Kotlin, an impressive language
Kotlin was created in 2010, which makes it newer than many popular programming languages today. Although it's been around for 12 years (at the time of this writing), I'm saddened it hasn't gained the popularity it deserves. The syntax is straightforward and it has many use cases and safety features built-in. The project touts that the language is "easy to pick up, so you can create powerful applications immediately " (kotlinlang.org). You can use Kotlin to build native Android apps, web applications, and multi-platform mobile apps.
So, why with all these wonderful features is Kotlin not used more in the web application world today? Sadly, I won't be examining this question in detail in this post, but I can tell you one reason why I haven't used it until now: Kotlin's tightly coupled relationship with Intellij. I have never seen any programming language tie itself so tightly to a specific IDE. The majority of 'Getting Started' tutorials I've found begin with 'open Intellij'. I don't have any problems with Intellij, but I'm in my 30s and I don't want to learn a new code editing process. I don't want to learn new keyboard shortcuts or query a database in the same program that I write code in. I'm a Vim (yes, Vim!) guy and I plan on staying that way.
If you too want to avoid the overhead of learning a new development environment when learning a new programming language, keep reading. I'm going to show you how I created a Kotlin + Spring Boot development environment with hot reloading without using Intellij! Here we go.
How is it done?
I was actually surprised at how easy this was. Here are the steps for MacOS:
- Install openjdk
brew install adoptopenjdk
- Create a new Kotlin +Spring starter application by visiting start.spring.io and configure it to your liking or copy the config in this screenshot to get a starter web application. Once done configuring, click 'Generate' to download the project.
- Run the Spring Boot application in a terminal window with the gradle wrapper script
cd demo && ./gradlew bootRun
- Open another terminal window and run the continuous build command with gradlew (this is what makes it hot reload)
./gradlew build --continuous
- Start editing code in your favorite text editor!
This was a high-level proof of concept for creating a development environment for Kotlin + Spring Boot that did not involve Intellij. It is by no means complete but is a great starting point to get acquainted with the Kotlin Language, Gradle, and Spring Boot framework. VSCode has several helpful extensions related to Kotlin and Gradle. Vim also has plugins that make development in this environment much easier. I list these extensions and plugins below.
You'll notice that in this setup, it does require you to have 2 terminal windows open, one for Spring Boot and one for hot reloading. Multiplexers like Tmux or Screen can make this process slightly less cumbersome. Even with this minor annoyance, I enjoyed learning about this environment with tools I'm familiar with. I hope you have found this helpful. Good luck on coding your journey!