posts
Coding Languages for Fintech:
How Will JVM Make You Succeed?

Coding Languages for Fintech: How Will JVM Make You Succeed?

Jan 5, 2021
Md Kamaruzzaman
29.7

BellSoft is rounding up 2020 with top languages for Fintech enterprises. Whether you’re a startup launching your very first MVP, an up-and-coming business, or an established player in finance, trading, or retail in search of an innovative edge, this list is guaranteed to answer all your IT needs.

Here we’ll explain why you should choose JVM languages over platform-specific native ones, look into their key features and rankings. We’ll be paying special attention to how they are applied to use case scenarios, covering everything from finance to investment to banking to insurance. This list will help you understand the advantages and opportunities each one offers. You can follow our advice when selecting the programming toolkit best suited for your project.

Introduction

For this comparative study, we’ve collected data from various sources that rank languages by different parameters:

  • the TIOBE Programming Community Index,
  • PopularitY of Programming Language Index (PYPL),
  • JetBrains, Stack Overflow and GitHub developer surveys.

Our research only covers 2020 so that you get the most relevant industry profile — since being current is vital in Fintech!

But first, we’d like to explain our focus for this article. Many would say that Python is best for a financial technology company (such as modern hedge funds) thanks to its developer-friendly nature,adaptability, and opportunities for machine learning. While that may be true, it lacks certain quantitative benefits for high risk businesses in Fintech. Historically, it’s Java that has been widely used by banking and financial institutions that view data security, productivity, and stability as their priorities.

One of its important features for programming since the beginning in 1995 has been object-oriented nature and platform independence, which came with the Java Virtual Machine (JVM). The JVM abstracted away from the low-level physical hardware and operating systems. With this efficient way of executing programs, developers in Fintech, finance, and banking did not need to focus on object lifecycle management or other low-level complications. Instead, they were able to direct all their efforts to the business logic.

Over the years, JVM has improved significantly in terms of garbage collection, performance, and maturity. Programming language designers realized the potential of this runtime. And thus many prominent, mainstream, and even newer technologies have developed with the features and immense class library both provided by JVM. Every financial enterprise can now find a solution that would meet their needs.

There was slight uncertainty within the IT community regarding the JVM status when Oracle introduced the subscription-based licensing for JDK in July 2018. Fortunately, the JDK spec is still license-free and open source, thanks to the OpenJDK initiative. Several companies are now providing their own open source Java SE derivatives, including BellSoft. Its Liberica JDK is one of the leading runtimes on the market with optional enterprise support for Fintech and other industries. Support is recommended to make the most of your OpenJDK investment.

Now that we have the history covered, it’s time for our piece de resistance: a list of the best JVM languages for the financial technology sector: Java, Kotlin, Groovy, Scala, and Clojure. You will not find it too difficult to guess the first one…

1. Java

Java is the primary choice for business applications. It was the first to conceive and widely accept the “Write once, run anywhere” paradigm focusing on developer productivity and ergonomics. It paved the way for the success of others like Python, JS, and Kotlin. It has adopted many pragmatic concepts, algorithms, and operations like memory model, intermediate representation, multithreading and handling functions as first-class citizens. One of the most disruptive and influential programming technologies to date, Java has forever changed the industry.

Let’s look into why it is now almost as successful as it was 25 years ago:

  • It has holistic backward compatibility, which is a highly valued feature, especially in finance and banking. The programs written two decades ago still run in the latest JDK.
  • It is statically typed and supports multiple paradigms (object-oriented, functional, imperative).
  • Because of its massive adoption in the industry, whether it is commercial software, an Android app, big data application, or an IoT device, this technology possesses one of the richest and powerful ecosystems, having many libraries and frameworks in all domains (for instance, it may use SQL for complicated modeling to search for relations between stock prices).
  • It is the “lingua franca” in data-intensive applications and for most of the industry’s leading DIAs (e.g., Hadoop, HDFS, Solr, Lucene, Flink, Cassandra), as mentioned in my blog Towards Data Science.
  • Widely used in the Fintech sector, by tech giants and startups alike, Java is here to stay.

