In October 2021 Gatling expanded its offer from just a Scala API to include a Java API as well. The additional API now lets developers choose to script using Java, Kotlin, or Scala. In this post, we’ll be exploring that decision and highlighting some of the differences that might help you choose which language to use.
Originally, Gatling was implemented in Scala, and for a very long time, we only offered the Scala API for writing Gatling tests.
However, In Gatling 3.7, we introduced our Java API that also allows you to use Kotlin. When adding the new API we wanted to make the experience of designing a script and building a test as close as possible to the existing scripting process. Our goal was not to create something entirely different but to make Gatling more accessible to users who might be intimidated by the thought of learning a new language. We also wanted to keep the same concepts and have very similar syntaxes for teams that might want to migrate their projects from Scala to Java.
The main reason we introduced this Java API is that lots of potential users were reluctant to give Gatling a try because of what they'd heard about Scala, in particular, that it's "hard". When starting a project the thought of having to learn a new language can be a big barrier to entry for some users. If you’re a long-time Gatling user who’s not proficient in Scala and learned to use Gatling, you probably know that this is more of a psychological barrier. While there is a bit of a learning curve to use Scala with Gatling, it’s not like you’re really learning a full new language and you definitely don’t need to be a Scala developer to write a Gatling script.
We chose Java because we are a load-test-as-code solution and many developers, software engineers, and site reliability experts are already proficient in Java. Not only is Java widely taught in computer science courses but there are also many free Java resources available online and plenty of existing Java developers around the world. If you’re starting from scratch, Java is probably your best choice in terms of ease of adopting Gatling in your organization.
The Java API also gave us the added bonus of having Kotlin as an additional option. While there are fewer Kotlin developers around, because Kotlin was designed to fully interoperate with Java it’s a great option for users who prefer it and we’re happy to support it.
In terms of functionality, there isn’t one! One thing we wanted to be sure of when adding additional languages is that there would be no difference in terms of features, whether you choose to write your scripts in Java, Kotlin or Scala. If you’d like to know some of the different technical aspects read on!
We’ve had ten releases since the Java DSL was introduced last year with Gatling 3.7.0 and we’re happy to say that it’s pretty stable. The latest release is Gatling 3.8.3; every update has added and improved stability.
Here’s a little of what we’re seeing in terms of usage per language. Amongst users of the latest minor version, 3.8.x:
When you consider that the Java DSL is under a year old, this is a huge percentage of users now using it and we expect this trend to continue in the future.
If you're committed to Gatling's Scala API and are happy with it, fear not: it's here to stay. We’re proud of the user base we’ve built with Scala and we’ll never take that away from you. Our goal in adding additional languages was to make Gatling more accessible, not to force existing users to switch to something new.
Moving forward our development guideline is that new features and changes can only be introduced if they can be used with both APIs.
As we’ve seen already with new Gatling users, we expect Java and Kotlin usage to keep on growing. Due to their larger existing user bases, we’re both observing existing users migrating their Gatling tests from Scala to Java and new adopters going with their favorite programming language.
Whatever makes you happy! If you’re a Scala developer and working on your own, choose Scala. If the bulk of your team uses Kotlin, jump in with Kotlin! If you’re a Java developer, work with a Java team, or want to make your scripts more accessible to new developers, use Java. There’s really no wrong answer. Even if you need to start using something new, you won’t need to learn a full language to start writing Gatling scripts. Whatever you choose the Gatling team will continue to upgrade it and take load testing to the next level with you moving forward.