Sunday, April 1, 2007

Programming and Music

This article was inspired (if not provoked) by Dave Thomas. It was several of his latest blogs that really made me stop, take a few steps back (actually 10000 or so km dividing Singapore and Slovakia) and take a break from the constant work cycle. Our circumstances couldn't be more different – he is an accomplished writer / programmer and founder of the pragmatic cult. Yet our daily issues, things we notice couldn't be more similar.

It started with Dave's blog drawing parallels between music and programming. Having finished 12 years of musical school (and frankly not having touched a musical instrument since). I've always wondered if we could get any inspiration for teaching / learning programming from teaching music. Maybe the most appropriate would be a jazz example, as jazz is probably the most flexible yet having a strong internal structure, patters and the same tune played by different musicians or played for different audiences may turn up completely differently. Just think of different renditions of Wonderful World. The parallel here is with pretty much any “standard software solution”. I worked on more than 20 inventory control systems and all of them were different – they used the same structure and patterns but the result was completely different for national distributor carrying 120 thousands different products and for a farm producing and selling bean sprouts.

Anyway, this is not so much about the end result as it is about the process. When you start playing a musical instruments you have to practice scales, etudes and and arpeggios. Sure you'll be playing some simple tunes as you go along but your daily bread for many years will be scales, etudes and then some more scales, and yes, etudes. From time to time, to boost up your motivation and to show the parents where their money is going, you play some concert gigs. From two note polka, when you're six through some Mozart when you're twelve to some Iron Maiden covers on your graduation party. Okay, maybe not that but when we played 6 saxophones + piano rendition of Chattanooga Choo Choo graduating from “school of classical music” everyone was equally shocked.

And this is exactly what I miss in my programming trainings. The first thing you learn on a new musical instrument is playing the scales, as they give you basic touch and feel of the instrument. As the notes are always the same you can fully focus on exploring each individual note, possibly different ways of playing it and slowly you learn to transition from note to note and you're getting comfortable with the full scale of the instrument. In software development I imagine this as a collection of simple challenges covering the basics of a language. Something like the really really great book Learn to Program, just a bit more structured and with many many more practice challenges. If you programmed in other languages and you're familiar with the concepts you will need just a few hours to go through and after you're done you will know the basic building stones of the language.

Later you move to etudes. Each etude is focused around a specific riff specific transition or specific problematic move but still having some kind of melody to make the learning process less boring. The idea is to practice this one thing over and over and over until you completely internalize it. This is another thing I really miss when teaching programming. To explain the collections in ruby is very easy – if you talk really a lot then you need maybe 10 minutes. Their so easy that their usually forgotten right away. Even if my students go through several “challenges” they're usually way too few and way too simplistic to really understand and internalize the collections so that next time they need a collection they will choose the right one without even realizing it and they will write iteration loop without even knowing it. And this is true for every part of the language (any language). When learning to play saxophone I went through around 4 etudes books every year. When teaching ruby programming I have nothing. The programming etudes would do the same as the musical ones – introduce various concepts, first in isolation later with more and more context and provide a wealth of challenges and questions to solidify the knowledge.

The last part of learning is working with the real life concepts – tinkering and playing with them and as there usually isn't just one way seeing it from different perspective and different angle. This part seems to be more addressed in programming as there are several good resources – for example Dave Thomas' Code Kata or book Ruby Quiz.

This is of course not to say that there are no resources for learning at all. Of course, there's plenty of books for every possible aspect of programming. Most of them, however, are written in more exploratory/reference style that is suitable for self study and exploration of the language, than for internalizing the concepts. An exception here is Java as there is plenty of preparation books for the first certificate and they provide sufficient number of questions and challenges. The truth is that ruby may not have reached the critical mass yet and it's used by people who “know how to use it”.

No comments:

Post a Comment