Auto Added by WPeMatico

Server-side with Kotlin Webinar Series

Kotlin is becoming a language of choice for server-side application development. Null safety, 100% Java interoperability, coroutines, and many other features make Kotlin ideal for backend programming.

We’re launching a series of webinars to help you to learn more about backend development with Kotlin or even try it for the first time.

In the next few weeks, speakers from JetBrains, Google, and Confluent will cover three essential topics of backend development: event stream management with Kafka, running applications in the cloud, and backends with Spring Boot.

Kotlin and Apache Kafka

What’s it about?

Viktor and Anton will demonstrate how Kotlin users can leverage Kafka to handle streamed data. The presentation will include a walkthrough of the internal architecture of Kafka.

Presenters:

  • Anton Arhipov, developer advocate at JetBrains, the company that created Kotlin and IntelliJ IDEA.
  • Viktor Gamov, developer advocate at Confluent, makers of an event streaming platform based on Apache Kafka.

Who’s it for?

  • Software engineers with experience of backend development in Java or Kotlin.
  • Engineers who already use Kafka but want to learn more about the capability of the system, or are considering using it with Kotlin.

When?

December 10, 2020
17:30 – 18:30 CET (8:30 PST).
Visit the web page for additional information and time in your timezone.

Register now

Kotlin and Google Cloud Platform

What’s it about?

In this presentation, you’ll learn how to use Kotlin with your existing Java codebase and how to take advantage of modern features like сoroutines, which provide an easier and more efficient concurrency model. You’ll also learn how to deploy Kotlin apps to Google Cloud.

The webinar is hosted by James Ward, developer advocate for Google Cloud Platform.

Who’s it for?

  • Android developers without previous backend experience.
  • Anyone who wants to know more about the capabilities of Kotlin on server-side and in the cloud.

When?

December 17, 2020
17:30 – 18:30 CET (8:30 PST).
Visit the web page for additional information and time in your timezone.

Register now

Kotlin and Spring Boot

What’s it about?

In this webinar, Ray will walk you through the creation of a Kotlin backend service. You’ll use Spring Boot and Spring Cloud GCP to leverage many of the useful Google Cloud services for database, storage, and observability. Once this is done, Ray will demonstrate how to deploy the service to the serverless Google Cloud Platform, where the backend can automatically scale up the number of instances based on load, or scale down to zero instances when no one is using it.

Speaker: Ray Tsang, developer advocate for Google Cloud Platform and Java Champion.

Who’s it for?

  • Android developers without previous backend development experience.
  • Anyone who wants to learn the capabilities of Kotlin with Spring Boot.
  • Anyone interested in serverless technologies.

When?

January 14, 2021
17:30 – 18:30 CET (8:30 PST).
Visit the web page for additional information and time in your timezone.

Register now

Save the date

Once you’ve registered, we’ll send you a confirmation email with calendar invites, and we’ll send you a reminder a day before the webinars begin.

All webinars are free to attend and will be recorded and published to JetBrains TV after streaming. Subscribe to the JetBrains TV YouTube channel to get notifications about when they are uploaded.

Resources

We’ve created a website about productive server-side development with Kotlin. Check out the page for additional information.

Go to Kotlin server-side page

Continue ReadingServer-side with Kotlin Webinar Series

Server-Side Development with Kotlin: Frameworks and Libraries

It is quite common to use existing frameworks and libraries for backend application development. If we look at most of the popular frameworks in the Java ecosystem, many of them actually support Kotlin out of the box. There are a lot of Java libraries too. You can use these frameworks and libraries in your Kotlin programs thanks to Kotlin’s flawless Java interoperability.


Kotlin is an excellent choice for server-side application development. Go to the Kotlin for server-side page to learn more!


This blog post is partially based on presentation content from the Kotlin 1.4 Online Event. You can watch the full video on our YouTube channel.

Spring Framework

The most popular and feature-rich framework in the ecosystem is Spring. Approximately half of all projects in the JVM ecosystem now use Spring as the framework of choice. The previous blog post about Kotlin for server-side development includes stories from Atlassian and Expedia who use Spring Boot for their projects.

Kotlin is one of the four major themes for Spring Framework 5.x. A number of extensions were added to the Spring core API specifically to provide better support for Kotlin.

In fact, Spring’s official documentation features code samples in both Java and Kotlin. This is very convenient if you’re new to Kotlin, because you can see the code sample in Java and then immediately see its Kotlin equivalent and so understand the idioms faster.

The start.spring.io project generator also supports Kotlin along with Java and Groovy.

The number of Spring tutorials is growing. We recommend that you start with the Building web applications with Spring Boot and Kotlin tutorial.

As support for Kotlin in Spring Framework is being improved, we had the privilege to host Sebastien Deleuze with his presentation about The State of Kotlin Support in Spring at the Kotlin 1.4 Online Event this year. See the video below.

An interesting new addition to Spring is the project Spring Fu. It is designed to configure Spring Boot with code in a declarative way. The Kotlin variety of the configuration DSL looks quite nice:

val app = webApplication {
	logging {
		level = LogLevel.DEBUG
	}
	beans {
		bean<SampleService>()
	}
	webMvc {
		port = if (profiles.contains("test")) 8181 else 8080
		router {
			val service = ref<SampleService>()
			GET("/") {
				ok().body(service.generateMessage())
			}
			GET("/api") {
				ok().body(Sample(service.generateMessage()))
			}
		}
		converters {
			string()
			jackson {
				indentOutput = true
			}
		}
	}
}

