DEV Community

javinpaul
javinpaul

Posted on • Edited on

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

Disclosure: This post includes affiliate links; I may receive compensation if you purchase products or services from the different links provided in this article.


If you are a Java programmer and are thinking of learning a new programming language to expand your knowledge and skills, but not sure which programming languages to choose, then you have come to the right place.

In this article, I am going to share 3 JVM languages Java programmers can learn and why you should learn them. You don't need to learn all of them, ideally, you choose the one which is most suitable for you. For example, I like Groovy a lot and that's what I learned because it was used heavily in our build tool and automation testing.

Also, being a Polyglot developer is of good quality and often valued highly in interviews. It also expands your thinking because different programming languages have different features that make certain things really easy.

Learning a new programming language also gives you the experience and knowledge to compare the pros and cons of two programming languages, which essentially enables you to write better code.

All of the programming languages I am going to suggest Java developers today are JVM-based because they are easier to learn for Java programmers.

They are related to Java in one way or another, and that's why they help expand the mind of any Java developer. I have also included relevant books and online courses which you can use to learn any of these languages and if you buy from my links, I also get paid.

Scala, Kotlin and Groovy - 3 JVM Languages Java Programmers can Learn

Here is my list of three programming languages Java developers should learn. Why I have included only 3 languages, why not 10 or 5?

Well, learning a new language is not that easy --- it takes time and effort to learn a new programming language, and even if you can learn just one, that would be more than enough.

1. Scala

Scala has been around for quite some time now, and when it first came out, it was touted as the best language to replace Java. Well, that didn't happen, especially after some functional programming features were introduced in Java 8, e.g. lambdas and stream, but Scala is still the language to learn for Java developers.

Scala has grown in the past couple of years, and more companies and startups have started using it, like Uber, Sony, Amazon, Autodesk, etc, which makes it one of the most sought-after skills.

Popular Scala frameworks like Play, Akka, and Spark are also helping companies adopt Scala for web development and Big Data solutions. It's no surprise that Scala developers are paid more than 120K USD on average.

If you are looking for some exciting work and to learn a functional programming language, then Scala should be your first choice.

And if you decide to learn Scala, then the Rock the JVM! Scala and Functional Programming for Beginners course on Udemy is perfect, to begin with.

If you need more choices, you can also see this list of best Scala courses on Medium and If you like books, then Scala for the Impatient from Cay S. Horstman is my recommended book. I like his teaching and writing style and have read many of his books, like Java SE 9 for the Impatient, Core Java 1 and 2, etc. Like the others, this book also covers key concepts of Scala and helps you quickly get going.

2. Kotlin

Kotlin was introduced in 2011 by JetBrains (maker of IntelliJ IDEA, PyCharm, and many other top IDEs) but not many programmers paid attention until Google announced it as the official language for Android Development in 2017 Google IO.

Like Groovy and Scala, Kotlin also runs on the JVM and compiles down to Java bytecode; you can start tinkering with Kotlin in an existing Java or Android project, and everything will work just fine.

So, if you are interested in learning Android development, want to make your app safe from NullPointerException, want to give your function some purity, write some higher-order functions, or some functional programming, then you should learn Kotlin.

To start with, Kotlin for Java Developers is a decent course. It covers essential concepts with simple language and provides real-world examples to help you understand them.

If you need more courses then you can also see this list of best Kolint courses on Medium and If you like books, then Kotilin in Action is something you can read. It's both easy to read and comprehensive enough to cover essential details, and if you need more choices, you can also check out this list of best Kotlin Courses for Java developers.

You will also find all the exercises and solutions for this book on Kotlin's official website, which also has an online editor to practice Kotlin programs.

3. Groovy

I explored the Groovy landscape a couple of years ago, and from that experience, I can say that every Java developer should learn Groovy.

It really complements Java with its concise syntax and powerful programming features, like collection literals, def to define anything, and multi-line strings.

After learning Groovy, I realized that what I can do in 50 lines of code. It seriously reduced the code required to do something when you compare it with Java, and the best part of Groovy is that it is Java.

One reason for me learning Groovy was the Spock framework, a descriptive and specification-based unit testing framework. It makes unit testing in Java much easier and also extends what JUnit offers.

If you decide to learn Groovy then The Complete Apache Groovy Developer Course on Udemy is a good place to start. This course explains essential Groovy features in simple language.

And if you still prefer books, then Making Java Groovy is the book I recommend. It helped me write Groovy scripts in just a few hours.

This was the book I read when I started with Groovy, followed by Groovy in Action, but if you need more choices, you can refer to this list of best Groovy books.

That's all about 3 programming languages Java developers can learn to become a Polyglot programmer. If you want to move to the functional programming side, then Scala is the best choice. If you are interested in developing mobile games and apps, then Kotlin will help you, and if you want to do scripting, then Groovy is a great language. It also helps a lot in unit testing and builds automation stuff. Since Groovy compiles to Java, it effectively complements the Java programming language.

Other Programming Articles you may like

Thanks for reading this article so far. If you like these programming languages and see the value of learning them then please share this article with your friends and colleagues. If you have any questions or feedback then please drop a note.

Top comments (24)

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