Interactive Scala Development with SBT and JRebel

Problem Statement

Scala REPL is a great tool for incrementally develop software. However, its is quite slow as noted here. Alternative: use Simple Build Tool, aka– SBT. SBT, via its tasks such as compile, run, console, facilitates a quick feedback cycle. The command sbt ~compile further provides continuous/incremental compilation model, that is– whenever a .scala file changes, it re-compiles them and generates .class files.

Problem is that in order to reload these changed class files, one has to restart sbt console. In my humble opinion, it seems a bit inconvenient.

Solution

JRebel provides dynamic reloading of modified *.class files. In combination with sbt ~compile, this setup leads to an interactive development experience as follows.

  • We run sbt ~compile in one console window
  • In other one, we run run sbt console.

Thus, when we modify Scala source codes, first SBT instance compiles it and generates class files. If we invoke any command in the second SBT instance, JRebel reloads the modified class files and afterwards the command gets executed, as shown below.

Note that JRebel is free for personal use, and it is definitely worth taking a look. For more information about the development flow using JRebel, SBT, Eclipse/IDEA, please have a look at this article which describes the setup process in details, or simply leave a comment.

Advertisements

One thought on “Interactive Scala Development with SBT and JRebel

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s