Category Archives: Uncategorized

CodeMash Recap: Scala Koans Precompiler

Was it just last year that I attended Joe O’Brien’s Ruby Koans precompiler at CodeMash?  Koans are little exercises, designed to provide tidbits of knowledge that when bundled together provide an in-depth understanding.  What an awesome way to learn a programming language!

Last year at CodeMash (January 2010), Dick Wall and a few other people got together to work on koans for other languages.  This year, there was some interest in a Scala precompiler.  Since Dick wasn’t able to make the precompiler, I started looking for folks to help.  I hosted “Six Weeks of Scala” at the SRT offices in October and November, and many koans were written there, with the help of several attendees (notably Jeff Hoover).  Nilanjan Raychaudhuri and Daniel Hinojosa, both selected as CodeMash speakers, agreed to pitch in as well.

The idea of koans is that the student has to make only a very small, seemingly insignificant change to make each koan work.  By crafting koans around language features, students gain focused knowledge around the individual features.  The Ruby Koans set the bar REALLY high.  The EdgeCase folks have made their koans fun, even amusing.  Those who have done either set will agree with the inside joke that the Scala koans are still on their journey toward the path to enlightenment.

On the other hand, the koans were well-received.  We had a half-day precompiler session and we seemed able to keep 20 or 30 people amused and interested.  Many others tweeted after the fact that they too were doing the Scala Koans.  The best compliment we could have ever gotten was the guy who came up to me afterward and said that our koans had changed his opinion of Scala.  That he had thought he hated the language, but that he know thinks it’s “not that bad”.  He said that was quite a change in his thinking.  I’ll attribute it to his open mind, and the mantra of CodeMash, which is “Free Your Mind”.

If you want to try the koans, they currently live in 2 places.  We’ll ultimately consolidate them with the Functional Koans on GitHub, but for now you can find the “solutions set” at https://bitbucket.org/dickwall/scala-koans and the student exercises at https://bitbucket.org/dmarsh/scalakoansexercises.

The Ruby Koans have a script that generate the exercises from the working solutions set, but we’re not there yet.

To run the koans, you just need a JDK (1.6+).  We provided the precompiler attendees with sbt and a script that packaged everything that they needed to get started.

Just run:

sbt

~test-quick org.functionalkoans.forscala.PathToEnlightenment

From that point on, you will be able to edit the Scala files and make appropriate changes to get the tests to work. sbt will run the tests when you make changes.  Scroll back through the messages to the first error and make the change to fix the error.

The wiki includes a list of changes that we’re working on, as well as instructions of how to run the koans.

Enjoy!