Monday, August 22, 2011

Scala is Magical

The first post for this blog wasn't supposed to be about Scala, but the fact is, Scala is dominating my thinking currently, and there's nothing to be done about that.  This blog is about the making of a very large scale, long time-frame turn-based strategy game, and the first post should have been an attempt to describe the game.  However, I'd decided long ago to write the game in Scala, and I didn't know any Scala, so that's what I've been doing - learning Scala.

Scala is magical.  I am having a blast using it.

One thing I've learned is that magic in a programming language is usually bad.  My only doubt about this "fact" at the moment is that, all my experiences with magical languages previously have also been dynamic languages, and I'm wondering if the problem isn't more the lack of static typing than the perceived magic of the language.  Perl was magical too, for instance.  And 5 weeks later, indecipherable.  

However, in Scala, my IDE can take me to the definition of some inscrutable method that I'm calling.  It can tell me what type "x" is, or "_", for that matter, as Scala loves the underscore as the placeholder for variables.  Not nice, IMO, but at least Eclipse knows what it is and can tell me when I hover over it.  Try that in a dynamic language.  I note that, with type inference, I am utterly dependent on the IDE for this help.  Without it, I'd be as lost in my own code as I am when I write javascript or python.  I am not sure type inference is such a win.  It's true that I never work on code other than in an IDE, it's not true that I only ever read code in an IDE.  Sometimes I'm looking at code in a book, or at some code pasted to a webpage.  In those cases, I can't read it, as I have no idea what those single-letter variables are.

So, I'm definitely committed to Scala.  I hope the problem with this type of magic does turn out to be dynamic vs static rather than expressive vs verbose.