So this tweet: "Garbage collection helps programmers the way training wheels help cyclists. The analogy is pretty much exact." (https://twitter.com/cmuratori/status/569223413677494272)
Tobias: "is that because you consider "training wheels" insulting or because you disagree with the analogy?"
Good question. Twitter isn't terribly good at subtlety, so I don't know what Casey originally meant. Also I don't know Casey, so hard to even guess what he meant exactly. I suspect it's a bit of both: 1) "once you learn you throw away training wheels", and 2) "training wheels are for kids". I disagree with both; I think there are places where GC does make sense, even if you are an experienced programmer.
I find the "manual vs automatic transmission" analogy much better really (manual memory management = manual transmission; GC = automatic transmission). Now, I know next to nothing about cars (I do drive, but that's about it), so take this all with a grain of salt. That said, I'm not a cyclist either.
Benefits of manual:
- You can be faster than automatic (transmission | memory mgmt).
- Yeah the analogy is not terribly good wrt GC pauses.
- Generally is more economical: uses less (fuel | resources).
- You can go Manly Man on the others using automatic and say they are not real (drivers | programmers).
- Cheaper (I guess) | smaller code infrastructure.
Benefits of automatic:
- Does some of the usually boring work for you. In many cases it's one less thing that you have to worry about.
- If you're in (racing | high performance software), there are reasons why (semi)manual is used.
- While you're learning, it's massively easier (you have to learn to much all at once; one less thing to worry about is a bonus)
- Prevents you from some mistakes (wrong gear | leaks/doublefrees/...). These aren't a big problem once you have experience though.
- You can say the ones using manual are dinoaurs who know nothing about the modern world.
My point? It's a tool. Don't like it? Fine, don't use it. Like it? Fine, use it. In both cases, does not automatically mean the other side is stupid.
Note 1: Daniel's suggestion: "as with any tool, don't treat it like magic. know how it works". Which is true, but does not play well with car transmission analogy. I guess majority of drivers have no idea how transmission works (either kind).
Note 2: Tobias below makes good points about training wheels analogy. Sheet. You ruined my rant, Tobias! :)
I feel like maybe you are missing one aspect of GC with this analogy - or maybe it is covered, I'm not sure - which is that when writing a program, you have to make a performance-related decision before any code at all has been written. To later discover that the use of GC causes performance issues that are non-acceptable, and where the problem is not some inner loop or particular point in the program but the accumulated allocations over time, means rewriting from scratch.
Actually, maybe this is covered by the analogy - it's like deciding to participate in a rally competition with a car that has automatic transmission. At some point, it will be necessary to switch to manual to compete, which means switching to a new car. The cost of switching cars seems too small to really convey why this is an issue though...