My journey with Kotlin

An Introduction

I am a backend developer that uses Python, and recently I started to look for another programming language to learn. I read about JavaScript, Ruby, Go, Rust, C++, and Java. The latter was the language that I was curious about because there are many resources about Java, and it has a large community. But when I was looking for Java jobs posts, many of them say something like this 'Java/Kotlin developer'. So, what is Kotlin?

Kotlin is a Russian island near St. Petersburg. This article is not about the island but the programming language that shares its name. Kotlin is a cross-platform, statically typed, general-purpose programming language with type inference. It is designed to interoperate fully with Java; and the JVM(Java Virtual Machine). It is compatible with JavaScript and enables you to develop client-side web applications and run them in a browser. Also, you can use Java's frameworks like Spring for web development with Kotlin; and write code to make Android Apps with Android Studio. You can migrate Java code to Kotlin and vice-versa. There are many characteristics it shares with Java; both have the name of an island.

One of the interesting things that I found about Kotlin is the concept of basic literal; it was interesting for me because, in this programming language, "A" is not the same as 'A'; the first one is a String, the second is a character. A character can represent a digit, a letter, or another symbol. To write a single character, we wrap a symbol in single quotes as follows: 'A', 'B', '1', '2', '&'. It is incorrect to write '123', '32' because these literals have more than one character.

The string represents text information. To write a string we wrap characters in double quotes like "Hello World"; "2", "Kotlin" . There are three basic literals. The last one, integers numbers, are the numbers we use to count things in the real world, like 1, 2, 10, 200, 4000. If an integer value contains many digits, we can add underscores to divide the digits into blocks to make it more readable: for example, 3_000_000, 100_000, underscores can't appear at the start or the end of the number. If you write 50 or 250 you get an error.

Examples:

  • 200 is an integer number, and "200" is a string.

  • 'B' is a character, and "B" is a string.

  • '4' is a character, and 4 is an integer number.

  • If you write _100 or 200000, you get an error.

    If you are interested to learn Kotlin, there is a Kotlin Basic free course in JetBrains Academy web page, also in the documentation page there are more resources.

Unfortunately, I'm not a Kotlin expert. I started to learn Kotlin a week ago if you read this article today (August 21, 2021), but fortunately, I'm not a Kotlin expert; if you haven't any idea about Kotlin and want to learn it, you are not alone.

References: