DEV Community

Scala, Kotlin, or Grovvy? Which Programming language Java Developers Should Learn?

javinpaul on July 22, 2019

Disclosure: This post includes affiliate links; I may receive compensation if you purchase products or services from the different links provided i...
Collapse
 
jillesvangurp profile image
Jilles van Gurp

For new programmers, I'd focus on Kotlin and then maybe Scala and ignore Groovy. The reason is that Kotlin is gaining a lot of momentum in the backend world where Scala has maybe ran out of steam a little. E.g. the Spring project recommends it, and it is also the language of choice for Android. A couple of things that make this language stand out: 1) co-routines and Flow are a nice step forward for asynchronous and reactive programming. 2) kotlin native and kotlin-js mean that Kotlin is becoming a full stack language that you could use outside the JVM.

Scala is very different from Java/Kotlin/Groovy in the sense that it seems more focused on functional programming. It depends on your domain. If you are doing a lot of data processing with e.g. Spark, Scala may be the better fit. You might want to look at Clojure for the same reasons. It's worth noting that people in the Scala community seem worried about core committers jumping on the Kotlin bandwagon: reddit.com/r/scala/comments/8xreuv...

At this point, Kotlin is a natural successor to Groovy that removes most of the need for both Groovy and Java. It has most of the nice language features but without the complexity of being a dynamic scripting language. I know quite a few people that are switching from Groovy to Kotlin at this point. I see very little reason for anyone to pick Groovy for a project.

Collapse
 
javinpaul profile image
javinpaul

Great comment and advice but I think for a new programmer it's to start with Java or Python. I have also blogged about it java67.com/2018/07/is-java-best-pr...

Collapse
 
jillesvangurp profile image
Jilles van Gurp

I'd argue most Java programmers need to consider if they want to stick to Java when Kotlin is pretty much a drop in replacement that people are literally dropping in Java projects to replace it. I've done a few of those and the language is designed from the ground up to facilitate that and be better than Java at literally everything it does. It's a better Java in every way that counts.

Thread Thread
 
javinpaul profile image
javinpaul

It depends, learning Kotlin is definitely a good option but you won't always get a chance to replace existing Java project with kotlin, not at least on big Investment banks and Insurance firms where most of the Java run nowadays. I would stick to Java and just add Kotlin in my arsenal rather than making it my primary skill, but again that's my thought.

Thread Thread
 
lemuelogbunude profile image
Lemuel Ogbunude

My thought as well...

Thread Thread
 
jillesvangurp profile image
Jilles van Gurp

Sure, those kind of environments are a bit slower to adjust. Unless you want to work in such an environment, you might want to look at what they will be doing in five years; which I'm betting will be mostly Kotlin because it is a drop in replacement on all of their Java stuff now already.

Short term having a Java background will help you understand Kotlin. But I have a suspicion that the JVM as a runtime will become less important as the native compiler and cross platform libraries mature.

Thread Thread
 
lemuelogbunude profile image
Lemuel Ogbunude

Sure Kotlin is cool but as Paul has stated, a lot of Java developers would just add it as part of their Arsenal. I have spoken to other Java developer, especially those who had already experienced the "shiny" Kotlin features on other languages such as Scala and the rest, they are not necessarily as excited about Kotlin as Android developers.

Kotlin's major market is Android and the issue with Android isn't Java, but that the developers are stuck with Java 7-ish features.

The companies using Java should focus on trying to use the latest Java features, it's very likely those companies are using Java 8 or even Java 7. They could upgrade to the LTS JDK 11 and use the latest features instead of migrating to a new language. I feel it's not a necessary action.

In the next five years, Java would still be kicking and kicking even harder, it's great to have additional Languages like Kotlin and Scala in the JVM, these languages have the luxury to try out features and see if it works, Java learns from their experiments, Java does not have that luxury because of the number of systems depending on it, the stewards of Java have to make sure a feature is needed before adding it... and a lot of very cool features are on their way.

I see the JVM languages as an awesome team rather than competitors.

Thread Thread
 
jillesvangurp profile image
Jilles van Gurp

You are wrong on that it is an Android only thing. I use it on the backend. Lots of Java backend frameworks are moving towards either supporting/recommending Kotlin or even porting to it. E.g. okhttp just released a fully backwards compatible v4 that has been completely ported from Java to Kotlin. Spring is recommending Kotlin over Java and optimizing their frameworks for Kotlin. Spring probably represents about half of the industry; particularly enterprise/fintech setups.

If you are planning to do work involving Spring 5.2 and up, you should be planning to move to Kotlin as they are adding co-routine support in Spring 5.2 and it makes the flux/reactive mess they released a while back a lot more user friendly. IMHO any new Spring Kotlin project will be much more likely to use Kotlin than Java very soon. Any new project that isn't is doing it wrong.

Collapse
 
charliemason profile image
Charlie Mason

I have tried all 3 languages over the last 3 years. I settled on Kotlin in the end to port a key product codebase at work too. For such a new language the tooling is incredibly mature, if you use IntelliJ. It took Scala nearly a decade to get the same level of integration. It's turned out be a great choice. Productivity is definitely up since the switch away from Java.

