I have been learning kotlin since quite a while. Needless to say I love it :) When I started learning it I had no clue from where I should start ? Because of number of resources like videos, official documentation and books. If you haven’t started yet and planning to learn kotlin then I would like share my journey of learning kotlin.
Step 1 : Get your basics clear
To start with you should go through online kotlin’s official documentation. This will teach you about language basics like syntax and other features. Cool thing I like is while reading it you can also edit and run example code snippet within your browser so that you can play around with concept that you have just read.
At first looking at documentation it will be overwhelming. Don’t panic and don’t target to finish entire documentation in one go. Learn piece by piece and once you finish documentation I would recommend again go through it once.
After reading documentation twice you would have rough idea about language and at least you would be able to write hello world in kotlin :)
Step 2 : Kotlin Koans
After reading documentation it’s time to play around with kotlin. Kotlin koans is programming exercises that you should try. It covers all language features and concepts. It has failing unit tests for each concept, your task is to make it pass. You can try it either online here or you can clone github repo to try in IDE(Intellij IDEA or Android studio). I would recommend cloning github repo and try it in IDE for your future reference of your own solution.
Kotlin koans will push you to think about all concept you read in documentation and apply it while solving exercises. After solving it you would have nice grip on language and feel bit confident. But this doesn’t mean you are done with kotlin. At this point you know the language basics and can write code in kotlin.
Step 3 : Try it in real project
Now it is time to pull up your sleeves and show some action!!!
Side projects are perfect guinea pig for experimenting with new things and learning all consequences that you might face while using it in production. As a android dev I am always occupied with side project. If you are starting something fresh like new side project then it is perfect opportunity to use kotlin in your domain. Using kotlin in side project related to your area of interest will boost your confidence and eventually make you feel safe to use it in production.
At this point you will come across things in kotlin that is specific to your domain (e.g Kotlin Android Extensions for android, Anko is a library providing a set of Kotlin-friendly wrappers around the Android APIs). Trying kotlin in side project not only allow you to evolve your language skills but also gives you opportunity to learn other things that might be helpful if you use it along with kotlin in your domain.
If you don’t have side project to try kotlin then don’t worry. You can still try kotlin if you love to solve programming puzzles (HackerRank, TopCoder etc). I personally got inspired by Dan Lew to improve my kotlin skills by solving puzzles on advent of code (work in progress).
What’s next ?
Learning programming language and writing code in that language is not big deal. What matters is how you write code that is readable to others and at the same time it uses ideal approach of writing code using language features. “Idiomatic kotlin” is the term that best describes above statement and it is not something that you get it quickly. As you keep using it you would come across ideal way to implement something you wrote previously. When you come across situation like this don’t blame yourself. It is perfectly fine to write code in a way you understood language at first. Realizing best approach and refactoring your approach to best approach is the key to idiomatic kotlin. It takes time to master a programming language and kotlin isn’t exception.
Finally I would like to highlight few resources I use to keep up to date with kotlin.
https://blog.jetbrains.com/kotlin
https://antonioleiva.com/kotlin
This was originally posted on Medium