“Uncle John” McCarthy, the creator of the functional programming language LISP, died earlier this week in California at the age of 84.
McCarthy will probably best be remembered for being decades ahead of his time, working out how to make LISP manage entirely automatically the memory needs of programs running inside it.
Whilst explicitly requesting and releasing memory can make for well-thought out and efficient programs, even the slightest mismatch in your malloc()s and your free()s can lead to havoc. Crashes are almost inevitable – and that’s the best outcome. The worst is that memory mismanagement can lead to remotely exploitable vulnerabilities in your software.
These days, therefore, languages which manage memory for you are commonplace. Take Lua, for example. If you concatenate two text strings to build up an error message, you don’t need to worry if you’ve preallocated enough RAM to store the combined string. The language runtime will sort that out for you.
And when you’ve printed the error message, you don’t need to remember to return its RAM to the system. Again, the runtime will work out when the memory it loaned you is no longer needed, and take it back for later.
McCarthy not only pioneered this approach back in the late 1950s, he even came up with the name by which it is generally known these days: garbage collection.
But as McCarthy wryly footnotes in the 1995 online version of his seminal 1960 paper Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I (there isn’t a Part II), he didn’t get to introduce the name back then:
We already called this process "garbage collection", but I guess I chickened out of using it in the paper — or else the Research Laboratory of Electronics grammar ladies wouldn't let me.
Like household garbage collection, automated memory management in programming languages doesn’t magically make you an environmental greenie. (It’s still easy to use too much memory, or to create data structures which the system can’t later recognise as surplus to requirements.)
Garbage collection does, however, assist enormously with reliability, safety and security, and generally leads to much more elegant and maintainable code.
Thanks, Uncle John, and farewell.Follow @duckblog