Disclosure: Codacy, the automated code reviews platform, has previously sponsored Hacker Noon. For Hacker Noon readers, they’re offering 15% off using this code: HACKERNOON.
Kotlin is a language I thought about using for some time, yet it wasn’t until recently that I decided to give it a try. And I’m so excited that I have!
If you’ve not heard of Kotlin, it’s a language that, while newer than most, has gained significant amounts of traction in recent years. And why not? It has a series of advantages, especially over Java, that makes it quite compelling.
Here’s a short selection:
null
.equals()
, hashCode()
, toString()
, and copy()
functions.And these are just a small selection. If you want more, definitely check out this list from Android Authority.
However, if you’re still sitting on the fence regarding learning Kotlin, I thought I’d share a series of tips and resources with you, to get you off the fence and learning.
The Official Kotlin Site
Like most languages, there is an official site for the language, at kotlinlang.org. There, you’ll find a wealth of information and helpful resources, whether you’re a beginner, intermediate, or more advanced Kotlin developer.
There’s Kotlin’s reference documentation, which steps you through from the absolute basics, including basic syntax, idioms, and coding convention, through the entire feature set of the language, such as classes, objects, generics, nested classes, and lambdas.
There’s a range of tutorials that
Then there is a list of books, including Kotlin in action and Kotlin for Android Developers, and a host of other resources, including frameworks, libraries, editor and IDE plugins.
After having spent much time on KotlinLang, and performing numerous searches, I’ve yet to find a site that so offers such well organized and comprehensive information on Kotlin as this site does. Other sites, such as those created by individual developers, are great, but nothing tops the depth of information that you’ll find here.
My tip is to either pick one of the getting started guides in the tutorials section or work through the Overview and Getting Started sections in the Reference section. Then, build your knowledge progressively from there.
The Kotlin Slack Channel
The next best resource I’ve found is the Kotlin Slack channel. I begrudgingly accept that IRC doesn’t have the popularity or mindshare that Slack has achieved. And if I could, it’d be IRC all the way.
However, the people have spoken and the Slack channel it is. In the channel, you’ll find channels for discussions for:
Like all good communities, you’ll find helpful advice to questions that people have, links to exciting tidbits, recent happenings, libraries and packages, and a heap more.
The experience I’ve had there has been excellent. Even though I’m relatively new, the community’s been welcoming, knowledgeable, and responsive. I can’t say that for every community I’ve been a part of, or which I’ve attempted to interact.
A Twitter Search for Kotlin
While Twitter doesn’t have quite the reach and popularity that it once did, it can still rapidly yield significant results for technical topics. Just searching on “Kotlin” returns links to a plethora of information, which includes:
Now that we’ve worked through a series of top resources let’s look at a set of tips to help you get your Kotlin on.
IntelliJ IDEA Community
While there are a range of IDEs that support Kotlin, such as Eclipse, none has as through support as IntelliJ IDEA, by Kotlin’s core development company, JetBrains.
I might seem biased, as I love using PhpStorm when writing PHP code, and in a way I am. However, even a small amount of googling will return results for IntelliJ than for any other editor or IDE.
There are two versions, Ultimate (commercial and not free) and Community (open-source, released under the Apache 2.0 license). Naturally, there are some differences between the two.
For just getting started, the community version has all the functionality that you will need, such as code analysis, insights, inspections, integrated version control, code completion, and an absolute plethora of plugins.
However, those differences aside, it provides rich functionality, including:
gradlew
and gradlew.bat
, command-line utilities for running any Gradle task.
Kotlin Koans
Let’s say that you’ve installed a copy of IntelliJ IDEA Community and created a basic project. Now what? Good question. Like any skill, to get better at it, you have to use it regularly, progressively learning every aspect of it.
You have to learn in an organized and focused manner. To help you do that, Kotlin offers Koans. Koans are:
A phrase, dialogue, or saying that a practitioner uses to break down the shell of his or her identity. The koan serves as a surgical tool used to cut into and then break through the mind of the practitioner.
They’re a way of breaking down and learning a skill, and they come in three forms:
1. Kotlin Online Koans2. As plugins for IntelliJ and Android Studio3. As a GitHub repository
The online version, which you can see above, offers a list of 42, covering the core language features, starting with the most basic, simple functions. Using them, you can learn in an organized fashion, progressively improving your skills.
That way, you have a clear path from beginner to advanced, you can see how much you’ve learned and how far you’ve come, and you don’t have to search for what to learn next endlessly.
Assuming that you’ve worked through several — or all — of the Koans, and you’re feeling comfortable with your Kotlin knowledge (as well as of its idioms), it’s time to build a meaningful application; something other than the typical Hello World example.
The trouble is, everyone’s needs are different. So what kind of application should you create?I offer advice from a programming mentor of mine, John Sonmez, when he quoted Douglas Hofstadter:
The only way that we can learn new information is that it’s an analogy to something else.
He suggests that when you port an existing application (preferably one that you’ve created), you learn so much quicker as:
Ideally, I’d suggest that the application which you port is smaller rather than bigger. That way you can gain a sense of success and satisfaction quicker.
However, the application needs to be more than “hello world”, so that you can cover a sufficiently broad cross-section of the new language, and not just grab the low-hanging fruit.
The last way that I suggest that you learn Kotlin, is something not specific to Kotlin, but applicable to any software language, it’s by reading through code of existing projects and by learning from other developers. I can’t recommend this approach highly enough!
If there’s one way that propelled my knowledge of a language, it was by working with developers (often far) more experienced than I was.
By seeing how they approached and solved problems, the way that they wrote code, the evolution of their code over time, and asking them questions, I learned far more rapidly than learning on my own.
I’m not going to go into significant depth here, suffice to say that these two approaches are veritable treasure troves of knowledge that you never want to pass up.
Time for one last tip, a set of links to various blog posts that have helped me no end as I’ve been learning.
Those are my shortcuts for learning Kotlin. I’m not as experienced as other Kotlin developers, but I see that as an advantage, not a hindrance.
I hope that my relatively fresh eyes and enthusiasm have given you a substantial insight into why Kotlin must be on your list of languages to learn.
If you know of other reasons or want to share your experience coming from another language, I’d love to hear it in the comments and to have a discussion with you. So don’t be shy, share your knowledge!
Oh, one last thing, if you’re keen to review the quality of your Kotlin code, Codacy has your back, as they have Kotlin in their list of supported languages. Sign up, login, add your project, and get a handle on its quality.
Read more articles on The Codacy Blog.