Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to become more productive using Scala? (Tools, IDEs)

Tags:

scala

workflow

What Tools do you people use to work with Scala? For my learning phase, I used the Scala REPL and hacked some code with TextMate and compiled it with the scalac CLI. But as the projects grow in size, much more sophisticated tools are required.

I am aware of the Scala plugins for Elipse, IntelliJ and Netbeans and I tried them all. The best one is IMHO IntelliJ, but still far away from being perfect.

The major issue I have is the lack of auto completion. As a not-so-advanced Scala coder, I still dont know the whole standard API and have to switch between the Scaladoc and IDE regularly. This feels like "killing productivity". But they all fail to auto-complete method arguments. (I heard that method arguments are not included in compiled scala code, but what about attaching source to do auto completion?)

Another very annoying issue is the build process. I am using Maven to build my Scala projects and manage their dependencies. But nevertheless, I have to do a full rebuild to test my changes. Maybe I am spoiled by Eclipses incremental rebuild available in the Java world, but it feels like a big issue to me.

I like Scala very much and I feel way more productive while coding, but the lack of sophisticed tools let me feel less productive. And both seem to cancel out themselves.

So, whats my question? I doubt every single Scala programmer uses good ol' vim or emacs along with scalac to do their work. So what tools do you use? What workflows have you developed to bring speed into developing with the Scala language?

Edit

Clarification what I ment with auto-completion of method arguments.

val myList = "foo" :: "all your base" :: Nil
myList.partition(_.length > 3)

For the code above, IntelliJ fail to provide me with the information that partition requires that I have to pass a () => Boolean function. In fact, IntelliJ does not check for this contraint. I can pass a String and IntelliJ will not indicate my error until I do a compile.

like image 957
Malax Avatar asked Feb 27 '10 17:02

Malax


4 Answers

scalac

Get familiar with command line options to Scalac.

  • -deprecation
  • -Xprint:all: watch your code progress through compiler phases, very useful to see what implicits are applied.
  • -help / -X' /-Y` list all options.

The latest nightly builds of scalac include a bash completion file that makes these easier to use.

IntelliJ IDEA

Method completion with Javadoc (CTRL-Space, CTRL-Q/Apple-J) Screenshot

Parameter Info for the example in the question (CTRL-P) Screenshot

Method Argument Completion (CTRL-SHIFT-Space). Screenshot

You need to have the source or javadocs linked into the dependencies in IntelliJ to see the Javadoc.

It doesn't currently highlight type errors on the fly, as there are still too many false-positives in complex code. This is coming, though.

Simple Build Tool

SBT keeps the compiler resident, and analyzes dependencies between classes to allow incremental recompilation. It can also monitor for changes to source files and automatically trigger recompilation and/or test execution.

  • Continous Compilation: >~compile
  • Continuous Compilation + Test: ~test-quick

I have SBT and IntelliJ project configured in http://github.com/scalaz/scalaz, you could use this as a reference.

like image 111
retronym Avatar answered Oct 18 '22 16:10

retronym


I've been using Scala daily for the last six months. I'm still using vim (and ctags to find stuff), and Maven for builds. I've gotten some good mileage out of JRebel when working on Lift web apps -- it will reload changes on the fly without server restarts.

I spent some time looking into IDEs, but it got depressing really fast. I really missed a lot of Eclipse features at first, but after a period of adjustment I don't think I'm significantly less productive now.

I've heard some rumblings that NetBeans is the current champ for Scala IDEs, but I haven't tried it first hand.

like image 43
overthink Avatar answered Oct 18 '22 15:10

overthink


One simple way is to use fsc, an offline compiler. It maintains caches of information, and the standard compiler will talk to fsc (running as a daemon) and use its cached information during compilation, thus speeding up your compilation cycle.

like image 4
Brian Agnew Avatar answered Oct 18 '22 14:10

Brian Agnew


Here's my answer on a similar thread. After giving about an hour to Ensime. I just can't help but get the word out. I must say it's very, very well written for an Emacs package.

like image 4
Y.H Wong Avatar answered Oct 18 '22 15:10

Y.H Wong