I really hate when this happens

I burned most of my productive time on Tuesday with an infinite loop in the Scala compiler. It made me very, very grumpy.

First, you can find the code that reproduces the problem in the Visi repository.

To reproduce the problem, clone the repository, checkout the scala_infinite_loop branch, cd visi/core/scala, type sh sbt11, and in sbt, type compile and then test.

The following lines cause the infinite compiler loop (lines 200-202):

private def lineFeed: Rule0 = rule {
  zeroOrMore(EOL | EOI)

But, if you change the code to:

private def lineFeed: Rule0 = rule {

The code compiles and tests just fine.

Why this is a problem

So, in most computer languages, it's not a problem to have a bug in the compiler... complex systems have complex bugs.

The problems that I see here are:

  1. The problem manifests itself when program B is compiled against program A and the type signatures have not changed between the two code inputs. This is a serious problem.
  2. I cannot change to a different release of the compiler because of Scala's version fragility issue. Yes, I spent more than an hour looking for Scala 2.9.1 and 2.10.0-RC?? versions of the libraries that Visi depends on and the only combination of the libraries I needed were in Scala 2.9.2.
  3. It takes a long time to fix bugs in the compiler like this pattern matching bug that took 4 years to get fixed.

My switching costs are too high

I've spent 6 years learning Scala, writing web frameworks for Scala, writing books about Scala, and bending my brain to code the Scala way. Building a complex system in something that's not Scala is more than I can do right now. My switching costs away from Scala are too high.

Yeah, I know I'm likely to be insulted for pointing out the fact the Scala is not yet ready for prime time, even after 2 years and more than $3M of investment in a commercial Scala company. But, I've been a huge advocate for the value of Scala (it's awesome for small, hot teams like Twitter and Foursquare). It's equally true that if you adopt Scala, many of the benefits to the developers can be destroyed by the bugs, the versioning challenges, the challenges of having legitimate concerns being heard by a community that's steeped in academia, and the value of research over stability.

Choose Scala wisely.