Building a bank? Here’s why you should use Kotlin
Backend development for greenfield banking requires a special set of needs. We use Kotlin as our programming language. Here’s why.
Our ideal programming language
Saves our engineers’ time
As a greenfield bank, there are lots of fundamental product or technical-based decisions which can change on a daily basis. Engineers used to spend time on a particular problem only for the direction to suddenly change.
Therefore, we need a programming language in which most low-value problems are already solved, so decision changes are less costly. For example, we don’t want to invest in creating our own circuit breaker framework for remote calls. We want to use an existing library already proven in the production environment, so we can focus on high-value problems like customer experience.
Lots of startup banks are attempting similar things. Approaches may differ, but ultimately it is a race to reach the market. Therefore, we need a programming language that accelerates us.
Lets us focus on hiring talent
Ideas are great, but execution is everything. We need talent, and lots of it to achieve our desired outcome.
ultimately it is a race to reach the market.
Java was the king of backend development in banking for years
Java is one of the most popular high-level programming languages in the banking world. Almost all banks have a part of their system developed in Java. In the past, it was used on many platforms, but now is mainly used for backend development.
It has many plus points, including:
Portability and platform-neutrality
Java Virtual Machine (JVM) gives banks the freedom to choose processors independent from programming languages
JVM manages memory allocation and garbage collection
Security problems are centrally and continuously solved by JVM providers
Java syntax is intuitive
Hiring Java engineers is easy
Teaching Java is easy due to volume of online materials
If Java is that good, why use Kotlin?
Kotlin is a high-level JVM language 100% interoperable with Java, because Kotlin source is also compiled to bytecode to be run on JVM. So you get all the benefits of the JVM language.
Kotlin was invented by JetBrains in 2010. JetBrains is also the creator of IntelliJ IDEA, a famous Java Integration Development Environment (IDE) tool. Their engineers needed a simpler tool to develop the IntelliJ - and so, Kotlin was born.
What are we trying to achieve by moving to Kotlin?
More possibility, less complexity
For all its merits, Java is overcomplicated and too boilerplate. That means we’re keeping and maintaining low-value code in our repository. Kotlin was designed to be concise and clear. For example:
it would only take about two hours for a professional Java developer to start writing commercial code in Kotlin.
A collection of overloading methods in Java can be expressed in Kotlin in one function. Concise source code means:
We can do more with less typing and less time
We can focus on solving the problem rather than ensuring correct syntax
Less room for error
Easier to maintain
No more nulls
Since Java does not guarantee any non-primitive to be non-null, null checks have been a frequent practice by Java developers. It’s necessary to code defensively because NullPointerException is unpopular.
The null checks made every Java developer branch out the logic flow whenever a non-primitive variable can be null. The combination of possibilities is at worst 2n.
This complexity is solved by Kotlin by ensuring null safety at compile time. Basically, each value is by default non-null, and setting a null to a non-null value will not compile. The outcome is that we are free from the stress of handling all possible null value cases. Another time saver in the geometric scale.
Whenever we use a third-party library in Java, we often face the challenge of no options to extend the functionality of foreign classes. That leaves us making a lot of separate methods and wrapping foreign classes to make it look homogeneous.
With Kotlin’s extension functions, we are able to enhance any third-party library, without the penalty of wrappers.
Functions as first class citizens
While there was no choice in Java, Kotlin allows you to simply declare a function without any boilerplate. No class is needed, just a function on its own.
What is the cost of moving to Kotlin?
Kotlin has a similar structure to Java, and thanks to the 100% interoperability, it would only take about two hours for a professional Java developer to start writing commercial code in Kotlin.
Kotlin is now the second-most popular JVM language after Java, according to the JVM Ecosystem Report 2021 by SNYK.
When migrating Java projects to Kotlin, we only need to add Kotlin dependencies to the projects, and then you can start writing new code in Kotlin. Every time you need to update a Java class, convert it to Kotlin. IntelliJ can even convert 90% of the syntax for you!
You don’t even need to worry about updating your project dependencies - you can still use all your favourite Java frameworks. Meanwhile, the Kotlin equivalent frameworks are designed to be even more concise.
Don’t just take our word for it - N26 are big advocates of Kotlin too!
A greenfield bank requires a programming language that gives us time to focus on solving high-value problems, moving faster and hiring talented people.
Java is a high-level programming language that comes with powerful tools and support. Most cross-cutting concerns are addressed by the vast collection of frameworks and the large internet community.
Kotlin is 100% interoperable with Java with the same benefits. Furthermore, it is simpler, more concise and easy to transition to. For these reasons, Kotlin is our programming language of choice.