Find out how to choose the right
programming language for your team.
- If your team’s users are Scala developers, use Gatling in Scala
- If they are Kotlin developers, use Gatling in Kotlin
- Otherwise, use Gatling in Java
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.
Let’s go backwards a bit, why is Gatling usable in 3 programming languages?
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.
Why Java and Kotlin then? Ease of Adoption!
The main reason we introduced this Java API is because 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.
What’s the difference between the different languages?
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!
Some technical differences between Java, Kotlin & Scala:
- Scala and Kotlin are less verbose than Java
- Scala and Kotlin compilers are way slower and have more CPU usage than the Java compiler
- Scala requires an extra (free) IntelliJ IDEA plugin that’s not installed by default
- Scala and Kotlin require extra maven and gradle configurations, while Java is set for both out-of-the-box. This point is mitigated by all the demo projects we provide to get you started.
- Scala is the only one of the 3 that works with sbt, the interactive build tool for Scala that is supported by Gatling
Since introduction, how is the Java DSL doing?
We’ve had 10 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 and 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.
Where should I go if I want to learn about how to use Gatling in any language?
- Our official Gatling documentation provides all code snippets with all 3 flavors of Gatling: Java, Kotlin and Scala
- Gatling’s official tutorials are available as well and all emphasize Java
- Our official online free courses at the Gatling Academy have 3 modules available in Java and 2 available in Scala
- Most historical unofficial material for Gatling is written for Scala due to the recency of the addition of Java. However, most of this material is outdated and/or heavily inspired from the official material.
- The Gatling Community has lots of posts and requests in both Scala and Java. Feel free to ask any questions you may have about either there and you’ll likely get a response.
What’s the future of Gatling? Java or Scala?
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.
So which should I choose?
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.