In his SXSW talk Programming and Minimalism: Lessons from Orwell & The Clash, Jon Dahl from Zencoder asked what other activity is programming like. He acknowledged that it was valid to think of programming being an engineering discipline and valid to think of it as being a craft, but he mostly proposed that programming is like writing, in particular that programming is like writing musical composition.
One analogy he made was of how styles of programming evolve in the same way as styles of musical composition. Music styles tend to get more and more complex over time until some new composers create a new radically simplified style, though keeping the best of the earlier style. Witness Mozart rejecting the Baroque, Phillip Glass rejecting complex early Twentieth century classical music, and the punk rockers rejecting the preening intellectualized operatic rock of the ’70s.
Similarly in programming there are similar lurches back to minimalism in programming languages and in frameworks. Dahl did not explicitly talk about this, but I assume he meant the rise of Ruby on Rails and later similar systems which rejected the complex configurations and layering of both J2EE and Microsoft web stacks and replaced them with an elegantly simple framework that emphasized convention over configuration and “don’t repeat yourself”. I would also add the earlier eclipsing of C++ by Java is an example of a similar return to simplicity, rejecting pointers, multiple inheritance, and explicit memory management. The speaker also made a foray into the realm of writing prose. He quoted George Orwell who asserted that sloppy writing leads to sloppy thinking, such as how using the passive voice avoids being clear who is responsible for some action. Sometimes writing is deliberately sloppy, such as giving a law the misleading title “The Patriot Act” and not something like “The Enhanced Surveillance and Executive Powers Act”, which would have been more accurate but less likely to get passed by Congress.
All of this was entertaining, but seemed a bit of a stretch in its analogies to programming. I felt it was stroking the egos of programmers a bit, allowing them to see themselves not as code monkeys but as exalted artists. However, he did end up with a list of coding guidelines that I already generally do follow and which I think all programmers should consider:
- The simplest approach is always best.
- Clever code is bad code.
- Any code not doing anything is harmful.
- It is good to accept constraints of your language and framework, and not to fight against them.
- As much as possible move view code to the controller, controller code to the model, model code to a library, library code to an open-source library.
- Do not over-abstract.
- Always actively clean up your code, constantly.
- Break hard problems down to simple problems.