Programming Languages Section

Kotlin

Card image
Post by Amina Delali, September 18th,2021

Some Facts

Kotlin is a modern programming language, open source and statically typed. It targets Java Virtual machine, Android and javascript. It is a general programming language with functional features, used by Google, Amazon , Netflix and many more companies. 

It combines object oriented and function programming features. It allows fast and safe development for android apps. So Kotlin permits you to write code that is expressive and concise, safe, and interoperable. Even if a big part of android professional developers use Kotlin to develop android apps, it also can be used for server side, web, native and desktop development.



How to install it

  • on Windows:

    To install Kotlin on Windows, you can follow these steps:

    1. download the Kotlin compiler from as a zip archive from the assets sections of this Github releases page.
    2. extract the archive
    3. define a new KOTLIN_HOME environment variable and add it to the PATH environment variable.
    4. test the compiler from the command prompt using the following command:

    kotlinc -version
    If everything is ok, you should see the version of Kotlin printed on the command prompt.  For more details about the installation check the page available in this link.

  • on ubuntu :
    1. Install java, for example, you can install the default-jdk
      $ sudo apt install default-jdk:
    2. Install Kotlin
      $ sudo snap install --classic kotlin
    3. check the installation by running the following command:
    4. kotlin -version

In the video below, the details of the installation of the Kotlinlanguage on Ubuntu.

The Hello World Example

To test Kotlin code on Ubuntu, do the following:

  1. Create a new file in the Home folder, and save it under the name hello.kt
  2. In the hello.kt file, write and save the following code:
    fun main (argsArray<String>){
        println("Hello World!")
    }
  3. compile the code to the corresponding class file (it will generate the file HelloKt.class): kotlinc hello.kt
  4. run your code from the generated HelloKt.class file: kotlin helloKt


Additional Information

Something to say ?

If you want to add something about the Kotlin language or about this post, please feel free to do it by commenting below 🙂 .