The Rise and Fall of Scala

There seems to be a consensus in the Java community that the Scala programming language is already on the decline. I consider this a pity because I always enjoyed programming in Scala. Actually, I even started this blog to support alternative JVM languages like Scala. But the market has decided differently. Moshe Kranc has written an excellent analysis about the rise and fall of Scala. I found Moshe’s article interesting enough to summarize it and to add a couple of thoughts of mine.

Before I start

However, I’ve also read some of the 169 comments to Moshe’s article, so I’d like to add a few words. First of all, I’m really fond of the Scala language. I’m not trying to write an anti-Scala article. Quite the contrary. I’m following the fate of Groovy and Scala for at least ten years now, and I’m still puzzled why the industry doesn’t adopt one of these languages. In many aspects, both languages are clearly superior to Java.

Groovy is Java on steroids: it offers a host of useful features while remaining 99% compatible with Java. In fact, every Java programmer is a proficient Groovy programmer, they just don’t know it.

Scala is a bit different because it doesn’t try to be compatible with Java. Granted, there are (somewhat limited) compatibility and interoperability on the bytecode level, but the source code looks remarkably different. But that’s simply the price you have to pay for a more flexible syntax, powerful type inference and much more. From a historical perspective, you can consider Java a radically simplified C++ dialect. Since the early days, the core Java language team added many features: Generic data types, lambda expressions, just to name a few. The Scala language was a pioneer for many of these features. Plus, it has been created as an academic greenfield project. I consider the result pretty convincing. For instance, this well-thought language design makes the powerful type inference possible.

So how come neither Groovy nor Scala have been widely adopted by the industry?

A couple of years ago I even proposed to use Scala as a first language for students and apprentices. However, that’s not what happened. In my daily life, Scala hasn’t made a big impact. It seems to be limited to certain areas like Spark, Akka, Gatling, and big data. It goes without saying that these niches are important, but as to my impression, the vast majority of programmers sticks to Java. That’s a bit surprising taking in mind that Java has been considered the assembly language of the JVM universe by some. Java is fast, rock-solid and boring. Programmers are less productive than they are in Scala because Java is such a ceremonious language. But still. Recently I’ve read many tweets stating that Scala is declining again. Let’s try to understand why. Moshe’s article is a good starting point.

Why is Scala losing traction?

