Kotlin is a great fit for developing server-side
applications, allowing to write concise and expressive code while maintaining
full compatibility with existing Java-based technology stacks and a smooth
learning curve:
Expressiveness: Kotlin's innovative language features, such
as its support for type-safe builders and delegated properties, help build
powerful and easy-to-use abstractions.
Scalability: Kotlin's support for coroutines helps build
server-side applications that scale to massive numbers of clients with modest
hardware requirements.
Interoperability: Kotlin is fully compatible with all
Java-based frameworks, which lets you stay on your familiar technology stack
while reaping the benefits of a more modern language.
Migration: Kotlin supports gradual, step by step migration
of large codebases from Java to Kotlin. You can start writing new code in
Kotlin while keeping older parts of your system in Java.
Tooling: In addition to great IDE support in general, Kotlin
offers framework-specific tooling (for example, for Spring) in the plugin for
IntelliJ IDEA Ultimate.
Learning Curve: For a Java developer, getting started with
Kotlin is very easy. The automated Java to Kotlin converter included in the
Kotlin plugin helps with the first steps. Kotlin Koans offer
a guide through the key features of the language with a series of interactive
exercises.
Frameworks for Server-side Development with Kotlin
Spring makes use of Kotlin's language features to offer more
concise APIs, starting with version 5.0. The online project generator allows to
quickly generate a new project in Kotlin.
Vert.x, a framework for building reactive Web applications
on the JVM, offers dedicated support for Kotlin, including full documentation.
Ktor is a Kotlin-native Web framework built by JetBrains,
making use of coroutines for high scalability and offering an easy-to-use and
idiomatic API.
kotlinx.html is a DSL that can be used to build HTML in a
Web application. It serves as an alternative to traditional templating systems
such as JSP and FreeMarker.
The available options for persistence include direct JDBC
access, JPA, as well as using NoSQL databases through their Java drivers. For
JPA, the kotlin-jpa compiler plugin adapts Kotlin-compiled classes to the
requirements of the framework.
Deploying Kotlin Server-side Applications
Kotlin applications can be deployed into any host that
supports Java Web applications, including Amazon Web Services, Google Cloud
Platform and more.
This blog post offers a guide for deploying a Kotlin
application on Heroku.
AWS Labs provides a sample project showing the use of Kotlin
for writing AWS Lambda functions.
Users of Kotlin on the Server Side
Corda is an open-source distributed ledger platform,
supported by major banks, and built entirely in Kotlin.
JetBrains Account, the system responsible for the entire
license sales and validation process at JetBrains, is written in 100% Kotlin
and has been running in production since 2015 with no major issues.
Next Step
The Creating Web Applications with Http Servlets and
Creating a RESTful Web Service with Spring Boot tutorials show you how you can
build and run very small Web applications in Kotlin.
---------------------------------------------------------------------------------------------
Kotlin JavaScript Overview
Kotlin provides the ability to target JavaScript. It does so
by transpiling Kotlin to JavaScript. The current implementation targets
ECMAScript 5.1 but there are plans to eventually target ECMAScript 2015 also.
When you choose the JavaScript target, any Kotlin code that
is part of the project as well as the standard library that ships with Kotlin
is transpiled to JavaScript. However, this excludes the JDK and any JVM or Java
framework or library used. Any file that is not Kotlin will be ignored during
compilation.
The Kotlin compiler tries to comply with the following
goals:
Provide output that is optimal in size
Provide output that is readable JavaScript
Provide interoperability with existing module systems
Provide the same functionality in the standard library
whether targeting JavaScript or the JVM (to the largest possible degree).
How can it be used
You may want to compile Kotlin to JavaScript in the
following scenarios:
Creating Kotlin code that targets client-side JavaScript
Interacting with DOM elements. Kotlin provides a series of
statically typed interfaces to interact with the Document Object Model,
allowing creation and update of DOM elements.
Interacting with graphics such as WebGL. You can use Kotlin
to create graphical elements on a web page using WebGL.
Creating Kotlin code that targets server-side JavaScript
Working with server-side technology. You can use Kotlin to
interact with server-side JavaScript such as node.js
Kotlin can be used together with existing third-party
libraries and frameworks, such as JQuery or ReactJS. To access third-party
frameworks with a strongly-typed API, you can convert TypeScript definitions
from the Definitely Typed type definitions repository to Kotlin using the ts2kt
tool. Alternatively, you can use the dynamic type to access any framework
without strong typing.
Kotlin is also compatible with CommonJS, AMD and UMD, making
interaction with different module systems straightforward.
Getting Started with Kotlin to JavaScript
To find out how to start using Kotlin for JavaScript, please
google it.
Comments
Post a Comment
Please Comment if Any Query !!