Stable and reliable

N26, a German neobank offering its services in the Single Euro Payments Area and the US, uses RxJava to build Android applications.1 It provides a standard workflow to manage all data and events across the application. That’s the reason behind its rising popularity among web developers. The engineering team achieved clean separation of concerns, which made the features easier to navigate in code.

Take a look at a short finance-related snippet from the app’s feature to display a list of the bank user credits drafts:

Flowable<Option<List<CreditDraft>>> getAllCreditDrafts() {

   return store.getAll();

}

Completable fetchCreditDrafts() {

   return creditService.getCreditDrafts()

                       .subscribeOn(Schedulers.io())

                       .observeOn(Schedulers.computation())

                       // map from raw to safe                                

                       .flatMapObservable(Observable::fromIterable)

                       .map(creditDraftMapper)

                       .toList()

                       // put mapped objects in store

                       .doOnSuccess(store::replaceAll)

                       .toCompletable();

}

Java isn’t built for Mobile and Web in Fintech? We would like to disagree. A bank, whether it runs on servers or in the cloud, must be robust and able to work consistently for many years without a need to tweek this and that. Here it’s the ideal tool with a large, mature ecosystem and non-breaking changes.

It is by far the most used technology in Enterprise and backend. The majority of ranking sites tend to put it at the top.

TIOBE, specialized in assessing and tracking the quality of software, named Java the second most popular language of 2020 and one of the top two most in demand technologies over the last 20 years! During this period, it has been only surpassed by C a couple of times.

For 2020, PYPL, relying on Google Trends data, listed Java as the second most popular programming language behind Python. And here we’d like to point out that it only lost the lead in 2018.

Also, JetBrains’ fourth annual developer survey placed it second, just behind JavaScript.

Verdict

Java is facing stiff competition from Python, often synonymous with data science and machine learning, and JS. It will probably never have the same market share it once had in the industry. However, the developers still view learning this technology as a secure investment for the future, since the number of job openings demanding these skills in Fintech is as immense as ever. And considering the amount of adoption and many recent innovations, it will remain the number one choice for financial business going forward.

2. Kotlin

In recent times, Java received much criticism regarding developer experience and ergonomics: It is verbose, produces boilerplate, prone to accidental features, and lacks many modern features. We strongly believe Kotlin is the best among technologies that tried to address those shortcomings.

JetBrains, the developer behind IntelliJ IDE, released Kotlin in 2016. It tried to solve the described issues without compromising the compile time. Kotlin has introduced many excellent features from other state-of-the-art and highly productive technologies. It is considered a much simpler, modern, concise alternative.

Android and many Enterprise apps run on LTS versions of JDK. In such use cases, Kotlin provides the developers more powerful modern features as Kotlin can target a wide range of older JDK versions (such as 6 or 7).

Kotlin received a significant boost in 2019 when Google declared it as the preferred Android and web app development option. But why is it so fast growing?

  • Kotlin is statically typed and supports multi-paradigm (object-oriented, functional).
  • It has introduced many modern features in JVM like Type Inference, Null Safety, Data Classes, Extensions, Coroutines. With its clean design, Kotlin resembles Python on JVM in terms of developer productivity.
  • As the preferred language to develop for Android, it has already surpassed Java with a 60% market share in this field.
  • The industry gave it a warm welcome. Many Fortune 500 companies are adopting Kotin, including the tech giant Google.
  • Although Kotlin was developed mainly as a JVM language, it has recently widened its target platform support. Today it can be compiled to JS, Native Code (via LLVM).

The best of both worlds

Mastercard entered a partnership with Corda to develop and pilot a new blockchain-enabled cross-border payments solution.2 It connects global fast payments infrastructures, trading schemes and banks supported by a Mastercard-operated clearing and settlement network. Corda is an open source blockchain project written in Kotlin for storing, managing, and synchronizing financial obligations between various financial institutions.

This example is taken from the Corda project:3

