Saturday, November 7, 2009

Scala – Transition from Java to Scala - My initial experience and thoughts

A couple of months ago I was given a task at work that required code to be written in Scala. At first I wasn't so thrilled about the fact that I would be learning a new language but I must say after spending some time with it I am glad I did. The hardest part in learning Scala was the "getting started" part. The syntax of the Scala code is very different from Java and it required me to "concentrate" and to think a little before I could start my very first "Hello World" application…as you can see I wasn't very motivated. The sample applications were also a little difficult to follow because I wasn’t familiar with the syntax it required a lot more thinking and a lot more concentration…sigh…yeah like I said in the beginning I wasn't very motivated. However having spent a couple of months programming in Scala I am a lot more familiar with the syntax and believe it or not  the code has become a lot more readable, a lot more flexible and more desirable to write than Java code. I am amazed at how much you can do with so little effort.

It doesn't take too much effort for somebody who is a Java programmer to learn Scala. Like I said in the beginning the hardest part for me was getting started but after that I became excited about what I could do with this language and I became motivated to learn more. Scala compiles to Java byte code and runs on the Java VM. You can reference existing Java libraries in your code and make full use of their classes. Scala pretty much does everything Java does but on top of that it offers a whole lot more. I am also enjoying learning other programming concepts and techniques. Scala is an object-oriented and functional programming language. I am learning a lot about functional programming and I have started thinking differently about how I can use these techniques and concepts to produce better code.

So if you are interested in learning Scala and come from a Java programming background like me than I would recommend the following links:

There are also a number of open source projects written in Scala and I would recommend anyone getting started to download the projects and take a look at the source code. Below are a few I have come across and learnt from:
  • Lift - Scala web framework
  • TalkingPuffin - Twitter client
  • Scalaffinity - library containing core functionality used by any social networking web site
Post a Comment