7 ms·
20 years ago in the programming languages lesson at the university we started learning about OOP using Java and Ada as examples. When the professor started desc
by spapas82 4y ago
20 years ago in the programming languages lesson at the university we started learning about OOP using Java and Ada as examples. When the professor started describing Java, a fellow student interrupted him to inform the class that "Java has garbage collection" (and boast of his special knowledge).
After that incident his nickname was "the garbage collector"!
- ajdude 4y agoCoincidentally, Ada optionally supports garbage collection in its specifications but it's up to the runtime to implement it.
- pjmlp 4y agoAnd since no implementation has ever supported it, it has been deprecated in ISO Ada 95 and further removed from it on ISO Ada 2012. https://en.wikibooks.org/wiki/Ada_Programming/Pragmas/Controlled https://en.wikibooks.org/wiki/Ada_Programming/Pragmas/Contro...
- admax88qqq 4y agoThere was this project though. https://github.com/Roldak/AGC https://github.com/Roldak/AGC The best part is that it's faster than manual management. People will tell you they need do to malloc and free manually for performance, but when you actually run the numbers GC wins for a majority of use cases.
- vlovich123 4y agoTracing garbage collectors don’t generally win against reference counting connectors, especially when those reference counts are automatically elided via ARC (eg swift and objective C) or because they’re rarely used by means of composition (c++ and rust). Additionally, different kinds of application strategies are better depending on the use case (eg a pool allocator that you bulk drop at the end of some computation). What papers are you referencing showing tracing GCs outperforming things? If it’s just the website, I think it’s an artifact of a micro benchmark rather than something that holds true for non trivial programs.
- kaba0 4y agoThen why do every performant managed language opts for tracing GCs when they can? RC is used in lower level languages because it doesn’t require runtime support, and can be implemented as a library. As I wrote in another comment, even with elisions, you are still trading off constant writes on the working thread for parallel work, and you even have to pay for synchronization in parallel contexts.
- adgjlsfhk1 4y agothis isn't fully true. Java is in the process of getting lxr which is uses both tracing and reference counting.
- NobleExpress 4y agoYes and no. LXR is a highly optimized deferred and coalesced reference counting (amongst many other optimizations) GC and it looks nothing like the RC implementations you see in other languages like Python, Nim, Swift, etc. So yes, reference counting can be performant, _but_ only if you are using a deferred and coalesced implementation as otherwise the simple implementation requires atomic operations for every pointer read/write operation (though compilers could optimize it to use non-atomic operations when it's sure semantics are preserved). EDIT: The post you're responding to is referring to the simple standard implementation of RC.
- vlovich123 4y agoRust doesn’t use multi threaded Rc unless you actually need to send it across threads.
- NobleExpress 4y agoI'm aware. Rust isn't a conventional "managed language" which is why I consciously omitted it from the above list. In an increasingly multi-threaded world, you just have to use the synchronized version of RC (aka Arc<T> in Rust).
- kenniskrag 4y agoHow is that possible? Sounds counter-intuitive. Do you have a recommendation for reading?
- lispm 4y agoThere was an Ada implementation on the Lisp Machine, that might have been using GC.
- pjmlp 4y agoAs for .NET and JVM implementations, but that is a consequence of underlying platform, just like C++/CLI and C++/CX, and none of them have been that big into the Ada compiler market.
- syngrog66 4y ago> and further removed from it on ISO Ada 2012. and in that precise moment Ada proved it had garbage collection all along
- pjmlp 4y agoBy that measure same applies to C++, as C++20 removed the GC API introduced in C++11.
- polynomial 4y agoAh, same as C++ it sounds like.
- mcculley 4y agoWhich means no library can depend on it, pushing memory management responsibilities into calling code.
- chinchilla2020 4y agoPlot Twist: 20 years later, he wrote "The Garbage Collection Handbook" and is the leading authority on garbage collection.
- seanp2k2 4y agoStop-the-world indeed