Question

I'm currently using IDEA's build mechanism with fsc for developing with Scala. It's still a bit slow and having to (re) start the compilation server is a pain. Many people here are suggesting SBT as a build tool together with IDEA.

What do you consider the pros and cons of each approach?

Was it helpful?

Solution

I tried both and in the end I prefer straight sbt for compiling.

Cons? I really miss being able to click through compile errors and fix the code directly, but... compiling in sbt is just much faster.

The nightly builds of the Idea Scala plugin can vary in quality/performance, but it's been getting better and better lately. The Scala plugin can now flag a number of errors that before I would have had to run compile to catch. (For example, I'm running nightly build 0.4.693 and the new method inspections have already been dead helpful.)

My advice for life with sbt on the command line: start sbt up and leave it running interactively as long as possible to take advantage of everything being loaded and JIT-ed.

sbt left running will fall over eventually but by giving it more memory in your sbt wrapper you can make that happen only rarely.

Here's the sbt launch wrapper that works for me.

java -Xms512M -Xmx1500M -XX:MaxPermSize=512m -jar `dirname $0`/sbt-launch.jar "$@"

My biggest issue with sbt 0.7 is that it frequently goes back and recompiles great swathes of files that seem only tangential to the code I was actually changing. (Even so, still faster than Idea and fsc!)

Good news: sbt 0.9 has some great incremental compile improvements. Unfortunately, the migration path from 0.7 to 0.9 is still in its early days. Mark Harrah's presentation at NEScala is online at http://www.nescala.org/2011/ if you're interested.

Useful plugins

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top