Switch to Kotlin
Non-technical advice on how to switch from Java to Kotlin for Android developers
Kotlin is a great addition to the Android world. For me it has the potential to be what intelliJ was to eclipse in terms of Android development.
You’ve heard about it a lot and after several years of verbose Java development you’d like to switch. You’re a busy developer however so you prefer this to be as efficient, smooth and fun as possible. Here is some advice. Again, this is not a technical introduction.
Rule 0: Minimal preparation (30 minutes)
- Check the language basics to understand the basic syntax and concepts. Because it is quite similar to Java don’t spend more than 20 Minutes on this! You’ll get the real hang of it quickly.
- Find a cheat sheet that suits you. I love this one. Print it, hang it beside your screen. Read it superficially so you know what’s on it and where to find it. Remove the cheat sheet after a month.
Rule 1: Learning by doing (12 work days)
- If you’re a professional Android developer choose a small project to implement fully in Kotlin. Personally, I don’t believe that mixing up both languages is the optimal choice and should be avoided if possible. If you’ve got a hobby project that you’ve always wanted to implement, this is your chance! A little additional motivation will be useful.
- Convert the template Java classes to Kotlin one by one, viewing the Java code and the resulting Kotlin code. Do this only with the template classes created by Android Studio. Please don’t start regularly implementing in Java and converting to Kotlin.
- Go all Nazi on code and architectural quality. Don’t even consider using workarounds (as you might do when time and budget are running out, as they usually are ;)! Again, stick to best practices in terms of code style and design patterns. Don’t allow this switch to reduce the quality of your work! Some points might be:
- Abstract if/when possible
- Aim for 100% null safety
- Stick to all Android best practices and your favourite libraries!
- etc. (you know what “good quality” is ;). Just be persistent and stick to it this time!)
Rule 2: Continuous learning (yep, never ends)
- Remember, Kotlin is a language. A language requires some time to master. So don’t be too hard on yourself if you’re not using all the Kotlin magic in the beginning (and there is quite a bit of magic!). I’ve been developing Java for over 11 years now and it has been a steady and continuous course. To be honest, even though I always look forward to learning new things, there is always a small amount of fear. I believe thats the most normal thing. That’s just human nature. Don’t let that restrict you.
- Make sure you maintain your developer “flow”. That humming feeling that surrounds you when you’re ONE with your code, implementing features on a high abstract level and not fighting syntax. I achieve this by not trying to use too many new Kotlin concepts at a time.
- Check in with more advanced concepts early on but not right at the beginning. You’ll quickly identify the concepts foreign to you in the language reference. Don’t skip this point.
- If possible, chat with coworkers who are going through the same. Do small code talks to share insights.
Good luck everyone!
Very good thanks.
> If you’re a professional Android developer choose a small project to implement fully in Kotlin.
I would even recommend to forget first about Android and all the slowness and accidental complexities it always bring
Instead, start first a JVM project. Your obvious first candidate will be
§ git clone https://github.com/Kotlin/kotlin-koans
Even after that’s completed, I kept a JVM/kotlin kitchen-sink project where I could try quickly a lot of stuff and this proved to be immensely useful