Sunday, August 4, 2013

How I decided to learn Scala?

I started coding java in 1999 when I was working at the Sun Microsystems. It was the time when servlets was the newest and hottest technology. Before that I was developing perl-cgi and was  feeling the limitations of the perl paradigm and wanted to shift to a new paradigm, and oops felt the great option.

All these years,  I never felt comfortable with Java Threading model though, for concurrency coding the developer has to delve in lower levels, e.g. to set up thread priority you have to know how the operating system works, implementation of ++ operators, multi-core vs single core configurations.  I was also writing
 way too much boilerplate code, even the code for a simple bean is too bulky with all its getters and setters. The tools can help generate the code, but the classes are still too bulky. Six months ago I was writing a piece of code for a DSL, the idea was to use business analyst written methods, it was not that easy coding it in Java, Groovy made it work faster.


Considering all this, I thought it was time to explore other languages. I have of course been hearing a lot about Scala, and felt like it would be the best choice, but I wanted to make sure that it really was the best option for me. At the same time one of my friends  had become a champion for learning Ruby and another friend was complaining about the performance limitations he hit with JRuby for a large application. I was therefore looking for some objective information on the popular languages, and Walla, there it was 

Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages (Pragmatic Programmers) 

The book covered Ruby, Io, Prolog, Scala, Erlang, Clojure and Haskell.
From the book, one of the best books I read in a while, I slowly stated to come to a conclusion:

Ruby is all about the programmer productivity, very flexible, (open classes, missed method),object oriented with functional constructs,  and would be great to bring a product very quickly to the market. The concurrency is not very evolved. Duck typing is good, but absence of Static Typing can be a problem for IDEs and refactoring tools, and I am almost addicted to these tools, cannot imagine development without them.  I also gathered that my friend's experience about Ruby performance is not all that unusual, rather expected.
Io, a purely prototyping language, very small syntax, no syntactic sugar, reminded me of my graduate work using Lisp. On one hand, you don't have to spend a lot of time in learning the syntax, but on the other hand, you have to understand many concepts, did not find a large community. Helped me understand some Javascript concepts better, I don't really develop much in Javascript.
Prolog, I particularly enjoyed reading on Prolog a lot, nostalgia from my graduation thesis, which was in the area of Indian music recognition. Of course Polog is  the best choice when you can model your domain in rules, particularly for artificial intelligence. The best way to use Prolog would be inside a main application. It is not based on JVM.
Erlang, described in three words is Concurrency, Concurrency and Concurrency. It is also extremely reliable, since  reliability was a major requirement for Ericsson labs' Telecom applications. For a java Developer like me, it would be a totally new game. I am not sure about the community support and how easy it will be for me to debug, dig into language features.
Clojure, what I gathered from the book is very powerful and flexible. From the syntax and examples I thought that to exploit its power, one has to spend a long time in learning the language, and then I don't know how easy it would be to find a bunch of such programmers to build a project.
Haskell, a pure functional paradigm, it is not that easy for some one like me to shift my thinking from object oriented style. I think I would have to spend more time in design with Haskell, for most domains object oriented design fits so well. 

In a nutshell, I would learn any one of the languages mentioned above only if the app I want to develop warrants for it. E.g. To bring a web product very quickly to the market I will probably go for Ruby, to develop an extremely reliable, concurrent product I will think of using Erlang, for an artificial intelligence product, Prolog probably would be my first choice.

Right now I want to learn a language that I can learn rather quickly, with semblance of Java, with less boilerplate code, less bulky code, easier to understand and implement concurrency features, can use existing Java libraries and even home-grown code like JPA, JDBC etc, essentially runs on JVM, can let me think in OO paradigm, and yes Scala fits the bill.
Scala has coexisting functional and oo paradigms, it is easier to learn for a Java programmer compared to learning Haskell or Erlang, it is a very general purpose language, facilitates DSL, its static typing lets me use the IDEs and refactoring tools.

Once I came to this conclusion, I started looking for some good resources to learn Scala. It turned out that although comparatively shorter learning curve, Scala too needs some serious reading, and trying out programs. I have finally settled on the book, Scala in Action by Nilanjan RayChaudhuri.

I want to share my journey with scala on this blog. In the next post, I plan to cover the basic features of Scala.






 

1 comment:

  1. This inspired me to install Scala in Eclipse. From Eclipse Juno:
    Help menu --> Install new software...
    In text box enter as one URL:
    http://
    download.scala-ide.org/sdk/e38/scala210/stable/site/
    Click the Add... Button
    Give it a name

    See http://youtu.be/dGI04efb6hg
    For a video of the other steps.
    Go to 1 minute in. I have updated the URL for version 2.10

    ReplyDelete