Twitter moves from Ruby to Scala

I just read this on The Register (I hope it’s not an April’s Fool piece), about Twitter moving from Ruby to Scala as its main programming language.

Not so important actually what Twitter is doing with its code, I was more intrigued by this new language, Scala, which I didn’t know at all. So a good chance to dig into it.

Scala (pronounced /ˈskɑːlɑː, ˈskeɪlɑː/, funny it means ladder in Italian) according to Wikipedia is a multi-paradigm programming language designed to integrate features of object-oriented programming and functional programming.

Functional:  functions are in Scala fully-fledged elements, they can be assigned to variables and used as parameters; closures are also available.

Object oriented: everything is an object, including primitives and arrays.

Type inference:  Scala tries to overcome the strong statical type features of Java, deducing automatically the type of a value, as in Ada or C#.

Concurrency: Scala uses more modern constructs as the actors, instead of threads as in Java. This could be a very important feature now, with multi-core processors and distributed computing.

The most interesting is that Scala runs on the Java platform (Java Virtual Machine) and is compatible with existing Java programs and can use the Java libraries.  It also runs on Java Platform, Micro Edition (J2ME) Connected Limited Device Configuration.

Twitter is a fast growing website that provides a micro-blogging service. It began its life as a Ruby on Rails application, and still uses Ruby on Rails to deliver most user-facing web pages. But about a year ago they started replacing some of the back-end Ruby services with applications running on the JVM and written in Scala.

Quoting from this article on Artima:

One of the things that I’ve found throughout my career is the need to have long-lived processes. And Ruby, like many scripting languages, has trouble being an environment for long lived processes. But the JVM is very good at that, because it’s been optimized for that over the last ten years. So Scala provides a basis for writing long-lived servers, and that’s primarily what we use it for at Twitter right now. […]

Also, Ruby doesn’t really have good thread support yet.

Now I’m quite curious about Scala, needs to try it and see if could really substitute Java in the medium/long term.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s