Home - Archive - Snipposé - Rename Finder Items

It's Almost Like Garbage Collection Isn't Worth It

In a recent article about Dropbox's move from AWS one of the challenges discussed was the inefficient use memory in the "Magic Pocket" system which was written in the Go programming language. Eventually, the team decided to move to Rust.

Of course, the Go programming language was developed by Google to create an "expressive, concise, clean, and efficient" (oops!) language with "concurrency mechanisms [to] make it easy to write programs that get the most out of multicore and networked machines". It's a statically typed, compiled, garbage collected language that's meant to feel like a dynamically typed, interpreted language. On the other hand, the Rust language, like the Swift language from Apple, is also a statically typed, compiled language that feels like an interpreted, dynamic language, but notably does not rely on garbage collection for memory management but rather automatic reference counting. This tends to lead to smaller memory footprints and much more deterministic performance due to no garbage collection overhead.

Apple made the same technical choice, abandoning garbage collection in favor of static analysis and automatic reference counting for Objective-C and Swift. This analysis also permits types to be inferred in a such a way that Swift feels more dynamic than, say, Java or even C#.

Compilers are becoming sufficiently advanced that types and even memory semantics can be inferred without having to either explicitly state all of it using type ontologies or memory management code or pay massive runtime overhead for an interpreter or garbage collector.

I can't help but wonder if elaborate type systems and memory managed runtimes will turn out to be temporary, expensive workarounds waiting for compilers to get smarter.

Look, for example, at the so-called "dumpster fire" that Dalvik & ART seems to be on Android, how a top of the line Android device with twice the RAM of the equivalent iPhone can't keep applications in memory or suffers long startup or download times because of the JIT.

While type systems can make coding painful and pedantic, garbage collectors bring a heavy runtime cost that's noticeable on small devices or at scale. It's almost as if garbage collection isn't worth it.