Groovy is nice, but it feels like an evolution of Java rather than something really new.

Scala is full of neat ideas, but it's also overly complex. There's often several ways to achieve the same thing. So no two devs implement something the same way. It seems to attract the sort of developers that reval in complexity purely for complexities sake. Even the compile times are noticeibly longer.

Kotlin has clearly stolen a lot of Scala's best bits. But it's skipped a lot of the complexixty. Plus it's integration with Java is much tighter than Scala. Our app ships over 150 jars with it. The majority are java libs. Using Kotlin instead of Java has never been an issue with any of them.

I would definitely say look at Kotlin for backend work. It's far more than just what people write Android Apps in these days!

Collapse
 
voidjuneau profile image
Juneau Lim

"Scala is full of neat ideas, but it's also overly complex.": It makes me both excited and worried.
Hope the language would be refined a bit before I starting to get my feet wet.

Collapse
 
javinpaul profile image
javinpaul

I won't say complex but yes, the initial learning curve is a bit high.

Thread Thread
 
voidjuneau profile image
Juneau Lim

OK, Thanks for the warning. Good to be aware. Let me see what I can do.

Thread Thread
 
javinpaul profile image
javinpaul

haha ha, don't worry, I didn't intend to scare you. Scala is a great language to master but yes you need initial zeal or at least a project. I learned while I had to work on a Scala project and I learned in just less than 4 weeks but yes I haven't mastered it yet.

Thread Thread
 
voidjuneau profile image
Juneau Lim

Sure thing. haven't scared. Just good to know ahead, and I HAVE to learn it no matter what anyway. Thanks for kind words!

Collapse
 
javinpaul profile image
javinpaul

I agree with you Kotlin has great tooling in terms of IntelliJIDEA and having JetBrains invented Kotlin only helped it on that front while Scala had to go through the hard way.

Collapse
 
robotsquidward profile image
A.J. Kueterman

Awesome article! I'm an Android developer that has fully shifted from Java to Kotlin for Android development and I love it! I also do a lot of automation/build stuff in Groovy because Gradle. If I was a Java dev moving to Android I would first try to understand basic Gradle syntax in Groovy then quickly move to Kotlin.

Collapse
 
fultonbrowne profile image
Fulton Browne

I am learning kotlin (also an android developer) any tips?

Collapse
 
robotsquidward profile image
A.J. Kueterman

I was lucky that I started learning Kotlin with a few other developers while we all worked on one large legacy codebase. That gave me the advantage of learning from not only my mistakes, but the mistakes of my peers as we learned how to capitalize on Kotlin.

There are tons of resources for learning Kotlin as a beginner that a quick google will reveal, so I'll stick to some high level stuff that helped me.

Build off what you know. For me, this meant building things on Android because I leaned on my knowledge of the Android APIs to put Kotlin in context. For example, I used to use Interfaces to create callbacks from my RecyclerView adapters back to my Fragments. In Kotlin, I can just pass a lambda argument into my adapter instead. Then it's just applying the syntax and profiting from a big reduction in boiler plate. (I know lambda's aren't Kotlin exclusive, just an example I experienced moving from Java 7).

I would also try to avoid using the Android Studio tool for Kotlin conversion. It does very little to help you understand how Kotlin works or even how you'd normally apply it. However, manual conversions did help me, especially when I challenged myself to use Kotlin language features and eliminate as much Java boiler plate as possible.

Finally, just explore the power of the tools in your code. Moving from Java to Kotlin introduces the concept of null-safety in a really full-featured way. This was novel at first, but when you start using tools like let, run and when to their full potential in concert with nullable types, you unlock some extremely cool stuff. It makes it hard to go back!

Thanks for asking, and good luck!

Thread Thread
 
fultonbrowne profile image
Fulton Browne

Thanks!

Collapse
 
voidjuneau profile image
Juneau Lim • Edited

Tasted a very little bit of Kotlin and Groovy when learning Android dev.
Kotlin seems like a really fascinating language. imo, my impression was that the Kotlin is made by somebody who loves UML. Was very interesting, but Mobile dev. was really not my thing, so stopped there.

Have been willing to learn Scala for Big data. Have been on my to-do list for months.
Love the functional programming futures of other languages, so excited to try it out more.
Thank you for the amazing article with rich resources, as always!

Collapse
 
javinpaul profile image
javinpaul

Yes, one of the reasons a couple of my friend learned Scala is for Big Data and Spark, but you are right, it's the right mix of OOP and functional programming which is Scala's USP.

Collapse
 
voidjuneau profile image
Juneau Lim

Your posts always make me ambivalent.
Those justify my to-do list, and make me nervous that I can't try them out right away. 😳

Thread Thread
 
javinpaul profile image
javinpaul

To be honest, you are not alone. Actually, I have been learning so many technologies now that I have to push many things to next year but yes it always depends how deep you want to go. I follow jack of all and master of one principle :-) and Java is my master :-)

Collapse
 
jelmer1980 profile image
jelmer

What a shameless cash grab.. this article is literally full of affiliate links