Cleaner code in other languages
At SPA2010 Rob Westgeest, Marc Evers and yours truly hosted the workshop “Flying horses, Cleaner code in other languages”. This is a quick writeup accompanied by the flipcharts that were created by the groups to summarize what they learned.
We brought one exercise, to be carried out by pair programming. A pair can choose what ever programming language they want to use. We try of course to get an interesting variety of languages to learn from. We ran three 40 minute timeboxes. Each timebox consists of 25 minutes for actual work, and 15 minutes reflecting (about three different solutions presented on the projector accompanied by discussion). Some people switch pairs from one timebox to the next, so they can get hands-on experience of trying to solve the same problem in different languages. The goal of the exercise is not to finish first, or have the cleverest solution, but develop a solution that is idiomatic in the language one is solving it in, so that we could compare notes afterwards.
This time we had three pairs working in smalltalk (cincom smalltalk as well as squeak), two pairs in ruby, two java, and further pairs in Scala and Haskell.
A few pairs wrote examples using Rspec or Scalaspec, most pairs wrote ‘classic’ XUnit style tests. Some worked completely outside-in, other bottom up, and quite a few from the middle outward (me and my pair amongst others).
Some things that struck me:
- at least one of the smalltalk solutions I saw did not strike me as very idiomatic smalltalk (admittedly, the presenter said it needed refactoring, so they went for make it work/make it right).
- Nat Pryce noticed that collections were processed easier (and with less code) in the Haskell and Smalltalk solutions than in Java.
- The smalltalk pairs were the first ones to finish setting up their development environment and getting to work (Rob did a timecheck, the smalltalkers were the only ones working on the problem already). Having an environment that contains almost all the tools and libraries that you need gives a big speed boost at the beginning. What was more striking still was that all smalltalkers used environments they just installed and had not used before; I installed squeak last weekend, the others were using a fresh beta version of their environment.
- Many people had not seen (much of) haskell/ruby/smalltalk style of iterating over collections using blocks/closures, luckily these idioms seem to be trickling down to Java and C#.
As with the previous instance of Flying Horses, the Haskell pair was moving towards a complete solution the fastest. This may be because the exercise we use seems to find itself in Haskell’s sweet spot (parsing and manipulating data).
On the whole, the level of engagement was pretty intense (about half the participants continued working through the breaks, even though we emphatically tried to get them to stop ), participants said they got to see some very different ways of solving a problem from what they knew, so they came out of the workshop with puzzles to investigate further.
As one participant mentioned, code presentations work up to a point. They show what a pair has done, but it is hard to see what steps they have taken to get to the solution. Seeing the sequence of steps (and experiencing it) when you are part of a pair (especially with someone you don’t know) is very valuable. I’m interested in suggestions for getting more of the sequence of events (rather than the solution) out into the presentations.
We have tried letting people work with task lists and presenting from there (works somewhat, but may cause pairs to loose to much time on their small design up front).
Let a thousand languages bloom Below are the flipcharts summarizing some of the things people learnt from the workshop.
May 19th, 2010 at 10:04 pm
Thanks for such an interesting post (and indeed going out on a limb to try something tricky to organize). I also think applause should go out to those who participated… Not an easy thing to do. Thanks again
May 22nd, 2010 at 5:39 pm
Git is a great tool for making it possible to step through the step pairs have taken. We often use it reply history when doing code reviews.
The downside is that there is a bit of a learning curve, and the git environment and tools take 5 mins or so to set up (in a 25 min timebox thats quite a chunk)
Peter and I spent a few mins trying to get git and github configured at beginning so I could follow his Haskell steps, but we decided it was going to take too long and abandoned the idea.
It might work if you could get everyone set up first, and have an initial repository that everyone can fork with the initial materials in
May 23rd, 2010 at 3:15 pm
Hi Tim, thanks for the appreciation. After the first round there were only a few people who wanted (dared?) to rotate. After the second round there was a lot more movement. I guess people who attend SPA are not afraid to try something out (much less afraid than the general population of software developers I’d guess).
May 23rd, 2010 at 3:18 pm
Hi Laurie, thank you for the suggestion. I’m wondering how we could get git to integrate with the smalltalk environments, for the other ones I know how to do it (although smalltalk environments have the notion of ‘change sets’ already built in).
We have done (single language) workshops in the past where we gave everybody a subversion repository to work in. We would then show thecommits + build results on a projector while work was happening. This has the interesting side effect of making pairs commit more frequently; it stimulates a friendly competition to do more commits