Gentle Kotlin

Kotlin is a programming language that is both general purpose and fun. It is a great language to learn for those who are newer and just getting into programming as well as the more experienced.

Kotlin is great for Android, Web Development, Desktop GUI, your next side project or just learning how to program for the first time.


Table of Contents

  1. Installing Kotlin
  2. Hello World
  3. Variables, Values, and Basic Math
  4. Console input output
  5. Conditional Statements - if and when
  6. Loops
  7. Collections and Arrays
  8. Lambdas and Higher Order Functions
  9. Classes and Objects
  10. Data classes
  11. Inheritance
  12. Generics
  13. Intro to Coroutines
  14. Launch, Join, And Hundreds of Thousands of Jobs
  15. Web Services with Kotlin using Ktor (Installation)

A better Java

Kotlin was made to replace Java, perhaps one of the most widely used languages of today,by making a much simpler syntax as well as better support for more modern approaches of programming. The best part is that Kotlin and Java play together perfectly. So if you ever find a situation where you already have some Java code you can add newer Kotlin code with ease. If you are moving a project to Kotlin then you can update just one file at a time without breaking anything.

Java also has nearly 20-30 years of libraries, questions and answers, toolkits, and frameworks which port along to Kotlin because of this as well. So even if Kotlin feels newer, it has the mature support and tooling of a very well established language.

Inspired from the best

On top of improving Java, Kotlin also borrows some features from popular languages like Python, C#, Go, Ruby, C++, Rust etc. Not only does this make for a well designed language but also prepares you to learn those other popular languages and paradigms better.

Android

The biggest improvement of Kotlin is in Android. As Android quickly became the most popular phone OS used by billions, Android for Java had to grow and change with it, becoming an overall clunky mess with bolted on layers. Java was not meant to be a language for this. People were not happy, creating tools like React Native, Xamarin, Cordova, Dart/Flutter. Turns out just improving the language itself was all that was needed.

It's hard to describe how much of a drastic improvement it is, but after it writing Android the old way will feel extremely tedious.

Fun

After a while, once you get used to the Kotlin way of doing things, it gets very fun. Your focus will move to what you want to do over how you express yourself. Just like how the code above starts with 'fun' this feeling sets in too as you learn more.

Made with love by the community

We're not related to any of the teams working on Kotlin, but just people who love Kotlin and want to teach others why we're so excited about it. Feel free to give any suggestions or even join in towards making this a better resource. For more details see our About page.