top of page
  • B D

Switching from Java to Kotlin

Hello, there! My name is Bryan, and I'm the (lead) programmer in BotsBurgh. After talking with other programmers on the team, we decided to switch from the Java programming language to Kotlin.

So what is Kotlin?

Kotlin is a modern programming language that runs on the JVM. (In layman terms, it compiles into the same kind of file that Java does.) The benefits of this are that it is entirely cross-platform compatible. If a computer can run Java (through the JRE), it can also run Kotlin. The other benefit is that it was not designed in 1995, therefore does not require layers upon layers of bootstrapping code.

Another plus is that Kotlin can work directly with Java files. You can import Java classes from Kotlin, and import Kotlin files from Java. They both work, and it translates pretty well!

Ok, that was a lot of talking. How about I show you an example to compare the two language?

Take a look at that! Files aren't required on being a class, there's an actual function keyword, the arguments parameter isn't required, and not more System.out.println!

There's a lot more examples, but I highly recommend you check out Kotlin's website for those.

Using Kotlin with FTC

I've gone over the main features of Kotlin, but I haven't shown any examples of it being used to program an actual robot. I have two examples.

If you've worked with advanced autonomous and motion planning, most likely you've heard of Road Runner. If you take a look at the code, it is written entirely in Kotlin! This is a cool example, but it doesn't actually show any tele-ops or autonomous programs. For this, I bring in BotsBurgh's own 2022-23 repository. After #4 merged, the code is fully in Kotlin. You can take a look at TeleOpMain.kt for an example.

Maybe a library and an unfinished program aren't that convincing, but all that I ask is that you try it. Kotlin is fun to work with, and is a lot less typing than Java.

Converting to Kotlin

For converting a Java program to Kotlin, I recommend you read this article from Jetbrains. It recommends a Jetbrains IDE specific solution, but you can alternatively add the Kotlin plugin to Gradle manually.

Jetbrains IDEs (and Android Studio) have a really cool feature called J2K. It allows you to automatically convert any Java file to Kotlin (most of the time). This is handy if you have existing APIs that you want to migrate over.

You can also convert files manually, which is what I did. I don't know which strategy is faster (probably J2K), but they're both options.


I hope this article helps FTC teams that are tired with a lot of bootstrap and confusing legacy features. Currently I am happy with the changes, and I think I will continue to be throughout the season.

If you are a high-schooler at USC interested in FTC and want to join a team, you can check out our enroll page. Alternatively if you are an adult and want to support the robotics initiative, you can donate or volunteer.

Thanks for reading!

46 views0 comments


bottom of page