Let me summarize his key points, adding my own thoughts along the way:

  • Scala brought functional programming to the Java world. Since version 8 Java itself caught up. So there’s no need to abandon Java just to do functional programming.
    Personally, I disagree with this, because functional programming usually feels clumsy in Java. It’s far from being a natural choice. So I usually deliberately avoid functional programming in Java, even when I happily embrace it when programming the same algorithm in TypeScript, Groovy or Scala. However, at the end of the day, it depends on the perception of the developers, and Lambda support seems to be convincing enough to stop them from learning a new programming language.
  • Scala is a challenging language that’s not easy to master.
    That’s something I noticed, too, and it’s not helped by the esoteric vocabulary of the Scala community. I never grasped the meaning of “monad” in philosophy, but it seems to be a building block of functional programming. I had a lot of fun studying category theory at university. It’s a slightly esoteric generalization of set theory. Interesting, but nothing you’ll ever encounter in everyday life. Unless you start learning Scala. I’ve read quite of few blogs about categories in Scala. I suspect that using such exotic vocabulary repels many newbies.
  • The syntax of Scala is too flexible. In particular, there’s operator overloading. Something I consider a great tool, but it has been used too often by many Scala framework programmers. I’ve seen entire frameworks consisting almost exclusively of methods bearing not a recognizable name, but a mathematical symbol. This allows for fast and efficient writing, but it makes it harder to understand the code, especially for the beginners. Plus, most operators are translated to methods taking the right-hand side expression as parameter, but it’s also possible to define operators that are translated to methods called on the right-hand side, taking the left-hand side expression as a parameter. That’s great, but it’s also something you have to wrap your head around.
  • Moshe also reports a lack of compatibility with older versions of Scala and Java.
    • Compiler speed

      Another complaint I’ve often heard is the speed of the compiler. The idea of adopting Scala is to boost developer productivity, but the slow compiler often eats a substantial portion of that boost. Combined with the steep learning curve results in a frustrating user experience. Over time, the compiler has improved a lot, so I don’t know if the speed of the compiler is still such an important issue as it used to be.

      Community support

      This is a point I’ve noticed more than once, but I haven’t used Scala often enough to be entirely sure. If you’re one of the Scala developers trying hard to help newbies on StackOverflow, the following lines may seem a bit harsh. The Scala developer community is very active, but many ardent advocates of Scala have an annoying tendency to be overly convinced of their language. As far as I remember, I’ve read several reports complaining about the lack of community support for beginners. On the other hand, that’s something where Java shines, especially on pages like StackOverflow or the Java code ranch, just to name a few. Recently, things are deteriorating, but for a long time, even stupid questions1 were answered quickly and patiently. As to my perception, the Scala community indulges in the superiority of the language to such a degree that this euphoria shows in the forums as arrogance. Truth be told, in the early days, the Java community did the same mistake. Adopting Java after a couple of years of C programming resulted in such a productivity boost that it was hard not to commiserate with the C or C++ programmers. Can you imagine how difficult it was to write a program without a blue screen? Nowadays, blue screens have almost completely fallen into oblivion. They aren’t associated with computer crashed. Instead, most people associate them with movie production.

      Critical mass: Java is everywhere

      I guess there’s at least one other important point. When Scala started to grow, the Java programming language already had reached a critical mass. No company wants to re-implement their entire code base. The promise of Scala is that there’s no need to do such a thing because it runs on the JVM and peacefully cooperates with Java. Unfortunately, that’s something managers have heard so often during their career that they consider it overly optimistic (to put it mildly). In this particular case, the marketing talk is mostly true, but from a manager’s perspective, it’s better to err on the safe side.

      By the way, there’s a similar critical mass on Windows desktop PCs and laptops. If I’m not mistaken, the vast majority of software targeting Windows is written in one of the Microsoft languages and IDEs, with the possible exception of games. Another example of a critical mass is PHP for web designers. Almost every web server, no matter how cheap, runs PHP. As a consequence, the major part of the internet consists of PHP pages.

      Are there other sources of change?

      The ubiquity of Java in the enterprise means that it won’t be replaced by a new programming language unless there’s a paradigm shift. Functional programming was a paradigm shift, but it was too academic to be broadly accepted. However, we’re currently living in the age of a major paradigm shift. The browser is becoming more and more important as a runtime environment. It’s incredible how many devices come with a browser. Smartphones and tablet PCs are only the tip of the iceberg. So I don’t expect major shifts on the backend side. Maybe a language like Kotlin is going to be the next big thing, but I doubt it. On the other hand, front-end programming is changing rapidly. The new hot programming language is actually a very old one: JavaScript. I hope it will be replaced by languages like TypeScript, but again, I doubt it. JavaScript already is ubiquitous. You can write a JavaScript program with a simple editor. TypeScript requires you to install several other programs first. You need a compiler, and to install the compiler, you have to install node.js and npm first. It seems most JavaScript programmers do this happily. But even so, it limits the ubiquity of TypeScript.

      By the way, both TypeScript and JavaScript are functional programming languages, and adopting a functional programming style feels natural in these languages. Maybe that the heritage of Scala. It gave us a fresh impetus and new ideas that influenced the Java programming language a couple of years later.

      According to Moshe, the Scala language is here to stay, at least in certain niches. It’s the language of choice for many big data problems, and it’s great for writing custom DSLs. The incredible flexibility of the syntax gives you a lot of freedom when you’re designing a DSL. You can even write DSLs that read almost like a stilted, but natural English text. That’s obviously not possible with Java. You can write a Java DSL without a lot of full stops, parentheses, and semicolons. That, in turn, means that you can’t use such a DSL to communicate with the business department.

      Wrapping it up

      Scala has played an important role in the evolution of Java and the JVM languages, but recently the popularity of Scala seems to dwindle for various reasons. What remains is the important heritage of Scala. Plus, it will persist in certain, even important niches. And who knows, maybe it’s going to rise from such a niche at some time in future?

      In particular, Gatling may attract a lot of curiosity to Scala again. It’s an opportunity to get familiar with Scala without having to port the business logic from Java to Scala. The future is open!

      Dig deeper

      Like said above, I recommend reading the article that inspired me to write this blog entry:
      the rise and fall of Scala by Moshe Kranc

      1. if there’s such a thing. Usually, “stupid” questions are simply questions asked by a beginner.

3 thoughts on “The Rise and Fall of Scala

  1. Ian

    It ignores the fact functional programming allows to do more with less and a 100 fold productivity boost thus eliminating the need for a lot of developers.

    1. Stephan Rauh Post author

      Not quite. Let’s assume you’re right and there’s a 100 fold productivity boost. How much does that influence the total cost of a project? Not much. Even in a software company programming hardly ever costs more than 30% of the total budget. You need to write manuals, you need your QA department, you’ve got a boss, there are secretaries and the HR department. Plus, you have to rent the offices. From the customers’ perspective, the cost of programming is neglectable. They, too, need their requirements engineering, their QA department, their IT operations and much more. All this usually amounts to 90% of the total costs of the projects. In other words: a hundred-fold productivity boost only influences 10% of the total project budget. Cutting 9.9% of the project budget is easily compensated by other means, such as hiring programmers specializing in languages that are badly paid.

      Basically, that’s the effect that’s working here: people like you and me proudly advocate great advances in programming, but this progress is simply ignored by the vast majority of the industry simply because they can afford it.


Leave a Reply

Your email address will not be published.