In this topic, we will guide you through the website where you can find Kotlin documentation and other useful materials essential for mastering the language. We will explain the website structure and show you how to use it to become more confident in this modern and multiplatform programming language.
The website structure
Official documentation plays an important role in learning a programming language. In the case of Kotlin, it can be found at kotlinlang.org, which is actually more than a mere language documentation site: it provides numerous resources to improve your knowledge. Here are some of the sections you can explore if you visit the website:
Kotlin overview – The language has a wide range of application, and here you can learn about its use in different fields. Read about the frameworks it works with, explore sample projects and take tutorials, learn about the official libraries, etc.
Kotlin news – The Kotlin blog provides information about the development of the language and its usage. Here you can find articles about new releases, webinars with experts, various practical guides on how to use Kotlin with different frameworks, libraries, tools, and much more. If you're a fan of social networks, you might want to follow Anton Arhipov and Hadi Hariri on Twitter. Both of them represent JetBrains and regularly tweet on Kotlin-related topics.
Kotlin community – If you're an active user and wish to be involved in the community, you have several options. There are Kotlin User Groups operating all over the world in different cities. If there is one in your city, you can join their meetups; otherwise, you can follow the Virtual Kotlin User Group. Other online platforms include the Slack channel, Linkedin group, and Kotlin forum, where you can meet and have discussions with Kotlin developers from around the world.
Those interested in contributing to the development of the language are also welcome. On the Contribution page, you will find what opportunities you have and choose the option best suitable for your interests. If you are a novice specialist and aren't ready to contribute to the language itself due to a lack of experience, you can still contribute to the documentation. Finally, if you've found some error, you can open a ticket in the issue tracker and follow its solution.Practice – Learning programming is very difficult, and practice plays an important role in the process. The site allows you to learn Kotlin by example. In this section, you will find examples illustrating various language features. Moreover, you can go further and solve Kotlin koans – a series of exercises aimed to let you practice with Kotlin syntax.
This isn't by far all the information provided on the website. Don't limit yourself to the above points only – take the time to fully explore the content of the website. You will definitely discover lots of useful stuff.
Kotlin Standard Library
Kotlin implements many extensions for JDK classes as well as utilities that enhance our work with strings, collections, threads, etc. Provided in the Kotlin Standard Library (stdlib), they are available at this link. Therefore, it's vital to learn how to deal with the website and use the documentation. The website is quite minimalistic and easy to navigate, you just need to realize how to use the two features at the very top of the page.
In the left block, there are buttons that allow you to select packages available for the selected platforms. In the example above, all available platforms are selected: Common (multiplatform), JVM, JS, and Native. On the right is a drop-down list with language versions. In our case, it is version 1.6, and we can see the packages available for this version. If, for example, you need to select only the packages for the JVM and JS platforms available in the 1.3 language version, you need to activate only the JVM and JS buttons and select version 1.3 from the drop-down list. The result will look like this:
The same structure can be found inside each package. When you open a package, you will find all classes available for all platforms in the latest language version, from which you can select what you need.
The functionality is quite straightforward; we will have tasks in the practical part of the topic to help you master it.
Exploring packages
We have figured out the structure of the Kotlin Standard Library, which contains various packages that provide the main APIs of the language. Now, let's open some package, for instance – kotlin. We will choose a class and write a small piece of code to use one of the functions and see what information the documentation can provide about it.
fun main() {
val a: Int = 10
println(a.inc())
}
Let's go to the Int class documentation and see what it can tell us about the inc() function. At the very top is a block where we can see that as of the 1.6 version of the language, the function is available for all the above-mentioned platforms.
And what about version 1.0? If we choose that version, we will see that our function was only available for development on the JVM platform. The other platforms were added gradually: one in each new version.
Now, let's move on to the next part of the web page. Here we will find the function description and a code example, which will give us an answer to an important question: why do we need that function if it is possible to write ++a or a++? In fact, the function does work differently compared to the code with the ++ operator. If you read this code carefully, you will realize the difference:
val a = 3
val b = a.inc()
println(a) // 3
println(b) // 4
var x = 3
val y = x++
println(x) // 4
println(y) // 3
val z = ++x
println(x) // 5
println(z) // 5Conclusion
This topic offers a brief introduction to the Kotlin documentation website. It has a comprehensive and constantly updated knowledge base, which allows you to learn and get better in Kotlin. We highly recommend visiting the website and keeping track of the news on a regular basis.