Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala+IDEA: Pros and cons of sbt and fsc

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?

like image 500
ziggystar Avatar asked Mar 17 '11 19:03

ziggystar


1 Answers

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

  • http://github.com/mpeltonen/sbt-idea - easily create and keep your Idea project in sync with your sbt project
  • http://github.com/orfjackal/idea-sbt-plugin - lets you create run profiles for sbt from within Idea (I found this slower than running sbt at the command line last October - but I see orfjackal is still developing so I should give it another shot)
like image 130
rktoomey Avatar answered Oct 13 '22 08:10

rktoomey