Micro Web Frameworks For Kotlin

Nick Apperley
3 min readFeb 3, 2017

--

When doing server side development with Kotlin you might want to consider using a micro web framework. To help you decide which one to use there will be four major frameworks listed along with their differences.

Spring Boot

  • Kotlin Support: Next stable version (2.0.0) to be released has some official Kotlin APIs/documentation
  • Documentation: Reasonably comprehensive with lots of guides and a very helpful getting started guide
  • Maturity: Very mature
  • General Difficulty: Easy with the Spring INITIALIZR system (switch to the full version to select Kotlin as the Language) to generate a shell project based on what options are chosen, APIs are approachable
  • Deployment Difficulty: Easy to deploy but has too many dependencies, requires JRE 1.7
  • Flexibility: Reasonably flexible, can swap out major parts and even use a different web server
  • API Style: Mainly traditional (uses annotations) with some declarative APIs
  • Concurrency: Traditional multi threading and the Reactor stream API
  • Data Persistence: Spring Data (JPA based)
  • Web Server: Tomcat (can be changed)
  • Configuration: Use annotations/properties files
  • REST Support: Provided by framework APIs
  • Kotlin Coroutines: Not supported

Most mature web framework with excellent documentation (plenty of guides), an easy learning curve, and the best Kotlin support. Use this framework when you need something that is solid (will be around for a long time), be able to quickly create and deploy a web app, and has proper Kotlin support out of the box. Spring Boot’s mixing of multiple API styles could cause major maintenance issues.

Vert.x

  • Kotlin Support: Next stable version (3.4) will have some official Kotlin APIs
  • Documentation: Very comprehensive and highly detailed manuals/API reference, but doesn’t have a good getting started guide/tutorial
  • Maturity: Mature
  • General Difficulty: Very easy to get into with the documentation (start with Vert.x Core Java Manual) and the API style
  • Deployment Difficulty: Easy to deploy and small footprint, however there are some unnecessary dependencies that need to be moved out of Vert.x Core module, requires JRE 1.8
  • Flexibility: Very flexible, the toolkit mainly avoids mandating a particular approach for a specific area, can select the modules that are to be used in a project
  • API Style: Declarative
  • Concurrency: Built in Agent based system which is similar to the Actor system
  • Data Persistence: JDBC/MongoDB
  • Web Server: Netty
  • Configuration: No standard way to do configuration
  • REST Support: Vert.x Web module
  • Kotlin Coroutines: Not supported

An excellent choice when you need an very easy (standard) way to do high level concurrency, and need a web framework that isn’t very opinionated but highly flexible. Keep in mind that the high flexibility can make it difficult to do certain tasks (eg configuration).

Spark

Very important to note that Spark doesn’t mean Apache Spark!

  • Kotlin Support: Non existent
  • Documentation: Average, some documentation hasn’t been updated for a while, navigation of website is inconsistent/confusing
  • Maturity: Reasonably new
  • General Difficulty: Very easy to get into with its API
  • Deployment Difficulty: Small footprint, Requires JRE 1.8
  • Flexibility: Reasonable flexible, doesn’t impose a specific web app structure
  • API Style: Declarative
  • Concurrency: Traditional multi threading
  • Data Persistence: None provided
  • Web Server: Jetty
  • Configuration: XML files
  • REST Support: Provided by framework APIs
  • Kotlin Coroutines: Not supported

Likely to be the easiest Java web framework to get into when you want to develop a very basic web app (particularly if its a web service). Remains to be seen if Spark will put its money where its mouth is and provide actual Kotlin support, which wouldn’t be difficult to do with its declarative style APIs.

Dropwizard

  • Kotlin Support: Non existent
  • Documentation: Has a decent getting started guide and a comprehensive manual
  • Maturity: Very mature
  • General Difficulty: Not too bad however there are some unnecessary hoops to go through
  • Deployment Difficulty: Straight forward to deploy if using Maven, requires JRE 1.7
  • Flexibility: Some flexibility however it is a bit rigid
  • API Style: Traditional (uses annotations)
  • Concurrency: Traditional multi threading
  • Data Persistence: JDBI (not common, can be changed)
  • Web Server: Jetty
  • Configuration: YAML files
  • REST Support: JAX-RS (Jersey implementation)
  • Kotlin Coroutines: Not supported

Used to be the easiest web framework to get into years ago, however Dropwizard has been surpassed by newer Java micro web frameworks (eg Spring Boot, Vert.x) and is struggling to stay relevant. Dropwizard is the web framework to go for if you prefer traditional ways to do web development.

--

--

Responses (2)