I’m coming from a PHP/Python/Javascript background, and recently became very interested in Scala – specifically Akka coming from the web standpoint.
I’m having an extremely hard time though with general workflow, issues compared to interpreted languages such as the ones I described.
In general I tend to code, test results, code and repeat. This comes to a standstill when even changing a single line in a 20 line class takes up to 30secs to compile and run. Is this really normal? Do I need to just build, build, build then go back 30 minutes or an hour later and compile/test?
(I’m using IDEA with SBT) Do I need to specifically learn how to use Maven other than linking to the repos?
Thoughts? Advice?
I think you’re on the right track with Idea and SBT. Have you tried
That will detect changes to your source automatically. For web applications, you can do a
followed by
To continuously compile and redeploy your app to jetty. Makes Scala dev feel a lot like Python web development.
Usually I’ve found SBT to be very fast when compiling, especially the size file you’re talking about. By the time I save my change and go to my SBT prompt, it’s done.
Another handy SBT aspect is the REPL which will load your project and its dependencies:
You can reload any compiled changes with
in the scala REPL.
EDIT:
Guess I should mention that you can play around with a simple class with a main method. If you create a file called src/main/scala/Foo.scala that looks like this:
And a file project/build/Build.scala like this:
Then at the sbt prompt, you can do
To continuously compile and run the Foo.main method. You may need to do a ‘reload’ in sbt first. It seemed to take 2-3 seconds from saving change to seeing output. Then you just edit away, save and see changes. It’s a pretty good workflow.
Also, don’t forget the REPL – definitely a critical tool for learning Scala. You can learn a ton just playing with it interactively.