radon-project / radon

The Radon Programming Language
https://radon-project.github.io
GNU General Public License v3.0
23 stars 2 forks source link

We will add a `__destructor__` method to delete the object. #93

Closed Almas-Ali closed 2 months ago

angelcaru commented 2 months ago

Personally, I think this is a TERRIBLE idea. Just look at the Python docs and see how janky __del__ is. It may never run, it may run during interpreter shutdown, when built-in functions like print are already GC'd away, and if it does run, there are basically no guarantees about when. And having built Radon on top of Python's GC will only make it even worse.

The alternative in my opinion would be a __close__ method (or whatever the name may be) that would function in a construction similar to Python's with.

Almas-Ali commented 2 months ago

How can we deal with Memory Management and Garbage Collection you think?

Even I rarely use __del__ method.

angelcaru commented 2 months ago

What do you mean? Python already deals with GC for us; it would only be an issue if we tried to rewrite the project in a language like C or god-forbid C++

Almas-Ali commented 2 months ago

Was thinking about a manual process, not by Python's automatic GC.

angelcaru commented 2 months ago

But I don't think that would have any benefits over sticking with what we're doing now. If you think that writing our own GC in Python (like you seem to suggest) would bring any benefit, please explain

Almas-Ali commented 2 months ago

It should make speed improvement or give user a API to manage memory by them self. It's just a theory, I don’t have any Idea what and how to do this anyway!!

angelcaru commented 2 months ago

But Python code will always be slower than equivalent C, so getting speed improvements from writing our own GC makes no sense! As for the API, maybe we could expose the functions from Python's gc module, but I don't really know if that would work out very well. Even if it doesn't, I don't think it's worth the speed toll.

Almas-Ali commented 2 months ago

In that case I think we need to stop this topic for now. We'll see if we need this in future.