Master any programming language fast

The Kotlin Programming Language

Share
Like SyntaxCorect.com on Facebook
Be the first to rate this article

Kotlin is a programing language created by JetBrains, the company who develops one of the best IDEs of the world. With Google adopting the language as a new official language for Android development, and many others jumping on the Kotlin train, let's see together why we have here a language well worth the attention of any serious developer

Introduction

Kotlin is a computer programing language first appeared on the scene 13 years ago (2011). It is a multi-paradigm, statically typed (with extended type inference), object-oriented (class-based), structured, imperative, generic, reflective, concurrent, functional and procedural programming language with automatic memory management whose main purposes are:

  1. propose itself as a successor to Java introducing to developers a new, better and more productive language which is 100% compatible with Java but offers more type-safe constructs and allows more concise sources and expressive code also allowing the creation and inclusion in source codes of DSL sources;
  2. offer to programmers a single programming language to develop software for many targets. In fact Kotlin programs can be compiled to: JVM, Android, JavaScript and Native, with Native at the moment supporting:
    • Windows (x86_64 only)
    • Linux (x86_64, arm32, MIPS, MIPS little endian)
    • MacOS (x86_64)
    • iOS (arm64 only)
    • Android (arm32 and arm64)
    • WebAssembly (wasm32 only)

First glance at the code

Example: The classic "Hello world" program written in Kotlin:

Main features of Kotlin

Technical features

Statically typed (with extended type inference)

From a programmer point of view in Kotlin everything is an object. In fact internally some of the types can have a special representation like numbers, characters and booleans. Kotlin basic types are: numbers, characters, booleans, arrays, and strings.

Table: Kotlin basic data types

Type Notes
Double 64 bits
Float 32 bits
Long 64 bits
Int 32 bits
Short 16 bits
Byte 8 bits
Char Characters cannot be treated as numbers
Boolean true/false
String Strings are immutable. Elements of a string are characters

Object-oriented

Kotlin is object-oriented. It supports common object-oriented patterns like interfaces, classes and also supports generics. Multiple inheritance is not allowed, but the language has delegates.

Memory management

Memory management in Kotlin is automatic. Depending on the target of the compiled sources Kotlin uses the JVM garbage collector or the JavaScript one. For Native targets there is a buit-in automated reference counting with cycle collector garbage collector.

Concurrent

Kotlin offers complete support, libraries and language costructs to allow the concurrent execution of multiple threads within the same application.

Performance

Kotlin performcance depends on the target the sources are compiled to, JVM or JavaScript or Native. For Native targets the language is still a work in progress and its premature to make evaluations.

Other features

Free and open source

Kotlin is free and open source software licensed under the Apache 2 License.

Best books for learning Kotlin

For beginners

Programmer's Guide To Kotlin

No need to be an expert in Java or any other language

While Kotlin is similar to Java, and you can pick up much of the language as you go along, a deeper understanding will enable you to create better and more robust programs. As with all languages there are some... (continue on Amazon)

For experienced programmers

Kotlin in Action

By Kotlin team members Dmitry Jemerov and Svetlana Isakova

Written for experienced Java developers, this example-rich book goes further than most language books, covering interesting topics like building DSLs with natural language syntax. The authors are core Kotlin developers, so you can... (continue on Amazon)

Conclusion

If you like and feel comfortable with Kotlin's syntax you should jump on Kotlin and leaving Java right now. Seriously. Kotlin is exactly, from a features point of view, what every Java programmer has ever dreamt about. On the other side, if you still feel way more comfortable with the Java syntax, your search surely won't end with Kotlin. Many many many times it really seems that when someone wants to create a new language extending an old one the fevre to alter even what was already perfect plays a really big role. This is really a big pity.