If you’ve ever experienced the phenomenon where you pick up a new word and then noticed it used everywhere, I’m getting that sensation now, noticing Scala in places I hadn’t noticed. I’ve been learning the language Scala recently. No, it’s not a dialect of Spanish, it is an object-oriented and functional-programming language.

Most applications and web programming are built with object-oriented languages, where functions (or methods) that do things are put inside containers called objects, of a particular type (or class). The language Smalltalk pioneered this form of programming, but C++ was the first object-oriented language to achieve widespread adoption in enterprise applications; in many engineering and heavy-duty applications, it’s the dominant language. C++ did this by building on the language C, the dominant language for UNIX programming at the time. Then came Java, improving on C++ in some ways like garbage collection, and now Ruby and PHP5 and others have followed the paradigm. Object-oriented programming enforces modularity and information-hiding in programming and enables large-scale programming through component-based design and code reuse.

Scala is built on Java and compiles to the JVM (Java Virtual Machine), but it adds functional programming constructs and features that take it beyond Java. In the process, it cleans up Java code so much that line counts for the same application could be cut in half.

What’s great about ‘functional programming’? There are powerful things you can do with programming if you can treat functions as modifiable variables – passing them as arguments, using them recursively to build complex meta-functions, and redefining function behavior dynamically. It enables terseness, flexibility, and powerful Functional programming is far from new, as the original functional programming language Lisp dates to the 1960s, and its power enables a programmer to write powerful yet concise code. Productivity increases if you can do more in fewer lines of code, so functional programming can make a programmer more productive.

Yet functional programming, since the time in the 1980s when Lisp machines rose then fell, has been relegated to academic use mainly – Prolog, Erlang, Haskell, and other elegant but obscure programming tongues. The functional paradigm may have been overlooked as it was treated as orthogonal to object-oriented paradigms in prior languages. Scala changes that. Is it that most programmers cannot handle functional paradigm complexity? asking some to learn Scala is like asking them to learn calculus while learning Java is like learning algebra. Scala is accessible to Java programmers.

The reason I came to Scala was to explore its potential for concurrent and parallel programming. To me “the data center is the computer” and we need programming models to program to match large-scale parallel clusters of multi-core computers. Scala is about ‘scalability’ and I’d like to see if and how Scala can scale in parallel. Java has threads and C++ has Cuda and MPI and OpenCL. Yet underneath these construct are imperative programming models that force programmers to design concurrent algorithms via sequential-based threads and languages. Decades of research, yet progress on the software side of parallel computing has been slow. Software is the bottleneck in leveraging the power of parallel computing. Why? We haven’t ‘cracked the code’ of concurrent programming models that are general, efficient, and natural-to-express all at the same time. Scala uses the concept of “Actors” with built-in message passing, so a concurrent program can be written naturally. Moreover, it has features which a team in Stanford has used to build a

The multi-paradigm aspect of Scala is a double-edged sword. Scala’s features and power adds complexity (the calculus vs algebra analogy). Now, a programmer doesn’t need to access all the features to gain benefits with it, as Scala code can be written in mostly object-oriented fashion, but users will have to know Scala syntax to understand other code. Some people think Scala’s grab-bag of features make it the next C++. In most of the debates where this meme is brought up, it’s derogatory towards C++ as in: “I’m pretty sure C++ concluded badly. I have no idea how Scala will conclude.” When I think of a Swiss army knife of a language, I think of Perl, a language with awkward syntax and enough miscellaneous powerful constructs that there is always more than one way to solve a problem in Perl. It hasn’t hurt Perl’s power nor popularity. But if features are too complex to be used well, or if the complexity creates possibility of misuse, the power of the programming language will be diminished.

Another way to look at it is to see C++ as an industrial-adoption of a new programming paradigm. C++ was and is a powerful but somewhat messy language, that lacked the ‘purity’ of other object-oriented languages, but its accessibility to C programmers enabled widespread adoption. Languages since C++ haven’t turned back from the object-oriented paradigm.. So my view is more like this: “I think it’s safe to say that the popular object-oriented design principles that we all take for granted would never have evolved to this level without the introduction of C++.”

So it will be with Scala. Scala has broken important ground in combining functional, concurrent and object-oriented programming, bringing together paradigms found in Lisp, Java, Smalltalk, Erlang, and, yes, C++. That alone makes it interesting. The web development frameworks already built on Scala (Lift and Play), and its use as a scalable back-end for sites like Twitter and Foursquare, alone make Scala useful and important. We need better tools for concurrent and parallel programming; that alone makes Scala directed towards the future needs of computing. Scala’s connection to Java, like C++’s connection to C, gives it a base of familiarity, enabling Java programmers to embrace Scala as “a better Java”. All these are good reasons to suspect Scala is the next big thing in programming languages. Whether Scala become widely used or not, Scala is the most important programming language for a programmer to learn right now.

That’s why I’m learning Scala.

By Patrick