Time has proven again and again that humans are really bad at memory management and having raw access to memory is something that needs to be justified on a case by case basis.
Well until AI write garbage collectors I'm not sure I see how your comment doesn't also apply to them. And lots of great software manages memory quite fine, like that browser you used to write your comment and the operating system it runs on, so not sure the use of "proven" is appropriate in your comment.
Which bit of the browser are you talking about? Garbage collection is used extensively during the execution of JavaScript in a lot of browsers. For example, Chrome [1].
[1] https://developer.chrome.com/devtools/docs/javascript-memory...
Most applications are _not_ games or web browsers, but enterprise-y CRUD applications.
I'm fine with having the ability to turn that off for specific things, but it should be made as inconvenient as possible to avoid the "Can't have GC pauses in my todo list" usecase.
https://developer.mozilla.org/en-US/docs/Mozilla/Performance
And are making Servo in Rust, which uses compiler dataflows form memory management.
Apple has added ARC to Objective-C and Swift.
Microsoft uses GC in .NET, ARC in C++/CX.
Modern C++ favors RC.
They all seem to think manual memory management is to be avoided.
However it does place a bit of cognitive burden, but last version already improved it.
Does it? I was under the impression that the order of preference (from most preferred to least) is something like:
- plain values (i.e. no pointers)
- references
- unique_ptr
- shared_ptr
- raw pointersYes.
> the others are the main/preferred strategy in those languages/libraries.
While true, manual memory management is still possible, but should be left for the 1% cases that really benefit from it.
I see what you did there. :)
The original posters meaning was that "malloc() has non-trivial execution costs", but the other meaning is, tautologically, malloc is the "complement" of free (think true is not false).
You are forgetting that Dalvik hasn't been touched since Android 2.3.
Of course, not much could be expected from it.
It's a bit like the folks who say that dynamic languages can be just as fast as compiled languages. Perhaps eventually, but in the here and now in the typical case that claim misses the mark by orders of magnitude.
There are plenty of very fast dynamic language runtimes: LuaJIT, PyPy, Spidermonkey, V8, SBCL, etc. They're all competitive with JVMs and some are consistently faster.
Dalvik avoided the state of the art on purpose, for some reason. It didn't even have a JIT by default until Android 2!
There are quite a few decent GCs out there, Dalvik's merely had almost no work put into it.
Sure, there are good GCs out there, but good GCs are harder than many GC proponents make out.
Take the top 100 most heavily used applications or platforms that rely on garbage collection. What fraction of them actually use decent GC implementations?
Also, you seemingly misread my other point about dynamic language runtimes, I wasn't comparing them to JVMs, I was comparing them to compiled code written in lower level systems languages (like C/C++). V8 may be fast, but it's not as fast as compiled code, yet. There's still a huge gap between theory and practice there.
Other than that, lag can come from many things, so if you lag without GC, the only solution is to profile that part of your app.