Full Stack Web Frameworks - KT

By pjain      Published Dec. 17, 2019, 1:52 a.m. in blog Programming   

Kotlin-idiomatic micro- web-server-side frameworks

Javalin - fork of Spark

Basically, Javalin is just a few thousand lines of code over Jetty. A new version is released two times per month (overall), where each non-major version is backward compatible.

+ive It centers around completing things rapidly. In some cases this doesn’t feel like an advantage

+ive Simple to use

+ive Embedded Jetty server

+ive Lightweight and fast, especially compared to other counterparts here.

+ive Lambda- based WebSocket API

+ive Real micro-framework

-ive Documentation is not a great. While suitable for someone with a prior Javalin knowledge; it simply not good for someone who simply needs to learn from scratch.

-ive Not sticking to standard terminology. For instance, what is normally known as Routes and Filters are combined together as Handlers. Which makes it harder when you read outsider tutorials and people keep referring to it as routes or filters.

-ive Not develop enough; their feature to-do list is still excessively long. To battle this you should depend on outsider dependencies and that is an extremely profound gap.

KTor

Ktor is a framework for rapidly making web applications in Kotlin with minimal effort. It is very light and don’t impose any constraints on what underlying technology a project is going to use. What makes it stand up is that it’s created by the Kotlin team.

Reliable and stable

Small memory footprint and lightweight

Fast but competition is faster (like Javalin and http4d)

Perfect for prototyping

Real micro-framework

+ive it's written in Kotlin and optimized for asynchronous use with co-routines. This is what you pick if idiomatic Kotlin everywhere is what you are going for.

+ive it utilizes a lot of the multiplatform libraries making it suitable for future uses in e.g. WASM usecases (edge computing, serverless computing). Likewise native compilation means it can go where a lot of JVM stuff can't go because of the footprint. But it can also play nice with existing java/jvm stuff if that's what you need.

-ive Simplistic like Javalin, so if you have to make anything complex you should incline toward third-party libraries.

-ive If you do not know what are you doing then documentation is going to be confusing as hell.

-ive Not mature enough

-ive Small community

I'm Using Ktor with Exposed : perfect combination for now.

I used Akka HTTP (a Scala library) by calling its Java API from Kotlin. It is quite simmilar to ktor, but has more features (like real type safe request) and it is has been used for years in Play, so it just works. In fact my experience using Akka actors from Kotlin is very positive. They are great when you need implement complex concurrency behaviors and Kotlin actors are not powerful enough

Fuller but harder web-server-side frameworks

Vert.x Fuller but harder

Vert.x is a toolkit for building reactive applications in a different programming language, like Java and Kotlin.

Fast
Small memory footprint – Comparable to Spark
WebSockets support
Reactive = more flexible, loosely-coupled and scalable applications.
Vert.x offers a complete ecosystem
Highly modular

+ive powerful but harder to use

-ive It’s not for everybody. As a reactive toolkit, it fills a different niche compared to other frameworks here.

-ive Not a solution for you if the Spring Boot is your framework of choice. Before you try it make sure you know what are you getting into.

Spring Boot

Spring Boot makes it easy to create stand- alone, production- grade Spring based Applications that you can “just run”.

Spring Boot is the mature choice and they are doing some interesting stuff optimizing for Kotlin. Check out their kofu effort for example. Also comes with co-routine support and a bunch of other good things. For commercial projects with conservative companies, this is the one to pick. The next versions are going to basically result in Java becoming a second class citizen in the Spring ecosystem. IMHO this is the breakthrough Kotlin needs on the backend and it means a lot of places currently advertising Java positions will soon be advertising Kotlin/Spring Boot type jobs. Now is a good time to specialize in this. The short version of this is: if you are using spring and you are not using Kotlin, you are doing it wrong and missing out on a lot of good stuff.

Can create stand- alone spring applications
Easy to setup and handle
Spring family environment
Modular
Plays well with other libraries
Large community (very popular)
Enterprise-ready

-ive Documentation fragmentation. Too many sources, too many versions, too many differences. Make sure you know which version you are going to use.

-ive Breaking changes between versions. If you hate what Angular is doing you will also hate it here.

-ive Confusing documentation.

Spark - Java and now Kotlin

Spark is the typical suspect with regards to micro-services. It’s one of the oldest expressive Kotlin/ Java web framework built for rapid development, you can even consider it a higher level of Kotlin frameworks.

Small memory footprint
Fast and also a lightweight
Excellent for rapid prototyping
Easy to setup
Plays well with Angular
Real micro-framework
Embedded Jetty server
-ive Documentation could be better, it is not intended for beginners.
-ive Not appropriate for large projects.

0 comments

There are no comments yet

Add new comment

Similar posts

SOA Api Metadata

Serverless Computing

Android Layouts Design 101

Drawing, Canvas in Kotlin