In this article, we will setup Scala in linux machine and will compare three popular IDE’s which support Scala and provide you my opinion which one is best.

Installation

  • Install Java

    Scala runs on JVM, (Java Virtual Machine) so I am going to assume you have JRE/JDK setup in your machine already if not go ahead and install sudo apt-get or yum install open-jdk or sun-java-6 etc

  • Download Scala

    Download Scala and copy to /usr/local/share/scala (I got it in /home/xxx/Programs/scala)

  • Make some sym links in your /usr/local/bin
      |  copy code |? 
    1
    2
     cd /usr/local/bin
    3
     sudo ln -s ../share/scala/bin/scala scala
    4
     sudo ln -s ../share/scala/bin/fsc fsc
    5
     sudo ln -s ../share/scala/bin/scalac scalac
    6
  • Type scala and you should expect a console something like this,
      |  copy code |? 
    1
    scala
    2
    Welcome to Scala version 2.9.0.1 (OpenJDK Server VM, Java 1.6.0_22).
    3
    Type in expressions to have them evaluated.
    4
    Type :help for more information.
    5
     
    6
    scala> println("Hello World")
    7
    Hello World
    8

  • Another Example

      |  copy code |? 
    1
    scala> val testList = List(1,2,3,4,5)
    2
    list: List[Int] = List(1, 2, 3, 4, 5)
    3
    scala> testList.foreach {i=> println(i)}
    4
    1
    5
    2
    6
    3
    7
    4
    8
    5
    9

If you could execute above examples, then you have installed Scala successfully in your machine.

IDE Comparision

I have written classic Inheritance Shape example in Scala ,

  |  copy code |? 
1
   
2
                    Shape  
3
 
4
         Circle    Triangle   Square
5

using three competitive Java IDE’s.

I ruled out Netbeans quickly just because there is not much documentation out there and also not much developers are involved in writing Scala plugin right now. Intellij and Eclipse both support Scala very well. Both Intellij Community/Ultimate edition supports scala, To install Scala in Intellij go to plugins section and search scala and install Scala. In Eclipse, go to the link above and get the update site url and install plugin in Eclipse using update site option. For me Eclipse is better than Intellij because, I was able to write Scala code in Eclipse as the way I used to write Java code in Eclipse. This is my opinion for now, it will change as my Scala codebase grows. In my next post, I will try to explain how we convert a bloated Java application to Scala application.