The Scala folks seem to think creating a new language that is halfway between Java and Scala isn’t a great idea.
Well, of course they are. They’ve invested a lot of time into Scala; if Kotlin takes off, their situation arguably becomes worse.
Here’s the thing, though: I actually think that Kotlin really hits a sweet spot for many teams. Scala really is its own thing, in a lot of ways. Yes, it compiles to JVM bytecode, and yes, you can work with Java libraries, but code you write in Scala still feels (at least in my experience) a bit cut-off from the Java side of things. Calling Scala from Java is a bit involved, Scala almost always uses its own build system (sbt), Scala has tons of syntax and concepts that are absent from Java, etc. This means it’s relatively expensive for Java teams to adopt: there’s a real need to train everyone before they can sanely use the language, and even more if you really want them to properly leverage everything Scala has to offer.
Kotlin, by contrast, is really just trying to be to Java what Swift is to Objective-C: a slightly better Java that fixes a lot of the major problems of the language, but doesn’t try anything radically new. I understand why that’s frustrating if you’re into Scala, but for Java shops, it’s brilliant: Java/Kotlin interop is really easy in both directions, Kotlin reuses the same build infrastructure as Java, and so on; Kotlin just brings a few key things to the table (null safety by default, immutability by default, a better streams library, and better immutability), and otherwise leaves things be. This means that gradually adopting Kotlin is a reasonable idea, and that the time required to train a team is dramatically lower.
For example, on my team, I was able to spool everyone up on Kotlin in really just a day, and we had Kotlin code running in production barely a week later. Based on teams at my company who’ve tried Scala in the past, this is concrete evidence that Kotlin is much easier to introduce into a legacy code base.
I understand why a Scala user would find all of this really frustrating. They’re looking at a language that, from their standpoint, is demonstrably “worse” because it does a lot less than Scala. But I genuinely believe that this “weakness” can be a strong benefit, and I think that writing off Kotlin because it’s between Scala and Java is not only a mistake, but erroneously looks at its biggest strength as a weakness.
I think some of the annoyance comes from the feeling that it is trying to sell a compromise which isn’t very useful.
It’s like Java claims “vaccination causes autism” and Scala says “no, there is scientific evidence that vaccination doesn’t cause autism” … then Kotlin comes in and suggests “hey, can’t we compromise? let’s just say vaccination causes some autism”!
In my opinion, the whole a-slightly-better-Java-is-all-we-need movement lives in some kind of a filter bubble–it only appeals to Java developers; everyone else will just assume those people are crazy and move on.
So we have a language which lives somewhere between Java 8 and C# 3 in terms of expressiveness. Given that the .NET team decided that they basically want to include everything Scala does for C# 7, I’m skeptic that their bet works out in the long-term: They have a very limited appeal, they haven’t managed to release a stable version, the language is still very volatile, they added an considerable amount of cruft to the language in the latest milestone, the compiler is quite unstable, the ecosystem is very small, there is nothing that you couldn’t write in Java and they lack any kind of “killer library”.
I apologize if I sounded too negative, but I think they will have a lot of trouble convincing people that the “slightly better Java” is called “Kotlin”, and not “Java 9”.
I want to ignore .NET, since we’re narrowly focused on JVM languages right now, and the JVM, for better or for worse, simply imposes a different set of trade-offs than the CLR. (Although having an F# v. Scala v. Haskell discussion would be really fun if you ditch that requirement.)
You went with a pretty intense claim with the vaccination thing. Can you give an example or two of what you have in mind there? I’m guessing you have several concrete language features where there’s something that Java and Kotlin make a horrible/ever-so-slightly-less-than-horrble decision on, and Scala avoids. Or some cruft you think they added in recent milestones? Or an example of where the compiler’s really unstable? Any of that might enable us to have a bit more of a concrete discussion here; at the moment, I’ve just got metaphors.
From my end, we’ve been having great luck using Kotlin in production to make money, and with very minimal track-the-language churn compared to my old Scala project. When we moved from Scala 2.8 to 2.10 (IIRC; might’ve been 2.9), we had a bunch of Scala library API changes, plus we had to rebuild all our JARs due to the lack of binary backcompat, plus there was some language syntax change that bit us. Conversely, the Kotlin upgrader has cleanly handled companion objects and lambda alterations for us, which are the only two breaks that have happened since we began using it in February. We’ve had no binary backcompat issues that I’m aware of, and internally publish a Kotlin library designed to be consumed from Java. Thus, the backcompat story, in my personal experience, has been better so far.
I was very busy recently, please let me know if you are still interested in an answer.
I’d still love one, if you don’t mind. My team’s not going to migrate off Kotlin for our existing projects, but I’d still like more information so I can take a second look at Scala moving forward if that makes more sense.
The compromise is stupidly useful for Android devs actually. We need tooling integration to be able to write code effectively because of the nature of mobile programming. Kotlin provides that officially; JetBrains makes the only up-to-date Android IDE and also makes Kotlin. It’s a huge leap forward. Maybe you’ve changed your mind in the huge amount of time between when you wrote this comment and now, but if not, their appeal is certainly working. Kotlin is Android’s Swift. We’re writing all our new code in it despite it still being in beta for the past few months.
Scala is neither useful nor desired for a majority of programming applications. It brings considerable code maintenance overhead to developers with non-functional backgrounds (most of them). In that respect, is not better than Java, it is only more powerful. Be careful when conflating the two.
EDIT: I’m also pretty curious as to how I stumbled upon this thread. I just had it open on my browser with no recollection of getting here.
kotlin has managed to pull off practically zero overhead (cpmpared to java) android binaries. afaik scala cannot yet compete in that.
Last time I checked, the overhead was around 100kb (for a simple “Hello World”). I think every random third-party library is larger than that.
Kotlin doesn’t have “practically zero overhead” either, but considering that no one uses the language, there are just less people fact-checking the claims of Kotlin devs.