Real FSC support

Posted on by Pavel Fatin

Usual Scala compilation never seems fast enough. There are two main reasons why:

  • It takes a lot of time to start Scala compiler and to process standard libraries.
  • Scala compiler doesn’t support selective recompilation.

The first problem is solved by FSC (Fast Scala Compiler). FSC runs a compilation daemon to avoid subsequent compiler instantiations (at the price of increased memory usage).

However, FSC still re-compiles everything you throw at it (usually – the whole project, even if you’ve changed a single file). To speed up compilation further, we need to use a selective recompilation, that is provided only by third-party tools (like SBT or IDE).

So, the combination of IDEA and FSC can provide lightning-fast Scala compilation.

Scala plugin has been supporting FSC for a long time. Kind of… It was hard to configure and use FSC, settings was vague and compilation daemon was … you know, uncontrollable. Now that things have changed.

We can setup either internal FSC server (per project) or external (possibly remote) one:

Then we may use that server in any module we want:

So we can mix FSC with ordinary Scala compilers (when there are multiple versions of Scala used or when we need special compilation settings for some modules).

IDEA automatically manages internal FSC servers – it starts an instance when needed and stops it on application exit (or project close). Additionally, we can manually start, stop or reset compilation daemon using a menu on FSC status icon:

Besides FSC status icon (a little gear-gauge in the status bar) we are receiving notifications on FSC events:

P. S. Mac users may need to configure the OS X firewall for FSC communication.

Comments below can no longer be edited.

12 Responses to Real FSC support

  1. Christian says:

    October 5, 2011

    Hello,
    that is great news.
    Tried it out, it is extremely fast compared to before.

    Cheers,
    Christian

  2. Eric P says:

    October 5, 2011

    Scala 2.8.1 didn’t work (compile just hung) but after upgrading my project to 2.9.1 it worked great. Thanks! This is huge.

  3. Srirangan says:

    October 5, 2011

    Just what I needed for my current project, thanks!

  4. Adam Warski says:

    October 5, 2011

    Works great! Finally an easily useable FSC 🙂 Thanks for that update.

    Now if only autocomplete was faster … 😉

    Adam

  5. Krzysztof Białek says:

    October 5, 2011

    Perfect! This is really big improvement.

  6. Jan Kotek says:

    October 5, 2011

    Perfect. How did you dealt with FSC exiting after half hour of inactivity?

  7. Sam Hendley says:

    October 6, 2011

    I just tried FSC with intellij and found an issue with the compilation, I wasn’t sure where to post it so I made a ticket on main bug tracker http://youtrack.jetbrains.net/issue/SCL-3665

    Bascially “type aliases” dont seem to work in all cases. That sucks because the build was running much faster until these errors. Thanks

  8. Tomasz Nurkiewicz says:

    October 8, 2011

    Works like a charm, I haven’t even noticed the compilation prior to running tests after a change, finally! Thank you!

  9. Andrew says:

    October 11, 2011

    I’m finding it impossible to get rid of the “Compiler internal error. Process terminated with exit code 1” error. Non-fsc compile works fine. idea.log has nothing useful in it. I’m on IntelliJ 10.5.2 with Scala plugin 0.4.1440. My project appears to be identically configured to that of a coworker who is using fsc just fine. I’m on Windows, he’s on OSX.

    There is nothing on the net that offers any answers. Any advice?

  10. Maciej Biłas says:

    November 1, 2011

    Works great with Scala 2.9.1. Really accelerates the development.

    Thanks!

  11. Andrew Bate says:

    April 9, 2012

    I have wasted two hours trying to get this to work properly. Bottom line: support is still patchy at best.

  12. James says:

    May 19, 2012

    It work fine on my machine with W7. Amazing! Never seem a compiler could be so fast when Scala is productivity at best!