Moving from Java to Kotlin

  • Ali Meshkat
  • 14-06-2022
  • 6 min

Kotlin is a modern, pragmatic language loved by many engineers within Rabobank. Even though the community is quite young and still growing, the adoption rate is steady. To grow faster and increase Kotlin adoption, Rabobank Kotlin Community has developed a training program that not only will help engineers to become experts in Kotlin, but also allow them to become Kotlin Champions: experts who help accelerate Kotlin adoption within Rabobank by providing Kotlin presentations and training sessions. Do you want to join?

Kotlin versus Java

To understand what Kotlin is and why moving from Java to Kotlin makes sense, let’s make a comparison between the two. Then we’ll explore the practical implication of integrating Kotlin into a Java world. And finally, we’ll look at the challenges of expanding the community around it.

What is Java?

Java is a general-purpose statically typed programming language that has been around for decades. Java programs, once built, can run everywhere a Java Virtual Machine (JVM) is installed. It has a big community of engineers all over the world. One of its key benefits is its great backward compatibility. Another benefit is its rich ecosystem. Many libraries, frameworks, and tools are developed around Java to help engineers to create software relatively quickly with less hassle. Many organizations in the world rely on it and are invested in it, such as Amazon, Microsoft, and Google. Rabobank has hundreds of Java engineers working on over 1000 projects (git repositories).

Why you should move from Java to Kotlin

Java is stable and has a rich ecosystem, so why move to Kotlin, right? I’m here to tell you why you should definitely consider using Kotlin. Like Java, Kotlin is a general-purpose statically typed language on the JVM. What makes Kotlin different is that, at heart, it is a pragmatic language. That means it was created with real-life use cases in mind, such as being interoperable with existing Java code and infrastructure. And the language will evolve to stay relevant and modern, by not only adding new features, but also retiring ones that are outdated. Kotlin offers what they call Comfortable Updates. Breaking changes will be announced ahead of time, and things that will disappear from the language will be marked deprecated. Tools are provided to migrate automatically. All before the change happens. [1]

Java was originally designed in the 90s for interactive television. Java has grown since then and accumulated a lot of legacies. Due to the nature of always wanting to be backward compatible, the language is evolving quite slowly. Even with the new rapid release cycle, other languages like Kotlin are still ahead of it. When designing Kotlin, the creators did not try to reinvent the wheel. Instead, they had a careful look at other languages such as Java, Scala, C#, etc. But rather than just recycling things from other languages, they improved upon them.

For example, some well-known Java issues have been fixed in Kotlin, like the Null Pointer Exception (NPE). Kotlin was created to be a language that combines Object-Oriented and Functional programming, focused on interoperability, safety, clarity, and tooling support. [2] [3]

Thanks to some syntactical sugar, you can create Domain-Specific Languages (DSL) to express your domain model. Its type-system comes with nullability support (no more NPE!) and type inference. And it is more than just a JVM language: Kotlin code compiles to run without JVM in a browser or on bare metal.

Using a programming language that has features that enable you to write simpler code and catch bugs early on will help you become more productive (and happier). With that in mind, I think Kotlin is a better fit for the challenges we, as engineers, are facing nowadays at Rabobank. As a software engineer, you want to focus on delivering software, not reasoning with the clumsiness of a language or tool.

Moving to Kotlin is easy

Although Rabobank seems quite orientated towards Java, moving to Kotlin is relatively easy.

Rabobank has an advanced infrastructure and tooling support for Java (JVM) applications. Teams can use off-the-shelf libraries for creating their own CI/CD pipelines. Rabobank offers tools for checking security and performance vulnerabilities in the Java code to catch programmer’s mistakes early on. All these tools and libraries are also used for Kotlin.

It wasn’t hard to integrate it with Rabobank standard tooling and libraries. We had to expand the security & quality tooling ruleset with added rules, and create security and development guidelines to advise engineers on the proper use of Kotlin, as Kotlin works wherever Java works because of its design.

Growing a Kotlin Community is hard

Last year, a Kotlin community was set up to unite Kotlin engineers scattered all over the bank. Several developers decided to take the lead and form a group to tackle questions about topics such as security and performance, training facilities, recruitment, and other requirements.

At the end of last year, the Kotlin community merged with the Java community. From that point on, Rabobank ‘pledged’ to support Kotlin and Java equally. More engineers can easily find each other and connect to offer support if needed.

This year, the community is steering towards increasing the adoption of Kotlin. To measure the adoption rate, we took the percentage of Kotlin among the total Java projects, and the baseline was 10 percent. By the end of this year, we would like it to grow to 15 percent. To achieve that, we need a bigger, more mature, and more diverse community. We need to reach out to engineers from different corners of the Rabobank and get them involved.

To create awareness and share knowledge about Kotlin, we regularly organize internal meetups. To get feedback from the community we send out surveys and have conversations with engineers and department leads.

Based on surveys and the talks we had with engineers, we found out that the majority of those interested in using Kotlin are new to it. There are some more experienced engineers, but few experts. The pitfall of starting out using Kotlin as a Java engineer is that they don’t know all the best ways to use it. It’s important to learn how to write idiomatic Kotlin from the start from a more experienced Kotlin engineer. This can help prevent the increase in technical debt and the spreading of bad practices throughout the team.

From beginner to expert

To grow the community, we need more experts that can offer support to less-experienced engineers. So we want to offer a training program that can help beginner and intermediate Kotlin engineers become experts. And if they’re up to it, help them make an impact within their own department and become one of the core members of the Kotlin Community and contribute.

We have designed a new training program around the idea of training engineers who can train other engineers. It’s called the “Kotlin Mastery Program”, and will allow engineers from different entry levels to become excellent in Kotlin and even become Kotlin Ambassadors and Champions.

A graph explaining the kotlin mastery program, with foundation, intermediate and advanced trainings
Kotlin Mastery Program Overview.

Depending on the ambition of the engineers, the Kotlin community will facilitate whatever is needed. For example, we can work together on providing training sessions, hackathons, and other events that promote Kotlin. The Kotlin Mastery program is on its way. Over 100 engineers have already followed the basic training, and about 30 engineers have followed the intermediate and advanced training.

Conclusion

Kotlin comes with extensive utilities and key features that allow you to create safe, expressive and concise code. Because most engineers within Rabobank are just starting out using Kotlin, it’s imperative to have more experts around to guide them. That way, moving to Kotlin will become more effective with less technical debt and developers can fully unlock the potential of Kotlin. The Kotlin Mastery Program is there to train such experts by offering a tailor-made program based on the needs of Rabobank engineers.

Only once the Kotlin Community has enough champions and ambassadors can we sit back and relax and let the community take over. But for now, we keep moving, experimenting, learning and offering our services to the community.

Want to join the Kotlin Movement @ Rabobank?

Check out our Kotlin vacancies!

Resources

About the author

Ali Meshkat
Software engineer & Kotlin trainer

Ali is a self-taught software engineer. He likes to share knowledge and helps others to do the same. He has founded Ignite Community, a knowledge sharing platform for developers by developers, within his tribe, Digital Platform. He is an avid Kotlin user and provides Kotlin workshops to engineers who want to get started with Kotlin. He believes that continuous learning (on the job) can improve engineers’ job satisfaction, hone their skills, and help organizations to grow.

Related articles

Setting up a Kotlin community

  • Wouter Nederhof
  • 16 September 2021
  • 5 min.

VIDEO: Why you should use Kotlin

  • Wouter Nederhof
  • 21 September 2021
  • 30 min.