// Add this import:

import net.corda.core.identity.Party

// Replace TemplateState's definition with:

@BelongsToContract(TemplateContract::class)

class IOUState(val value: Int,

               val lender: Party,

               val borrower: Party) : ContractState {

    override val participants get() = listOf(lender, borrower)

}

If the team wanted to leverage innovation, on the one hand, and sustainability provided by the JVM, on the other, Kotlin is ideal. It attracts Fintech companies for its progressive algorithms, flat learning curve, and increased development velocity.

On the rise

First released in 2016, Kotlin is gaining popularity and is becoming a top trend in the near future. As of December 2020, it ranked 13th on PYPL, just behind TypeScript and Go. Seeing it above such powerhouses as Ruby (14th) is already a rather impressive result.

Kotlin is designed for better developer ergonomics and enjoyed globally. It is the 4th most loved language for nearly 63% of respondents, just behind Python, as per the Stack Overflow 2020 Developer Survey.

With a 182% year-over-year increase between 2019 and 2020, it is one of the fastest-growing programming technologies worldwide, according to the GitHub Octoverse.

JetBrains 2020 Developer Survey stated that Kotlin is among the top three languages developers want to migrate to and adopt as their primary tool:

Verdict

Kotlin is one of those rare instances that strike the right balance between cool features and simplicity. It will definitely see more popularity next decade. Kotlin is an excellent choice for the curious minds who want to learn a highly productive language or test skills in modeling Android apps. Some even claim that betting on Kotlin would be a smart move for financial or banking organizations in the near future. You can read more about its features and what this technology means for the industry in BellSoft’s two-part series about Kotlin.

3. Groovy

In specific scenarios, dynamically typed languages have a significant advantage over statically typed ones from the standpoint of developer speed. Inspired by Python and Ruby, James Strachen started to develop dynamically typed programming for JVM in 2003. Four years later, Groovy saw the light of day as the first of its kind. It has introduced Python-like clean coding combined with Ruby-like dynamism.

Groovy is a respectable choice and widely used for the following reasons:

  • It is optionally typed and multi-paradigm (object-oriented, functional, imperative, scripting).
  • Groovy has brought many pragmatic features: type inference, multi-line strings, closures, prototype extensions. This approach later heavily influenced other technology, like Kotlin.
  • It is seamlessly compatible with the JVM and boasts a colossal library ecosystem. Many important frameworks, such as Spring, feature Groovy.
  • It can be used for Domain Specific Language (DSL) and implementing traits at runtime.
  • Dispatching methods through the meta-object protocol instead of calling them directly makes it highly performant.
  • Groovy is now part of the Apache foundation and is massively used in the industry. It is ideal for scripting, tooling, and DevOps for its dynamic, concise nature. Widespread tools like Gradle, Jenkins, and SoapUI use Groovy as the primary programming language. Being in DevOps and Architecture domains also extends its lifetime.

Speed is key

The Australian-based Auto & General Insurance Company Ltd. needed internal tooling to manage its DevOps.4 It planned to create a Maven archetype-like plugin for Gradle that generates project derivatives from local templates. For this small-scale finance project that other systems rely on, rapid development and operations are of utmost importance. Groovy is the perfect fit for interoperating with the company’s existing tools thanks to its dynamic nature, support for DSL, and huge adoption in the DevOps domain.

Little goes a long way

Groovy is a mature programming language offering Python-like productivity in JVM. This combination proves its advantage for a variety of smaller tasks: tooling, scripting, proof of concepts. Hence its relative popularity in finance, trading and banking regardless of not being a general-purpose language.

On TIOBE, Groovy moved its position from #12 to #11 in December 2020.

However, the PYPL index ranked Groovy as 23rd the same month: it seems that 0.45% market share is not something to boast about.

Verdict

Optionally typed Groovy is not for large-scale production in Fintech: its benefits lie in fast delivery and dynamism. Method caching and other pragmatic features are the secret behind the neat performance. Financial enterprises consider Groove a well-established tool that will have its share of users no matter what.