This new approach to configuration in Spring promises faster startup times and lower memory consumption, and it is a good fit with GraalVM native image thanks to its reflection-less approach.

Ktor

Ktor is a framework created and maintained by JetBrains. It was built with Kotlin from the ground up. Ktor encourages a minimalistic approach to application design, as you only need to configure the functionality that your project requires. Using Kotlin coroutines, Ktor is truly asynchronous and highly scalable. Ktor also includes an HTTP client that is implemented as a multiplatform library and is widely used in mobile application development with Kotlin.

Our previous blog post covers JetBrains Space and Adobe Experience Platform projects that use Ktor because of its support for asynchronous programming.

At Kotlin 1.4 Online Event, Hadi Hariri gave a presentation about the current state of the Ktor project and its future plans. See the video below.

Here are a few tutorials we recommend for learning about Ktor:

More web frameworks

Of course, Spring and Ktor are not the only frameworks in the JVM ecosystem and there are plenty of other frameworks that you can use with Kotlin. Take a look at Micronaut, Quarkus, Javalin, SparkJava, Vaadin, CUBA, and Vert.x. This is just a small list of the frameworks available. All these frameworks have either code samples in Java and Kotlin side by side or have dedicated tutorials on how to use the framework with Kotlin.

There are also a number of frameworks that are implemented in Kotlin. For instance, http4k, and Hexagon.

Database access

Backend applications often rely on database access. One of the most popular libraries today for working with databases is the Exposed library. It is an ORM framework for Kotlin that offers two levels of database access: a typesafe SQL-wrapping DSL, and lightweight data access objects.

Here’s a very simple example using Exposed:

object Cities : Table() {
   val id = integer("id").autoIncrement().primaryKey() // Column<Int>
   val name = varchar("name", 50) // Column<String>
}

Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver")

