01 Feb 2008 Google Programming and the Dangers of the Cargo Cult
A while ago Mark blogged on his experiences learning Rails using screencasts. Around this time he also confessed to me that he accomplished many things in Rails simply by doing a Google search for it. I thought I’d try a similar approach and it worked remarkably well.
For example, I might type in ‘how do I use fixtures when my table name is different from my model name?’. Google would usually figure out which words had the most weight and I’d get lots of useful results.
To me, it’s the ultimate answer to the question we pose when we say ‘Somebody must have had this problem before’. I even found myself using a phrase to describe it: ‘Google Programming’.
A related phenomenon is what I call ‘Google Debugging’: say my Rails application crashes with some mystifying error message from Ruby or Rails. In the past, I would have cranked up a debugger or started digging through documentation and code to try to figure out what’s going on. No more – now I just Google for the error message. I literally copy and paste the whole thing into Google (minus any stuff specific to my app) and search for it. If I don’t find anything, I strip it down until I do.
The most serious consequence of Google Programming is Cargo Culting – doing something you don’t actually understand. This can lead to crufty code or even bugs. 37signals’ Jamis Buck recently railed against it (no pun intended), but it’s another way of describing an old problem – ‘best-practices’ applied indiscriminately and without consideration, leaving a trail of systems over-engineered in all the wrong places and under-engineered everywhere else. My favorite example of this was JEE Blueprints.
So how does one avoid the perils of Cargo-Culting whilst experiencing the productive joy of Google Programming? I’ve found that the best way for me is to strike a balance between doing and learning. As I work, I do whatever I can to get things going. If I find myself asking ‘why?’ about something, I make a mental note of it (or even an actual note). When I’ve got a couple of minutes of downtime between tasks , I grab the appropriate reference book and seek the answer to the question. If I’m short of time, I’ll take the book to lunch or take it home, and make a point of reading it there.
It only takes minutes at a time, but when I do this over a period of months I end up accumulating a bunch of knowledge. Furthermore, the learning process has been driven by real-world experience – the best way to learn. So by all means embrace Google Programming, but balance it with learning if you want to avoid being a member of a Cargo Cult.