HACKER Q&A
📣 rajeshp1986

Scala vs. Kotlin?


I am an experience Java programmer. I am interested in learning picking a new programming language in my spare time. I am interested in static-typed languages. Which one should I pick next? If you have any other interesting suggestions/alternatives then please recommend those as well.


  👤 burntoutfire Accepted Answer ✓
I've been using Scala for a number of years. Frankly, I'm very wary of recommending it to anyone. The job market seems to not be growing (if not shrinking, as Spark-based projects are largely moving to Python now) and the community is focused on complex and esoteric ideas for solving mundane problems ("purity" over practicality). You're likely to work with people like that on your next Scala job. It's great if you dig it, but sucks if you just want a boring language that allows for getting things done.

👤 ttymck
Chiming in because the two extant comments are dismissive of Scala.

I use Scala every day, our current application is written 100% in Scala. We write functional code, but we are not religious about "purely functional" code.

My understanding is that, currently, writing Kotlin means you are almost certainly writing Android apps. If a company chose Kotlin over Scala for a backend/distributed application, I would be astonished. Maybe that is my bias, but Scala is proven and continuing to grow in the distributed space (Akka, ZIO, etc).

Regarding scala being "too cryptic". I felt the same way about Django when I first learned it -- now everyone thinks Django is a breeze. I had the luxury of learning Scala on-the-job, and had great mentors who saw the power of the language and helped me realize it too. Scala can be "fancy", but it can also be simple and elegant, if you learn it slowly.

Frankly, I think my biggest issue with Scala is that I live in North America, and the really interesting products built in Scala seem to be made by European teams.


👤 Sunscratch
7 month ago received an offer to join Scala project. Before that worked with Java and Go. I would say Scala is an amazing not just language, but an ecosystem. As a language, it’s very ergonomic and allows to do complex things with less boilerplate. So if you really interested in programming, learning new concepts - I would recommend to try it. If you want just to do boring stuff for money - Java and Golang. Regarding Kotlin - it doesn’t intersect with Scala, because mostly used for Android and back-end with Spring or other Java frameworks. Scala is mostly used for distributed systems, big data and applications with complex domain.

👤 AlexITC
First I would ask, what's your motivation?

- If you are just looking for a better Java, Kotlin is likely the way.

- If you are looking for a better language that leverages the JVM ecosystem, then, Scala might be the way.

It also depends about what kinds of projects do you want to work with, Scala is a no-go for Android if you are just learning, on the other hand, if you plan to work in distributed systems, Scala is great for that.

The biggest advantage I see on Kotlin right now is the Multiplatform side, we are taking advantage from it to write a library once, that can be consumed by Android, iOS, and our backend services built with Scala (we even want it for the JavaScript side but it isn't as mature as Scala.js).

On the Scala side, it has a very nice ecosystem, with powerful tools that usually get ported to other languages, for example, its the first language where I see good tools for:

- Compile time checked SQL queries.

- Documentation tools that actually compile your code examples to make sure it is correct (even arrow-ank on Kotlin was inspired by tut from Scala).

- Generating JavaScript code that actually works.

While Scala may have had not-so-good tooling years ago, right now is pretty good.

People usually complain about over-complex code, which can be true, but, you can find bad code in any language, on Scala you can choose a path, whether to be pure-FP or pure when practical, and there is great tooling for any side, I personally try to be practical and it has worked quite well over many years (also check http://www.lihaoyi.com/ blog for similar examples).

What I get in Scala that I can't get in other languages I have worked with is usually the confidence that my code works when it compiles.

As of know, I use Scala for backend services, frontend (through scala.js), browser extensions, mobile apps by leveraging PWAs, and even native apps (through GraalVM).

On the job market, every year I see more companies using Scala, and you usually find very competent people which allows you to keep learning, on the Kotlin side, most job posts that I see are for Android than for backend development.


👤 pestatije
I tried Scala and gave up: it's too cryptic, it gives too many opportunities to do "clever" hacks and leave you scratching your head trying to find out what the code is supposed to do.

👤 speedgoose
Scala is complex and interesting but perhaps more research than industry. If your goal is to learn fancy programming languages, I would go with Scala. If your goal is to do side projects not in Java but still using the JVM without thinking too much about the programming language, I would pick Kotlin.

I recently enjoyed learning Rust, but it's more low level which you may enjoy or not.


👤 treis
I don't think it's worth going from Java to Kotlin unless you have a real pressing reason. JVM languages have come and gone. None of them present enough of an improvement to leave the metric crapload of legacy Java code behind.

IMHO, for static typed lanaguages the most practical are Go or Typescript (if you wanna count that).