transaction {
   create(Cities)

   val saintPetersburgId = Cities.insert {
       it[name] = "St. Petersburg"
   } get Cities.id

   val munichId = Cities.insert {
       it[name] = "Munich"
   } get Cities.id

   Cities.insert {
       it[name] = "Prague"
   }

println("All cities:")

for (city in Cities.selectAll()) {
   println("${city[Cities.id]}: ${city[Cities.name]}")
}

As you might have guessed, Exposed is not the only library that you can use with Kotlin for database access. You can use jdbi, jooq, JPA with Spring Data, and even just pure JDBC API to access databases from Kotlin code.

Testing

Testing a vital part of application development. JUnit and TestNG are perfectly fine for implementing unit tests in Kotlin. But there are more additional libraries that are great for testing in Kotlin:

  • Spek – a Kotlin-based Specification Testing framework for the JVM.
  • Kotest – a testing library with support for Kotlin multiplatform projects.
  • MokK – a mocking library for Kotlin tests.
  • Kotlin Power Assert – an amazing compiler plugin for Kotlin that enables the diagramming of assert function calls, making diagnosis of test failures a breeze.

Other libraries

Aside from handling HTTP requests and accessing databases, applications are often required to communicate with other services using specific protocols, perform decoding/encoding of data in various formats, and many other things. Here are a few libraries that will be useful for application development with Kotlin.

JSON is the universally accepted standard format for sending data between web servers and browsers. There are awesome JSON libraries available in the Java ecosystem and they are great for use in Kotlin programs too. Jackson and gson are the most popular Java libraries for working with JSON. However, there are also libraries that are implemented with Kotlin from scratch. Klaxon is a good example. Also kotlinx.serialization was recently released and it provides JSON support.

gRPC is a high-performance, open-source, universal RPC framework. Kotlin is now supported by gRPC.

RSocket is also gaining popularity as a protocol for use in building microservices. Kotlin integration was recently added to RSocket.

To work with GraphQL there’s graphql-kotlin library maintained by Expedia Group engineers.

These are just a few examples. In fact, there is a long list of Kotlin libraries maintained by the community where you’re sure to find a library for the task at hand. However, we’d like to point out that, thanks to Java interoperability, it is also possible to use virtually any Java library with Kotlin.

Additional Tools

Code quality is an important topic for Kotlin too! Thanks to the type system, especially null-safety, Kotlin is quite a safe programming language. However, there is still a need for code style checks. That’s the part that is currently implemented via additional tools.

Ktlint is a static code analysis tool maintained by Pinterest. It is a 2-in-1 tool that provides linting and formatting (supported via EditorConfig) for Kotlin code.

Detekt is a static code analysis tool that operates with the abstract syntax tree provided by the Kotlin compiler. It is easy to set up with Gradle and there’s also an IntelliJ IDEA plugin that simplifies configuration.

Generating API documentation from source code is also an important part of software project development. In Kotlin, we can use Dokka for this task. It is a documentation engine for Kotlin. Just like Kotlin itself, Dokka fully supports mixed-language Java/Kotlin projects. It understands standard Javadoc comments in Java files and KDoc comments in Kotlin files, and can generate documentation in multiple formats including standard Javadoc, HTML, and Markdown.

Summary

Kotlin was initially designed as an alternative JVM programming language, meaning that Kotlin can be used anywhere where Java is used. Thanks to Java interoperability, it is easy to use any of the existing frameworks and libraries that are familiar to Java developers. This all greatly simplifies the adoption of Kotlin for application development on the JVM.

The current state of Kotlin support in the ecosystem is at the stage where even big projects and companies are confidently adopting it. You can read about a few notable examples of such projects in the previous blog post, Productive Server-Side Development With Kotlin: Stories From The Industry

Continue ReadingServer-Side Development with Kotlin: Frameworks and Libraries

Productive Server-Side Development With Kotlin: Stories From The Industry

Kotlin was created as an alternative to Java, meaning that its application area within the JVM ecosystem was meant to be the same as Java’s. Obviously, this includes server-side development.

Kotlin has experienced immense growth in the Android ecosystem in recent years. The adoption of Kotlin for server-side development is growing steadily as well. However, the question we often get from companies considering adopting Kotlin for server-side development is “Who else is using Kotlin for this?”.

Companies want to be sure that they are making the right decision when choosing technologies. They are looking for confirmation that other companies are successfully employing these technologies for the same intended purpose.

In this post, we would like to briefly highlight a few companies that have adopted Kotin for server-side development. We hope that this will help you make the decision if you are considering adopting Kotlin for the same purposes.

The blog post is based on the presentation content from Kotlin 1.4 Online Event. You can watch the full video at our YouTube channel.

Why Kotlin?

We are constantly talking to developers who use Kotlin, and we have learned about quite a few companies, big and small, that use Kotlin for server-side development. We’re always interested in finding out why companies are choosing Kotlin, and what benefits they gain from it.

There are a lot of nice features in Kotlin, but we’ll highlight those that the users we’ve spoken with liked the most:

  • Concise syntax. The expressiveness of the language results in concise code. The less code there is to write, the fewer bugs sneak into the final application, and the more maintainable the final code is.
  • Null-safety. This is the Kotlin feature that developers like the most. Kotlin’s type system is aimed at eliminating the risk of null references from code, also known as The Billion Dollar Mistake. This extra safety feature is built into Kotlin’s compiler, resulting in fewer issues with dereferencing null values.
  • Java-interoperability. Interoperability with the host platform is a serious productivity booster! With Kotlin, you can leverage the Java ecosystem, with all its frameworks and libraries. It is also possible to introduce Kotlin gradually into an existing Java project without having to convert all the Java code to Kotlin.
  • Kotlin Coroutines. These offer an easy way to master asynchronous code with an imperative programming model. Coroutines are especially useful for developing high-load server-side applications with a lot of IO operations, as they save a lot of system resources. The fact that Coroutines support was added to the Spring Framework made it even easier to take advantage of this feature for server-side developers.
  • Kotlin Multiplatform. With Kotlin, developers can target different platforms – JVM, JavaScript, Android, iOS, and even native applications. The ability to share code between different applications running on different platforms turned out to be quite a useful feature.

Now let’s take a look at a few examples where Kotlin takes development to the next level.

JetBrains Space: extreme code reuse

You won’t be surprised to learn that we use Kotlin at JetBrains. We use it not only for tools but also for services. JetBrains Space, a team collaboration platform announced at KotlinConf 2019, is built with Kotlin and the Ktor framework. Space uses Kotlin for everything: server-side services that run on JVM, an Android application, an iOS application, the web application, and an IDE plugin.

Thanks to Kotlin Multiplatform, a large portion of the code is shared between all these different applications. In addition to sharing the data model across the UI and server-side code, Space also shares the view model, validation logic, and common libraries. The UI components are platform-specific, however, so interoperability is also important for each platform that Kotlin code targets.

Kotlin Multiplatform

Just to give you an idea of how Kotlin supports development for multiple platforms, let’s take a look at the following example. Suppose there’s a data class that we want to use for multiple platforms (JVM, JavaScript, iOS):

class Holiday {
   val name: String,
   val date: LocalDate
}

The String class belongs to Kotlin’s standard library but not LocalDate. We can specify what class should be used as LocalDate for each platform that the application targets. To do this, in the common module that is shared across different platforms, we declare the LocalDate class by using the expect keyword, assuming that the different modules will provide the real implementation. The actual keyword indicates what type should be used in the platform-specific code:

//commonMain
expect class LocalDate()

//jvmMain
actual typealias LocalDate = org.joda.time.LocalDate

//jsMain
actual typealias LocalDate = Moment

//iosMain
actual typealias LocalDate = NSDate

The code that is not platform-specific can be written just once, in the common module of the project. The common code is then reused by the different modules that target specific platforms.

Kotlin support for multiplatform development is especially popular among mobile developers, who use it to share code between Android and iOS applications. You can learn more about this on the Kotlin Multiplatform Mobile website, and you can read about other companies’ experiences with the technology.

Jira Software: Microservices with Kotlin and Spring Boot

Another interesting example is Atlassian’s Jira. Kotlin is used at Atlassian for developing Jira Software cloud products.

Jira used to be a standalone monolithic Java application that users installed on their servers. However, with the introduction of Jira cloud, the need emerged to decompose the application into multiple services in order to scale it better.

The move to the cloud created an opportunity to update the technology stack, and this is how Kotlin came into the picture. The developers felt happy adopting the language, and with happiness comes a productivity boost! Now they use Kotlin with Spring Boot to implement microservices that power critical user experiences. Kotlin and Spring are used across the entire Jira cloud family — in Jira Software, Jira Service Desk, and Jira Core.

Adobe: going lock-free with Kotlin coroutines for high-load services

The Adobe Experience Platform team shared their thoughts on why they prefer Kotlin for server-side development.

They point out that application backends have evolved from monolithic web containers into a distributed mesh of data-driven applications. These applications have to process a lot of data, receive and send messages, and everything is latency-critical.

In their article, they list the key benefits of using Kotlin for server-side development. Support for asynchronous programming is cited as the most valuable Kotlin feature. Kotlin coroutines are described as “easy to learn”, with the resulting code being straightforward and easy to maintain.

“With Kotlin, we can write code in ‘direct style’ that reads almost like blocking, imperative code.”

The applications are quite I/O-heavy, having to rely on external services like queues, various databases, and other services. And these network calls can easily degrade application throughput. Therefore, Kotlin coroutines were immediately appealing for their use case. Going asynchronous improves overall throughput and consequently saves hardware resources.

The other benefits are the key language features in Kotlin: data classes, the sound type system, null safety, and support for functional programming. Kotlin’s flexible syntax makes it easy to create an internal DSL. This is something that appears to have been quite useful for Adobe engineers, too. They also wrote an article about their experience of building a DSL with Kotlin.

Expedia Group: building GraphQL APIs with Kotlin

Expedia adopted Kotlin because of its null-safety compiler guarantees, the conciseness of the language, and its full Java interoperability. Interoperability with Java made a gradual Kotlin integration possible without having to fully rewrite applications. Java interoperability also allowed Expedia to easily integrate Kotlin applications with Java libraries and fully utilize the existing JVM ecosystem.

Kotlin coroutines were a critical factor in the wide adoption of the language. They allow developers to write fully asynchronous code in an imperative way, which leads to more readable and maintainable code. The Spring Framework is used heavily at Expedia, and starting with version 5.2 it introduced interoperability between WebFlux and coroutines. For the engineers at Expedia, this was a game changer that made it possible to leverage the Spring and Reactive stack in a more imperative way.

Recently, Expedia decided to move toward GraphQL and and build a single API gateway to power all frontend applications. To achieve this, they applied Kotlin’s powerful reflection library to generate the GraphQL schema directly from the source code. The resulting set of libraries, graphql-kotlin, turned out to be quite useful. They were open-sourced and are now hosted on GitHub.

At KotlinConf 2019, Dariusz Kuc and Guillaume Scheibel talked about how to utilize the power of Spring Boot together with graphql-kotlin. Here’s the video:

Summary

In this article we shared a few examples of Kotlin adoption for server-side development. At JetBrains, Adobe, Expedia, and Atlassian, Kotlin powers business critical applications that are highly sensitive to performance metrics. This shows that Kotlin is a mature programming language suitable for developing web applications and services.

Tell us your story!

We would love to hear about your experience with Kotlin for developing server-side applications and share your experience with the community!

Continue ReadingProductive Server-Side Development With Kotlin: Stories From The Industry

Productive Server-Side Development With Kotlin: Stories From The Industry

Kotlin was created as an alternative to Java, meaning that its application area within the JVM ecosystem was meant to be the same as Java’s. Obviously, this includes server-side development.

Kotlin has experienced immense growth in the Android ecosystem in recent years. The adoption of Kotlin for server-side development is growing steadily as well. However, the question we often get from companies considering adopting Kotlin for server-side development is “Who else is using Kotlin for this?”.

Companies want to be sure that they are making the right decision when choosing technologies. They are looking for confirmation that other companies are successfully employing these technologies for the same intended purpose.

In this post, we would like to briefly highlight a few companies that have adopted Kotin for server-side development. We hope that this will help you make the decision if you are considering adopting Kotlin for the same purposes.

The blog post is based on the presentation content from Kotlin 1.4 Online Event. You can watch the full video at our YouTube channel.

Why Kotlin?

We are constantly talking to developers who use Kotlin, and we have learned about quite a few companies, big and small, that use Kotlin for server-side development. We’re always interested in finding out why companies are choosing Kotlin, and what benefits they gain from it.

There are a lot of nice features in Kotlin, but we’ll highlight those that the users we’ve spoken with liked the most:

  • Concise syntax. The expressiveness of the language results in concise code. The less code there is to write, the fewer bugs sneak into the final application, and the more maintainable the final code is.
  • Null-safety. This is the Kotlin feature that developers like the most. Kotlin’s type system is aimed at eliminating the risk of null references from code, also known as The Billion Dollar Mistake. This extra safety feature is built into Kotlin’s compiler, resulting in fewer issues with dereferencing null values.
  • Java-interoperability. Interoperability with the host platform is a serious productivity booster! With Kotlin, you can leverage the Java ecosystem, with all its frameworks and libraries. It is also possible to introduce Kotlin gradually into an existing Java project without having to convert all the Java code to Kotlin.
  • Kotlin Coroutines. These offer an easy way to master asynchronous code with an imperative programming model. Coroutines are especially useful for developing high-load server-side applications with a lot of IO operations, as they save a lot of system resources. The fact that Coroutines support was added to the Spring Framework made it even easier to take advantage of this feature for server-side developers.
  • Kotlin Multiplatform. With Kotlin, developers can target different platforms – JVM, JavaScript, Android, iOS, and even native applications. The ability to share code between different applications running on different platforms turned out to be quite a useful feature.

Now let’s take a look at a few examples where Kotlin takes development to the next level.

JetBrains Space: extreme code reuse

You won’t be surprised to learn that we use Kotlin at JetBrains. We use it not only for tools but also for services. JetBrains Space, a team collaboration platform announced at KotlinConf 2019, is built with Kotlin and the Ktor framework. Space uses Kotlin for everything: server-side services that run on JVM, an Android application, an iOS application, the web application, and an IDE plugin.

Thanks to Kotlin Multiplatform, a large portion of the code is shared between all these different applications. In addition to sharing the data model across the UI and server-side code, Space also shares the view model, validation logic, and common libraries. The UI components are platform-specific, however, so interoperability is also important for each platform that Kotlin code targets.

Kotlin Multiplatform

Just to give you an idea of how Kotlin supports development for multiple platforms, let’s take a look at the following example. Suppose there’s a data class that we want to use for multiple platforms (JVM, JavaScript, iOS):

class Holiday {
   val name: String,
   val date: LocalDate
}

The String class belongs to Kotlin’s standard library but not LocalDate. We can specify what class should be used as LocalDate for each platform that the application targets. To do this, in the common module that is shared across different platforms, we declare the LocalDate class by using the expect keyword, assuming that the different modules will provide the real implementation. The actual keyword indicates what type should be used in the platform-specific code:

//commonMain
expect class LocalDate()

//jvmMain
actual typealias LocalDate = org.joda.time.LocalDate

//jsMain
actual typealias LocalDate = Moment

//iosMain
actual typealias LocalDate = NSDate

The code that is not platform-specific can be written just once, in the common module of the project. The common code is then reused by the different modules that target specific platforms.

Kotlin support for multiplatform development is especially popular among mobile developers, who use it to share code between Android and iOS applications. You can learn more about this on the Kotlin Multiplatform Mobile website, and you can read about other companies’ experiences with the technology.

Jira Software: Microservices with Kotlin and Spring Boot

Another interesting example is Atlassian’s Jira. Kotlin is used at Atlassian for developing Jira Software cloud products.

Jira used to be a standalone monolithic Java application that users installed on their servers. However, with the introduction of Jira cloud, the need emerged to decompose the application into multiple services in order to scale it better.

The move to the cloud created an opportunity to update the technology stack, and this is how Kotlin came into the picture. The developers felt happy adopting the language, and with happiness comes a productivity boost! Now they use Kotlin with Spring Boot to implement microservices that power critical user experiences. Kotlin and Spring are used across the entire Jira cloud family — in Jira Software, Jira Service Desk, and Jira Core.

Adobe: going lock-free with Kotlin coroutines for high-load services

The Adobe Experience Platform team shared their thoughts on why they prefer Kotlin for server-side development.

They point out that application backends have evolved from monolithic web containers into a distributed mesh of data-driven applications. These applications have to process a lot of data, receive and send messages, and everything is latency-critical.

In their article, they list the key benefits of using Kotlin for server-side development. Support for asynchronous programming is cited as the most valuable Kotlin feature. Kotlin coroutines are described as “easy to learn”, with the resulting code being straightforward and easy to maintain.

“With Kotlin, we can write code in ‘direct style’ that reads almost like blocking, imperative code.”

The applications are quite I/O-heavy, having to rely on external services like queues, various databases, and other services. And these network calls can easily degrade application throughput. Therefore, Kotlin coroutines were immediately appealing for their use case. Going asynchronous improves overall throughput and consequently saves hardware resources.

The other benefits are the key language features in Kotlin: data classes, the sound type system, null safety, and support for functional programming. Kotlin’s flexible syntax makes it easy to create an internal DSL. This is something that appears to have been quite useful for Adobe engineers, too. They also wrote an article about their experience of building a DSL with Kotlin.

Expedia Group: building GraphQL APIs with Kotlin

Expedia adopted Kotlin because of its null-safety compiler guarantees, the conciseness of the language, and its full Java interoperability. Interoperability with Java made a gradual Kotlin integration possible without having to fully rewrite applications. Java interoperability also allowed Expedia to easily integrate Kotlin applications with Java libraries and fully utilize the existing JVM ecosystem.

Kotlin coroutines were a critical factor in the wide adoption of the language. They allow developers to write fully asynchronous code in an imperative way, which leads to more readable and maintainable code. The Spring Framework is used heavily at Expedia, and starting with version 5.2 it introduced interoperability between WebFlux and coroutines. For the engineers at Expedia, this was a game changer that made it possible to leverage the Spring and Reactive stack in a more imperative way.

Recently, Expedia decided to move toward GraphQL and and build a single API gateway to power all frontend applications. To achieve this, they applied Kotlin’s powerful reflection library to generate the GraphQL schema directly from the source code. The resulting set of libraries, graphql-kotlin, turned out to be quite useful. They were open-sourced and are now hosted on GitHub.

At KotlinConf 2019, Dariusz Kuc and Guillaume Scheibel talked about how to utilize the power of Spring Boot together with graphql-kotlin. Here’s the video:

Summary

In this article we shared a few examples of Kotlin adoption for server-side development. At JetBrains, Adobe, Expedia, and Atlassian, Kotlin powers business critical applications that are highly sensitive to performance metrics. This shows that Kotlin is a mature programming language suitable for developing web applications and services.

Tell us your story!

We would love to hear about your experience with Kotlin for developing server-side applications and share your experience with the community!

Continue ReadingProductive Server-Side Development With Kotlin: Stories From The Industry

Productive Server-Side Development With Kotlin: Stories From The Industry

Kotlin was created as an alternative to Java, meaning that its application area within the JVM ecosystem was meant to be the same as Java’s. Obviously, this includes server-side development.

Kotlin has experienced immense growth in the Android ecosystem in recent years. The adoption of Kotlin for server-side development is growing steadily as well. However, the question we often get from companies considering adopting Kotlin for server-side development is “Who else is using Kotlin for this?”.

Companies want to be sure that they are making the right decision when choosing technologies. They are looking for confirmation that other companies are successfully employing these technologies for the same intended purpose.

In this post, we would like to briefly highlight a few companies that have adopted Kotin for server-side development. We hope that this will help you make the decision if you are considering adopting Kotlin for the same purposes.

The blog post is based on the presentation content from Kotlin 1.4 Online Event. You can watch the full video at our YouTube channel.

Why Kotlin?

We are constantly talking to developers who use Kotlin, and we have learned about quite a few companies, big and small, that use Kotlin for server-side development. We’re always interested in finding out why companies are choosing Kotlin, and what benefits they gain from it.

There are a lot of nice features in Kotlin, but we’ll highlight those that the users we’ve spoken with liked the most:

  • Concise syntax. The expressiveness of the language results in concise code. The less code there is to write, the fewer bugs sneak into the final application, and the more maintainable the final code is.
  • Null-safety. This is the Kotlin feature that developers like the most. Kotlin’s type system is aimed at eliminating the risk of null references from code, also known as The Billion Dollar Mistake. This extra safety feature is built into Kotlin’s compiler, resulting in fewer issues with dereferencing null values.
  • Java-interoperability. Interoperability with the host platform is a serious productivity booster! With Kotlin, you can leverage the Java ecosystem, with all its frameworks and libraries. It is also possible to introduce Kotlin gradually into an existing Java project without having to convert all the Java code to Kotlin.
  • Kotlin Coroutines. These offer an easy way to master asynchronous code with an imperative programming model. Coroutines are especially useful for developing high-load server-side applications with a lot of IO operations, as they save a lot of system resources. The fact that Coroutines support was added to the Spring Framework made it even easier to take advantage of this feature for server-side developers.
  • Kotlin Multiplatform. With Kotlin, developers can target different platforms – JVM, JavaScript, Android, iOS, and even native applications. The ability to share code between different applications running on different platforms turned out to be quite a useful feature.

Now let’s take a look at a few examples where Kotlin takes development to the next level.

JetBrains Space: extreme code reuse

You won’t be surprised to learn that we use Kotlin at JetBrains. We use it not only for tools but also for services. JetBrains Space, a team collaboration platform announced at KotlinConf 2019, is built with Kotlin and the Ktor framework. Space uses Kotlin for everything: server-side services that run on JVM, an Android application, an iOS application, the web application, and an IDE plugin.

Thanks to Kotlin Multiplatform, a large portion of the code is shared between all these different applications. In addition to sharing the data model across the UI and server-side code, Space also shares the view model, validation logic, and common libraries. The UI components are platform-specific, however, so interoperability is also important for each platform that Kotlin code targets.

Kotlin Multiplatform

Just to give you an idea of how Kotlin supports development for multiple platforms, let’s take a look at the following example. Suppose there’s a data class that we want to use for multiple platforms (JVM, JavaScript, iOS):

class Holiday {
   val name: String,
   val date: LocalDate
}

The String class belongs to Kotlin’s standard library but not LocalDate. We can specify what class should be used as LocalDate for each platform that the application targets. To do this, in the common module that is shared across different platforms, we declare the LocalDate class by using the expect keyword, assuming that the different modules will provide the real implementation. The actual keyword indicates what type should be used in the platform-specific code:

//commonMain
expect class LocalDate()

//jvmMain
actual typealias LocalDate = org.joda.time.LocalDate

//jsMain
actual typealias LocalDate = Moment

//iosMain
actual typealias LocalDate = NSDate

The code that is not platform-specific can be written just once, in the common module of the project. The common code is then reused by the different modules that target specific platforms.

Kotlin support for multiplatform development is especially popular among mobile developers, who use it to share code between Android and iOS applications. You can learn more about this on the Kotlin Multiplatform Mobile website, and you can read about other companies’ experiences with the technology.

Jira Software: Microservices with Kotlin and Spring Boot

Another interesting example is Atlassian’s Jira. Kotlin is used at Atlassian for developing Jira Software cloud products.

Jira used to be a standalone monolithic Java application that users installed on their servers. However, with the introduction of Jira cloud, the need emerged to decompose the application into multiple services in order to scale it better.

The move to the cloud created an opportunity to update the technology stack, and this is how Kotlin came into the picture. The developers felt happy adopting the language, and with happiness comes a productivity boost! Now they use Kotlin with Spring Boot to implement microservices that power critical user experiences. Kotlin and Spring are used across the entire Jira cloud family — in Jira Software, Jira Service Desk, and Jira Core.

Adobe: going lock-free with Kotlin coroutines for high-load services

The Adobe Experience Platform team shared their thoughts on why they prefer Kotlin for server-side development.

They point out that application backends have evolved from monolithic web containers into a distributed mesh of data-driven applications. These applications have to process a lot of data, receive and send messages, and everything is latency-critical.

In their article, they list the key benefits of using Kotlin for server-side development. Support for asynchronous programming is cited as the most valuable Kotlin feature. Kotlin coroutines are described as “easy to learn”, with the resulting code being straightforward and easy to maintain.

“With Kotlin, we can write code in ‘direct style’ that reads almost like blocking, imperative code.”

The applications are quite I/O-heavy, having to rely on external services like queues, various databases, and other services. And these network calls can easily degrade application throughput. Therefore, Kotlin coroutines were immediately appealing for their use case. Going asynchronous improves overall throughput and consequently saves hardware resources.

The other benefits are the key language features in Kotlin: data classes, the sound type system, null safety, and support for functional programming. Kotlin’s flexible syntax makes it easy to create an internal DSL. This is something that appears to have been quite useful for Adobe engineers, too. They also wrote an article about their experience of building a DSL with Kotlin.

Expedia Group: building GraphQL APIs with Kotlin

Expedia adopted Kotlin because of its null-safety compiler guarantees, the conciseness of the language, and its full Java interoperability. Interoperability with Java made a gradual Kotlin integration possible without having to fully rewrite applications. Java interoperability also allowed Expedia to easily integrate Kotlin applications with Java libraries and fully utilize the existing JVM ecosystem.

Kotlin coroutines were a critical factor in the wide adoption of the language. They allow developers to write fully asynchronous code in an imperative way, which leads to more readable and maintainable code. The Spring Framework is used heavily at Expedia, and starting with version 5.2 it introduced interoperability between WebFlux and coroutines. For the engineers at Expedia, this was a game changer that made it possible to leverage the Spring and Reactive stack in a more imperative way.

Recently, Expedia decided to move toward GraphQL and and build a single API gateway to power all frontend applications. To achieve this, they applied Kotlin’s powerful reflection library to generate the GraphQL schema directly from the source code. The resulting set of libraries, graphql-kotlin, turned out to be quite useful. They were open-sourced and are now hosted on GitHub.

At KotlinConf 2019, Dariusz Kuc and Guillaume Scheibel talked about how to utilize the power of Spring Boot together with graphql-kotlin. Here’s the video:

Summary

In this article we shared a few examples of Kotlin adoption for server-side development. At JetBrains, Adobe, Expedia, and Atlassian, Kotlin powers business critical applications that are highly sensitive to performance metrics. This shows that Kotlin is a mature programming language suitable for developing web applications and services.

Tell us your story!

We would love to hear about your experience with Kotlin for developing server-side applications and share your experience with the community!

Continue ReadingProductive Server-Side Development With Kotlin: Stories From The Industry

Productive Server-Side Development With Kotlin: Stories From The Industry

Kotlin was created as an alternative to Java, meaning that its application area within the JVM ecosystem was meant to be the same as Java’s. Obviously, this includes server-side development.

Kotlin has experienced immense growth in the Android ecosystem in recent years. The adoption of Kotlin for server-side development is growing steadily as well. However, the question we often get from companies considering adopting Kotlin for server-side development is “Who else is using Kotlin for this?”.

Companies want to be sure that they are making the right decision when choosing technologies. They are looking for confirmation that other companies are successfully employing these technologies for the same intended purpose.

In this post, we would like to briefly highlight a few companies that have adopted Kotin for server-side development. We hope that this will help you make the decision if you are considering adopting Kotlin for the same purposes.

The blog post is based on the presentation content from Kotlin 1.4 Online Event. You can watch the full video at our YouTube channel.

Why Kotlin?

We are constantly talking to developers who use Kotlin, and we have learned about quite a few companies, big and small, that use Kotlin for server-side development. We’re always interested in finding out why companies are choosing Kotlin, and what benefits they gain from it.

There are a lot of nice features in Kotlin, but we’ll highlight those that the users we’ve spoken with liked the most:

  • Concise syntax. The expressiveness of the language results in concise code. The less code there is to write, the fewer bugs sneak into the final application, and the more maintainable the final code is.
  • Null-safety. This is the Kotlin feature that developers like the most. Kotlin’s type system is aimed at eliminating the risk of null references from code, also known as The Billion Dollar Mistake. This extra safety feature is built into Kotlin’s compiler, resulting in fewer issues with dereferencing null values.
  • Java-interoperability. Interoperability with the host platform is a serious productivity booster! With Kotlin, you can leverage the Java ecosystem, with all its frameworks and libraries. It is also possible to introduce Kotlin gradually into an existing Java project without having to convert all the Java code to Kotlin.
  • Kotlin Coroutines. These offer an easy way to master asynchronous code with an imperative programming model. Coroutines are especially useful for developing high-load server-side applications with a lot of IO operations, as they save a lot of system resources. The fact that Coroutines support was added to the Spring Framework made it even easier to take advantage of this feature for server-side developers.
  • Kotlin Multiplatform. With Kotlin, developers can target different platforms – JVM, JavaScript, Android, iOS, and even native applications. The ability to share code between different applications running on different platforms turned out to be quite a useful feature.

Now let’s take a look at a few examples where Kotlin takes development to the next level.

JetBrains Space: extreme code reuse

You won’t be surprised to learn that we use Kotlin at JetBrains. We use it not only for tools but also for services. JetBrains Space, a team collaboration platform announced at KotlinConf 2019, is built with Kotlin and the Ktor framework. Space uses Kotlin for everything: server-side services that run on JVM, an Android application, an iOS application, the web application, and an IDE plugin.

Thanks to Kotlin Multiplatform, a large portion of the code is shared between all these different applications. In addition to sharing the data model across the UI and server-side code, Space also shares the view model, validation logic, and common libraries. The UI components are platform-specific, however, so interoperability is also important for each platform that Kotlin code targets.

Kotlin Multiplatform

Just to give you an idea of how Kotlin supports development for multiple platforms, let’s take a look at the following example. Suppose there’s a data class that we want to use for multiple platforms (JVM, JavaScript, iOS):

class Holiday {
   val name: String,
   val date: LocalDate
}

The String class belongs to Kotlin’s standard library but not LocalDate. We can specify what class should be used as LocalDate for each platform that the application targets. To do this, in the common module that is shared across different platforms, we declare the LocalDate class by using the expect keyword, assuming that the different modules will provide the real implementation. The actual keyword indicates what type should be used in the platform-specific code:

//commonMain
expect class LocalDate()

//jvmMain
actual typealias LocalDate = org.joda.time.LocalDate

//jsMain
actual typealias LocalDate = Moment

//iosMain
actual typealias LocalDate = NSDate

The code that is not platform-specific can be written just once, in the common module of the project. The common code is then reused by the different modules that target specific platforms.

Kotlin support for multiplatform development is especially popular among mobile developers, who use it to share code between Android and iOS applications. You can learn more about this on the Kotlin Multiplatform Mobile website, and you can read about other companies’ experiences with the technology.

Jira Software: Microservices with Kotlin and Spring Boot

Another interesting example is Atlassian’s Jira. Kotlin is used at Atlassian for developing Jira Software cloud products.

Jira used to be a standalone monolithic Java application that users installed on their servers. However, with the introduction of Jira cloud, the need emerged to decompose the application into multiple services in order to scale it better.

The move to the cloud created an opportunity to update the technology stack, and this is how Kotlin came into the picture. The developers felt happy adopting the language, and with happiness comes a productivity boost! Now they use Kotlin with Spring Boot to implement microservices that power critical user experiences. Kotlin and Spring are used across the entire Jira cloud family — in Jira Software, Jira Service Desk, and Jira Core.

Adobe: going lock-free with Kotlin coroutines for high-load services

The Adobe Experience Platform team shared their thoughts on why they prefer Kotlin for server-side development.

They point out that application backends have evolved from monolithic web containers into a distributed mesh of data-driven applications. These applications have to process a lot of data, receive and send messages, and everything is latency-critical.

In their article, they list the key benefits of using Kotlin for server-side development. Support for asynchronous programming is cited as the most valuable Kotlin feature. Kotlin coroutines are described as “easy to learn”, with the resulting code being straightforward and easy to maintain.

“With Kotlin, we can write code in ‘direct style’ that reads almost like blocking, imperative code.”

The applications are quite I/O-heavy, having to rely on external services like queues, various databases, and other services. And these network calls can easily degrade application throughput. Therefore, Kotlin coroutines were immediately appealing for their use case. Going asynchronous improves overall throughput and consequently saves hardware resources.

The other benefits are the key language features in Kotlin: data classes, the sound type system, null safety, and support for functional programming. Kotlin’s flexible syntax makes it easy to create an internal DSL. This is something that appears to have been quite useful for Adobe engineers, too. They also wrote an article about their experience of building a DSL with Kotlin.

Expedia Group: building GraphQL APIs with Kotlin

Expedia adopted Kotlin because of its null-safety compiler guarantees, the conciseness of the language, and its full Java interoperability. Interoperability with Java made a gradual Kotlin integration possible without having to fully rewrite applications. Java interoperability also allowed Expedia to easily integrate Kotlin applications with Java libraries and fully utilize the existing JVM ecosystem.

Kotlin coroutines were a critical factor in the wide adoption of the language. They allow developers to write fully asynchronous code in an imperative way, which leads to more readable and maintainable code. The Spring Framework is used heavily at Expedia, and starting with version 5.2 it introduced interoperability between WebFlux and coroutines. For the engineers at Expedia, this was a game changer that made it possible to leverage the Spring and Reactive stack in a more imperative way.

Recently, Expedia decided to move toward GraphQL and and build a single API gateway to power all frontend applications. To achieve this, they applied Kotlin’s powerful reflection library to generate the GraphQL schema directly from the source code. The resulting set of libraries, graphql-kotlin, turned out to be quite useful. They were open-sourced and are now hosted on GitHub.

At KotlinConf 2019, Dariusz Kuc and Guillaume Scheibel talked about how to utilize the power of Spring Boot together with graphql-kotlin. Here’s the video:

Summary

In this article we shared a few examples of Kotlin adoption for server-side development. At JetBrains, Adobe, Expedia, and Atlassian, Kotlin powers business critical applications that are highly sensitive to performance metrics. This shows that Kotlin is a mature programming language suitable for developing web applications and services.

Tell us your story!

We would love to hear about your experience with Kotlin for developing server-side applications and share your experience with the community!

Continue ReadingProductive Server-Side Development With Kotlin: Stories From The Industry

End of content

No more pages to load