Often, when you search around for posts on Scala, you find pretty scary looking posts which discusses some rather advanced topic of the Scala type system or something similar, or just how functional Scala is by reimplementing ideas from Haskell in it.
On the other hand, I’ve been using Scala for more than a year now, and I find the whole experience very agreable, not because of the crazy stuff you can do in Scala (well, at least, not ONLY because of the crazy stuff), but because of the everyday improvements over Java Scala provides. For example:
Map[String,String] table = new HashMap[String,String];
. The
default is that the variable is just the type of its initial value.In any case, here is what’s necessary to get you started with Scala (assuming you already know enough Java and the infrastructure.)
Just download Scala, unpack and add the “bin” directory to your PATH.
I’ve tried the following three IDEs.
You can go with either maven or sbt.
I found that a great way to start playing around with ideas is to use the script mode of Scala. You can directly run files by typing “scala some-file.scala”. In Scala, you can put as many classes into a file as you want, so why not just do a quick sketch of your ideas in a single file.
For all those people coming from Java, here is a short list of things you should know:
Unfortunately, the current implementation of the scala compiler takes very long to start up (a few seconds). To improve this, the scala distribution comes with a scala server called “fsc” which runs in the background, and you should definitely use it.
In Maven, the default to use fsc is controlled by the useFsc parameter of the scala:cc goal, but the default is true according to the documentation.
In IDEA, you control the setting through “Compiler > Scala > Use fsc (fast scalac)”.
Using fsc also has it quirks. Sometimes, when a lot of classes change or are renamed, it gets confused and needs to be restarted with “fsc -reset”. Especially on Linux, IDEA cannot compile if the fsc isn’t already running. You can vote up the bug, for the mean time, you need to periodically run a small compilation in order to keep fsc from shutting down.
Before I start to work, I start the following script
with the file helloworld.scala being the one-liner
or something similar.
Posted by Mikio L. Braun at 2011-04-05 16:47:00 +0000
blog comments powered by Disqus