Kotlin Overview

What is Kotlin?

Kotlin is a new JVM based programming language that was fisrt conceived and developed by Jetbrains. By design, Kotlin is a pragmatic, concise, safe and has a focus on interoperability with existing java code.

Main Features of Kotlin.

1.It can be used to build anything,anywhere.

Just like java, Kotlin is a powerful language that can be used to build various types of applications on various hardware platforms. You can use Kotlin to make:

(a). Server side web apps

Applications that run on the server. These type of apps can be:

  • Web apps that return html pages.
  • Web apps that expose functionalities via XML or JSON APIs over HTTP

(b). Mobile Apps

Mobile applications that run anywhere java can run e.g

  • Native Android apps build purely on Kotlin.
  • IOS apps using Intel MultiOS engine.

(c). Desktop Applications

Kotlin can also be used to make desktop softwares like school management systems etc.

  • You can even use GUI toolkits like JavaFX.

(d). Client side Web apps.

Kotlin can also be used to create web apps that run in the browser. Kotlin can be compiled to Javascript that runs in the browser.

  • This feature is still experimental and under development.

Clearly, Kotlin is a powerful and general purpose language that can run in many platforms out there.

2. It's a statically typed language.

In the programming domain, whenever we talk about static typing, we basically mean that the compiler will infer every expression and variables in your program at compile time as opposed to at runtime. The compiler can ensure that you have assigned the correct data types to variables and that your methods and variables are actually defined in their classes.
In statically typed languages, common mistakes like spelling and other syntax errors can be detected before the program is actually run.
Other statically typed languages include java and C++. However, unlike these languages, Kotlin doesn't force you to specify the variable types explicitly. The compiler will automatically infer the data type of variable based on the data you assign.

var name="Oclemy"

In the above example, the compiler will for instance determine that we have used a String data type without us specifying it explicitly. This ability is calledtype inference.

Statically typed languages have the advantage over dynamically typed languages with regards to performance, reliability and better tool support.

3. Supports major programming styles.

The two main programming paradigms currently are object oriented programming style and functional programming style. Objects are the first class citizens in Object Oriented programming while Functions are the first class citizens in Functional Programming paradigm.
Majority of people are probably familiar with OOP unlike Functional Programming, however, functional programmer has also some benefits especially in some given scenarios.
The two main concepts to grasp in functional programming are:

  • Functions can beused as values in functional programming paradigm.
    Thus they can be passed as parameters, assigned to variables and returned by other functions.
  • Functions are immutable objects in Functional programming as opposed to Objects in OOP. Thus we have a guarantee that their state cannot be changed. This is quite useful in asynchronous programming.

4. Kotlin is Free.

Yes, free as in free, you don't have to pay any money to use Kotlin. It's also open source and available in github under the Apache2 license.