Now in Java there is "new" but no "delete", and all the dirty works are left to GC.
I wonder why is that?
If we have "delete" in java, developers can take partial responsibility of clean their own mess.
Is it possible that someday we have "delete" in Java?
Programmers can delete as many objects as they can remember and GC will only have to deal with things forgotten.
That will make Java more efficient.
Because people make mistakes and cause really hard to find memory leaks and do bad memory management such as double deletes so you get all these security leaks that you see often in the news. Plus it adds a whole lot of ugly boiler plate code.
Java is already very efficient; I don't know why you would want to go back to something as fragile as manual memory management just to squeeze a little more out. Better focus on learning how to properly work with the garbage collector so it can do its job properly in stead.
> That will make Java more efficient.
I seriously doubt that.
The common VMs are far more efficient than the standard C++ heaps in managing memory for running applications. That is possible because the algorithms used are far more complex.
C++ has delete but larger applications often need to take over memory management to make it more 'efficient' because of that.
And this presumes that, in general, programmers would be able to manage the memory more efficiently. Doing this correctly in C++ requires a deep understanding of how a specific application runs and how allocations occur. Along with a deep understanding of how C++ allocation works. Most programmers spend most of their time creating business flows and do not spend time learning and practicing the skills necessary to handle both of the those correctly. So in general those average programmers will not in fact be able to create more efficient management techniques. There is even a chance that they will in fact make it less efficient.
Yes, that. I spent the better part of 4 years diving that deep into C/C++ and assembly, becoming a technical wizard with it. At the end of those 4 years I started to come to my senses and drop the hate I had for Java at that time and could only come to one conclusion: why have I been wasting my time on that for so long focusing on low level code when I could have been learning how to properly develop applications and get a decent job?