Programming  /  Scala August 16, 2010

Learning Scala

A while back I read a blog post titled “If you have to learn just one programming language” by Babu Srinivasan in which he played with the scenario where you as a professional developer were to learn one, and only one, new programming language. In the post he listed 13 criteria and then compared a bunch of languages to those. Out of all of the languages, which consisted of Common Lisp, Scheme, Fortran, Smalltalk, C, C++, Objective C, Ada, Java, Javascript, C#, D, Prolog, Perl, PHP, Python, Ruby, Groovy, Clojure, Lua, Forth, Factor, Erlang, OCaml, F#, Clean, Haskell and Scala he proclaimed Scala the winner.

While I think it’s an excellent idea to learn new programming languages, if not only to view the ones you work with on a daily basis from a new perspective, I’ve been kind of stuck in the .NET world since I started working professionally with software development. Reading Babu’s article peaked my interest not only in Scala but in learning a new language in general. Also, in June I had the pleasure to attend the Norwegian Developers Conference where there was quite a lot of talk about looking outside the Microsoft ecosystem (if not only to bring back new ideas to it), particularly at Ruby.

So, I decided to learn (at least) one new language this summer and while there are quite a few languages that interest me I thought I’d give Scala a go as it seems to be a fascinating programming language with a bright future ahead of it.

mouse-on-skateboard I think writing is a great way to consolidate and cement knowledge so therefore I plan to write about my experiences and what I’ve learned from diving into Scala in a series of blog posts of which this is the first. They will be very basic, at least at first, and written from a C# and (sometimes) Java developers perspective. Join me on an adventure outside the comfort zone?

A first look at Scala

Scala is a statically typed language that was conceived in 2001 by Martin Odersky who has also written the Java reference compiler and co-authored Java generics. It is both a functional language, meaning that functions are values, and also an object oriented language where every value is an object. Scala compiles to byte code for the Java Virtual Machine (JVM) making it platform independent. That also means that we from a Scala program can use existing Java libraries and vice versa. While it seems the primary focus is on the JVM it can also be compiled for the .NET framework’s Common Language Runtime (CLR).

Other than the fact that Scala is a multi paradigm language that can be used both on the JVM and the CLR I’ve also found a bunch of other things that I find interesting about it:

  • Scala is very well suited for creating both internal and external domain specific languages (DSLs).
  • Scala has structural typing, sometimes referred to as duck typing done right (I have no idea if it actually is though). David Pollak describes Scala as “the statically typed dynamic language”.
  • Scala has traits which can be likened to interfaces with implementations, or controlled multiple inheritance.
  • Scala supports both thread based and message based concurrency, the latter using the actors model like Erlang.
  • There are a number of web frameworks for Scala of which Lift seems to be the most popular.
  • Several Java IDEs have support for Scala.
  • There are a number of existing testing frameworks, both for creating traditional unit tests and BDD-style tests.
  • Scala works smoothly on Google App Engine and can be used to create Android apps.

For some great slides on the many cool things that Scala has to offer check out Jonas Bonér’s Pragmatic Real-World Scala presentation.

My learning companion

programming scala cover When it comes to learning a technology that I’m totally new to I like to enlist the help of a book. I settled on Programming Scala by Dean Wampler of Object Mentor and Alex Payne from Twitter, mainly because it was the shortest book I could find about Scala. While I put my faith to this book to give me a solid introduction to Scala I will probably create my own curriculum to suite my, and hopefully the readers of this blog’s, background.

The next step

In the next part of the series we’ll look at how to install Scala and at a few tools that we can use. Once we’re done with that we’ll do the mandatory Hello world application in the third part of the series.

Posts in the series

  1. Introduction (this)
  2. Installation and tools
  3. Executing Scala code
  4. Classes and constructors
  5. Methods
  6. If statements and loops
  7. Traits
  8. Scala’s type hierarchy and object equality
  9. Uniform Access
  10. And more coming in the near future…

PS. For updates about new posts, sites I find useful and the occasional rant you can follow me on Twitter. You are also most welcome to subscribe to the RSS-feed.

Joel Abrahamsson

Joel Abrahamsson

I'm a passionate web developer and systems architect living in Stockholm, Sweden. I work as CTO for a large media site and enjoy developing with all technologies, especially .NET, Node.js, and ElasticSearch. Read more


comments powered by Disqus

More about Scala