Blog

Kotlin and Vaadin for productive and fun web app development

By  
Marcus Hellberg
Marcus Hellberg
·
On Jan 26, 2023 5:19:00 PM
·

Kotlin is a programming language that has gained much popularity over the last few years. Its concise and expressive syntax feels liberating compared to the verbosity of Java. Vaadin supports the Kotlin programming language through the Karibu-DSL library, which contains various extensions to use Vaadin and Kotlin together.

Despite its simplicity, Kotlin is a fully type-safe language and helps you avoid many common programming errors in Java, such as null-pointer exceptions. Kotlin runs on the JVM and is fully interoperable with existing Java code, which means you can use it both in new and existing projects.

Can you build web applications with Kotlin?

Although Kotlin is well-known among developers as a language for building Android apps and backends, it's also great for building web apps. If you want to stay close to the browser API, you can compile Kotlin to JavaScript to build frontend applications instead of using JavaScript.

A full-stack framework makes building web apps in Kotlin even easier. The Vaadin framework allows you to build web apps on a higher level of abstraction, working with components instead of DOM elements. Vaadin handles the communication between the server and browser transparently.

Vaadin: a full-stack web framework with Kotlin support

Vaadin Flow is an open-source web framework for JVM backends. It features a large library of customizable UI components and supports an intuitive Kotlin DSL for building UIs declaratively.

verticalLayout {
	val nameField = textField("Your name")
	button("Say hello") {
		onLeftClick { Notification.show("Hello, ${nameField.value}") }
	}
}

Vaadin applications run on the JVM, giving you full access to backend services, databases, and other server resources as you build your app. The apps are secure by default, thanks to Vaadin's unique architecture.

Get started: build a Kotlin web app with Vaadin

Here are some links to help you get started:

Please try it out and let us know your thoughts in the comments below!
Marcus Hellberg
Marcus Hellberg
Marcus is the VP of Developer Relations at Vaadin. His daily work includes everything from writing blogs and tech demos to attending events and giving presentations on all things Vaadin and web-related. You can reach out to him on Twitter @marcushellberg.
Other posts by Marcus Hellberg