Every so often I’ll crawl out of my Java cave and run into a seasoned dev who has embraced Scala. And I have noticed that not one of them seems to want to go back to Java programming.
Having moved to Java 8 and embraced Optional and streams, I can see the appeal of thinking functionally. Whenever I see a nested for loop iterating over a collection or a bunch of null checks on a class hierarchy, I shudder little. Not only because the code is so ugly, but because for the longest time I didn’t know any better myself.
All of which makes me think that I should start investing some serious time in a real functional language like Scala. What exactly do I have to lose?
Pro: Scala is one of the few functional languages that you can get paid to write in.
Doing a quick job search for Scala shows that it is gaining commercial adoption. Searches for Clojure and OCaml return nothing on the job front in my local city, while Erlang, Kotlin and Haskell return only one job each (and even then usually as a “bonus” skill). Scala is at least being requested as a primary skill.
Pro: You know a company takes development seriously when it is writing code in Scala.
I have yet to see an inspirational job ad that targets Java developers. Reading these job descriptions you can almost smell the dank basement you’ll be working in as you grind out code to generate yet another report or whip up a CRUD web application.
Seeing Scala as a desirable skill at least shows that someone has taken the time to think beyond the default choice of Java, which is a pretty good indication that they take the practice of software development seriously.
Pro: You will be a better developer, even if you have to write in plain old Java
Why isn’t this variable final? Am I really just doing a reduce or a map with this for loop? Should I return a new object instead of modifying the existing one? Is this an optional return value? These are all questions that I find I ask myself when writing Java because of my limited exposure to functional programming. And asking these questions has made me write better code.
While coding in Scala may not be an option, exposure to Scala can only improve my code, even if it is Java code.
Con: Scala is just one skill from an infinite selection that I could be learning.
Ask an experienced Java and Scala developer to solve a problem, and you’ll probably get two different solutions. But you will get solutions, because neither Scala nor Java provide a fundamentally unique way to get a computer to do what computers do.
But when was the last time you had a development job where your responsibilities ended when your code compiled?
Con: Scala might just be the icebreaker for languages like Kotlin.
Kotlin has yet to take off (it isn’t even mentioned in the TIOBE Index top 50 as of May 2016), but I’m actually willing to bet that Kotlin ends up being the JVM functional programming language of choice over the next few years.
It’s created by JetBrains, so you know it is going to have kick ass tooling. Kotlin comes from industry, not academia. And by this time next year I predict that job searches for Kotlin will rival those for Scala.
Con: Maybe functional Java is good enough?
Writing functional Java gives you code that the other gazillion Java developers in the world would be familiar enough to read and understand, you forgo the headaches of moving existing developers and organizations to a new language, and Java 8 gives you functional support right there in the language.
It may not be pure, and you won’t get Higher Kinded Types bragging rights. But maybe you get the 20% of functional coding features with 80% of the benefits?
No such thing as easy answers
I find myself torn between the obvious benefits that a deep understanding of Scala would give over the practical realities presented by competing languages and a broader knowledge of the IT ecosystem. What choice would you make?