4. Scala

The JVM veteran Martin Odersky decided to work on its drawbacks. In 2004, he released Scala that combined many functional programming features with the object-oriented paradigm. It became one of the earliest languages targeting the JVM as a runtime platform. Scala has successfully accelerated technological advancements and directly contributed to the recent modernization of Java. The industry would not be the same without this language: it has played a critical role in popularizing the functional programming paradigms in the last decade.

What are its features valuable for finance and Fintech in general?

  • It is statically typed and has a multi-paradigm model (object-oriented, functional, concurrent, imperative).
  • Many functional programming features have been introduced with Scala, such as currying, immutability, lazy evaluation, pattern matching, type inference from Haskell and Standard ML.
  • With its functional programming features, immutable collections and concurrent support, it is heavily used in data-intensive applications. Some of the world’s best batch and stream processing applications (Apache Spark, Apache Kafka) are written in Scala.
  • Although it was developed mainly as a JVM language, Scala can be compiled to other intermediate representations: JS, Native Code (via LLVM), etc.
  • It has gone through a major overhaul in Scala 3 (Dotty), addressing various criticisms and pain points. Scala 3 is more opinionated, simpler, predictable, and stable. It’s got rid of several obsolete features and reduced compile time — to save resources and increase capital.

Skyrocketing performance

In 2016, PayPal implemented Scala as a part of their complex finance infrastructure to increase the amounts of transactions it could receive.5 Built on Akka (a runtime and toolkit to simplify the building of apps on the JVM) with Akka Streams and powered by Scala with Kafka, their new open source squbs platform showed incredible results. Applications served a billion+ hits a day “with as little as 8 VMs and 2 vCPU each.” This change proved to be a successful investment. Before, with a Spring/Java combination, the performance was almost one-tenth of what the team achieved.

PayPal’s requirements for the tech stack were:

  • horizontal and vertical scalability,
  • near-real-time performance,
  • efficient usage of resources (most likely for cloud deployments), and
  • resiliency under high burst.

Below you see a perpetual stream that starts and stops with the system. It provides a convenience trait to help write streams controlled by the lifecycle with minimal to no message losses. It provides customization hooks and killSwitch (from Akka) to be embedded into the stream.

class MyStream extends PerpetualStream[Future[Int]] {

    def generator = Iterator.iterate(0) { p =>

        if (p == Int.MaxValue) 0 else p + 1

    }

    val source = Source.fromIterator(generator _)

    val ignoreSink = Sink.ignore[Int]

    override def streamGraph = RunnableGraph.fromGraph(

        GraphDSL.create(ignoreSink) { implicit builder =>

          sink =>

            import GraphDSL.implicits._

            source ~> killSwitch.flow[Int] ~> Sink

            ClosedShape

        }

    )

}

Here Scala fits nicely with its functional programming features and potential interoperability with leading streaming platforms like Apache Spark and Apache Flink.

Always finds its purpose

Even though Scala was released with a lot of optimism, it has remained a special-purpose language. We see its adoption within Fintech flattening in the past five years. But in its domain, data-intensive applications and stream processing, Scala edges out almost all others. Moreover, many acclaimed and prevalent frameworks and runtimes support this piece of tech (e.g., Akka, Play, Finagle, Lagom), proving its strong foothold in the industry.

Verdict

Scala had a say in improving Java and influenced other modern tech, including Kotlin; but it has not gained broader acceptance for financial institutions. Its many breaking changes that had been introduced over the years were not well received in Fintech or banking. The one thing it’s really good at is stream processing, which is shown by the PayPal use case above. Scala 3, the latest release, finally adapts pragmatic features to become a more mainstream language. We do hope this version has the potential to make it general-purpose and used on a wider scale in finance and trading.

5. Clojure

Lisp was one of the first ever high-level languages, released in 1958. Much later Rich Hickey, a noted engineer, worked to create a dynamic and functional dialect of Common Lisp to target JVM, which became Clojure. Unlike Scala that combines the object-oriented and functional paradigms, Clojure is a pure functional language. Clojure encourages immutability and immutable data structures, as well as being explicit about managing identity and its states.

