Concepts of programming languagesJava 8

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.

7 thoughts on “The Rise and Fall of Scala

  1. 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. 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.

  2. Perl is an excellent programming language if you can ignore, hardly so, the fact that one can write a code in 10 different is all cool, if you are a programming language researcher..but a software project, as the author correctly pointed out in previous comment a business undertaking…maintenance is the single most cost volcano…Scala, in my opinion does not work well when your project team is not just you…I totally agree that it also has a pedantic attitude towards its constructs …as a result a steep learning curve….it is opposite to what a language should be…it should allow the programmer to be pedantic or otherwise…C, Java all have this inherent beauty of simplicty…Software engineering project should be about solving engineering problems….scalability, performance..etc.. not language nightmares… In my opinion Scala does not solve anything that Java or C cannot or do not…and it is not fit for large project adoptions..unless you are ready to police your developers adopt a coding style regime..

    P.S: above is strictly my personal opinion.

    1. I think that Java shaved too many features off C++. Scala tried to fix this error. People keep telling me that that’s why learning and using Scala is difficult. Too much freedom. So maybe a culture of reading each other’s code and giving feedback frequently might be a solution.

      Currently, TypeScript is my favorite language. It’s sort of Java the way it was meant to be. It’s more flexible than Java. There are many interesting and useful features. Even so, most of the time, I’m reading clean source code.

  3. You don’t understand Scala, Java is garbage, what a dumb post and other additional fear-motivated reactionary ranting.

    Yes, definitely appears time to return to Java.
    Seems Scala was just a fad with too much baggage that weighed it down. I enjoyed writing Scala and once considered it my favourite (Queen’s English you scrub of a browser) language. I enjoy being paid to write Scala and I think I am very knowledgeable, but I find for pet projects off-line I choose Java, and I think that’s pretty indicating.

    My issues with Scala in ascending importance:

    7. When I go to read about Scala I find material telling me to write Haskell.
    6. Runtime debugging is a lesion in masochism (yes I meant lesion).
    5. I find implicits cause more pain than they’re worth (see #3 and #1).
    4. There’s all this syntactic flexibility but no half-decent built-in enumeration type.
    3. IDE support just isn’t there, and that’s understandable if as an IDE you have to “search the universe” for implicit references upon every key down event.
    2. Flexibility in syntactic style seems to be a major point of contention for developers on the same team.
    1. The compilation times kill it for me above all else, incremental compilation is effectively broken. If I change two characters in a string and hit recompile I may as well go for lunch. That should never happen, ever. If incremental compile actually worked properly in Scala I think we could achieve world peace.

    1. Fear-motivate reactionary ranting… funny how times and judgments change. When I propagated Scala in my team, a was always dismissed as being too progressive :).

      BTW, what you consider “fear-motivated” doesn’t necessarily my own thoughts. Let alone my wishes. I tried to understand why so few teams adopt Scala. If my theories are right, they may be motivated by fear indeed. Of course, it’s also plausible that your seven points are the root cause of Scala’s demise. Be that as it may, thanks for your valuable insight!

Leave a Reply

Your email address will not be published.