10

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?

ziggystar
  • 28,410
  • 9
  • 72
  • 124
  • Some (partial) answers in http://stackoverflow.com/questions/3606591/why-does-intellij-idea-compile-scala-so-slowly – VonC Mar 17 '11 at 20:55

1 Answers1

10

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

rktoomey
  • 186
  • 1
  • 3
  • 2
    There is an Emacs plugin that allows you to use sbt in a separate buffer and another one which enables you to click on sbt error messages, jumping to the appropriate location in your sourcecode: http://stackoverflow.com/questions/4112838/emacs-ensime-and-sbt – axel22 Mar 17 '11 at 21:25
  • So there's no way of getting the sbt compile errors into idea? That's one of the cons of sbt I was wondering about. Thought the sbt plugin would handle this. – ziggystar Mar 17 '11 at 21:52
  • I've never used idea before, so I can't tell if there is such a plugin. – axel22 Mar 17 '11 at 21:56
  • I'm not an emacs user, but emacs with ENSIME is pretty sweet. There is an Idea SBT plugin, https://github.com/orfjackal/idea-sbt-plugin, but I just got used to the command line. – rktoomey Mar 17 '11 at 21:59
  • Is SBT still under active development? They have this RC0 for half a year now. – ziggystar Mar 18 '11 at 07:37
  • Definitely - the code lives at https://github.com/harrah/xsbt/ and there is a very active user group at http://groups.google.com/group/simple-build-tool – rktoomey Mar 18 '11 at 13:33
  • Can you explain why you prefer sbt to fsc? – mbdev May 25 '11 at 06:43