We may summarize its main characteristics as follows:

  • It is dynamic, agent-oriented, and functional.
  • By default, it has an immutable data structure and provides tail recursion.
  • As a Lisp variant, Clojure also supports Code as Data, i.e., it can be modified automatically at runtime with Lisp macros, and treats programs as models.
  • Like Scala and Kotlin, Clojure also can be compiled to other intermediate representations, such as JS and .NET. ClojureScript has influenced new functional languages targeting JS (e.g., Elm).
  • With its immutable core data structure, software transactional memory (STM), and Atoms (shared, synchronous, independent state), Clojure excels at concurrent and parallel programming.

Micro level analysis

Nubank, the largest Fintech in Latin America that became a unicorn startup in 2018, has developed a Double Entry Accounting system with Clojure.6 The bank claims it to be “an ancient technology used for centuries” which wonderfully connects with this functional programming language. Among its requirements, Nubank mentioned that the language should be capable of parallel processing, ensure maintainability, and manage invariables.

Here’s a snippet that showcases declarative rules for banking movements.

(def new-purchase

    [{:entry/debit-account    :book-account.asset/settled-brazil

      :entry/credit-account   :book-account.liability/payable-brazil

      :entry/amount           (comp :amount :purchase)

      :entry/post-date        (comp time->date :time :purchase)}

      {:entry/debit-account    :book-account.liability/payable-brazil

        :entry/credit-account  :book-account.profit-and-loss/interchange-brazil

        :entry/amount          (comp :interchange :purchase)

        :entry/post-date       (comp time->date :time :purchase)}

      {:entry/debit-account    :book-account.liability/current-limit-counterparty

        :entry/credit-account  :book-account.asset/current-limit

        :entry/amount          (comp :interchange :purchase)

        :entry/post-date       (comp time->date :time :purchase)])

This allows proceeding analysis of a specific user or groups of users by any criteria behavior. For instance, the Fintech can predict capital flows or how much a customer will spend next year based on the current prices.

Perfect for greenfield

Clojure is getting popular with companies in finance, retail, banking, and Fintech working on large-scale projects from scratch thanks to its speed of development and clean code. It is excellent for specific use cases (e.g., concurrent programming, big data projects); slowly but steadily, it’s gaining traction in the financial industry. Still, Clojure is not yet a general-purpose, mainstream programming language.

Verdict

Although Clojure is excellent at what it does, it lacks the pragmatism of Kotlin or Groovy. A universal language for Enterprise needs both object-oriented and functional paradigms. We predict that Clojure will not go beyond its scope and remain special-purpose.

Summary

JVM is, by far, the most widely used process virtual machine in finance. It is powerful, battle-hardened, and it has passed the test of time. In this article, we have explained how financial, banking, investment, and overall Fintech companies can benefit from JVM’s versatility and summarized the top 5 JVM languages, each with its strengths and particular use cases.

Any business task is possible with one of these five options. You can rest assured that in any case and resources available, your solution will be performant, implement fast, multiply your capital, and stay relevant for many years to come.

If you would like to learn more about how JVM-based solutions can advance your business, contact BellSoft. The company’s engineers are willing to share best practices collected over the decade of working in the JDK world. They’ll be happy to answer all your questions and provide the Progressive Java Runtime that will satisfy your needs.

References

  1. n26/N26AndroidSamples · GitHub
  2. Mastercard and R3 Partner to Develop New Blockchain-Powered Cross-Border Payments Solution
  3. Corda · GitHub
  4. Auto & General Insurance Company Ltd. · GitHub
  5. PayPal Blows Past 1 Billion Transactions Per Day Using Just 8 VMs With Akka, Scala, Kafka and Akka Streams
  6. Building a powerful Double Entry Accounting system - Lucas Cavalcanti

Subcribe to our newsletter

figure

Read the industry news, receive solutions to your problems, and find the ways to save money.

Further reading