Additional units have been published to this learning path. (July 18, 2019)
Welcome to the IBM Developer Kotlin learning path!
If you want to learn Kotlin, you've come to the right place. While the Kotlin website is a trove of great information (I'll refer to it frequently throughout the learning path), that information is densely packed in some places and thin in others. In this learning path, I've tried to simplify the former, and expand and fill the latter to give you a complete introduction to the language.
The learning path is divided into 17 units, including this one — the learning path introduction.
Why you should learn Kotlin
The Kotlin docs are filled with explanations that are geared towards Java developers – and that's great – but developers who don't know Java may find that off-putting. After all, explaining an unknown concept mostly in terms of another unknown concept makes for a less-than-satisfying experience.
This learning path explains Kotlin in terms that don't rely on pre-existing knowledge of any particular language.
But to understand how we got here, let's take a brief journey back in time (only about 20 years or so).
A (very) brief history of Java
The Java platform transformed enterprise computing. In the 1990s, moving enterprise software (a customer relationship management system, for example) from one platform to another was no small feat: the development team had to know both platforms so that code could be ported from one platform to the other, extensive testing had to be performed, and, in the end, there were two code bases to maintain.
Then along came the Java platform with its "write-once-run-anywhere" promise: enterprise apps could be written in a single language – Java – and run on a variety of platforms for which there was a suitable Java Virtual Machine (JVM) implementation. It seemed too good to be true (and had its nay-sayers, to be sure), but in no time, developers only had to know one language to target a dozen different platforms. The "write-once-run-anywhere" promise had come true.
Other JVM languages emerge
But the Java language isn't perfect. It's mostly object-oriented, but not completely. It has strict type checking, but is still susceptible to runtime errors arising from the use of null values. The Java compiler doesn't perform automatic type inference, making its syntax (read that: the amount of code you have to write) at times maddeningly verbose. As a result, industrious developers began to create compilers that would let developers write programs using their favorite languages (Groovy and Scala were among the first) and generate Java platform bytecode so that their programs would run on the JVM. Now there are lots of languages that run on the JVM.
Along comes Kotlin
So, why Kotlin?
Kotlin enables very compact — yet surprisingly readable — code: through type inference, smart casts, and incredibly compact lambda expressions, Kotlin allows you to write very maintainable code, while still producing code that runs on the JVM.
Kotlin is also emerging as THE language to use for Android development: its compact syntax makes it a perfect choice for the event-driven Android platform, reducing the need for lines and lines of repeated boilerplate code to implement even listeners and handlers, for example.
Kotlin has its origins in the Java language: if you're coming over from Java, the leap is an easy one. And Kotlin has been designed from the ground up to fix all of those little irritating things that drive us Java developers nuts, like support calls related to
NullPointerExceptions at 2am (oof). Not with Kotlin; well, unless you go out of your way to allow
nulls in the front door.
What you should know already
To get the most out of the learning path, there are a few things you should know.
You need to know how to search the web. While I'll endeavor to explain Kotlin concepts in a clear and thorough way, the effort requires that I borrow from other areas of computer science. The sad reality is that I'll occasionally — through either necessary editorial economy or simple negligence (the latter is more likely) — make such an allusion and proceed to leave it orphaned from further explanation. When this happens, your ability to search the web and learn about these borrowed concepts on your own will benefit you greatly.
You should know how to install software on your computer, including the IntelliJ IDEA Community Edition (CE) IDE that you'll use to write code (though you're free to use any IDE you like), and the Kotlin compiler and runtime libraries to compile and run your Kotlin code.
If you have written code before (especially Java), you'll move through the material more quickly. Though I'll refer to Java at times, I won't make a habit of it and, as a general rule, won't map my explanations of Kotlin constructs to their Java counterparts (the Kotlin website does a fine job of this already).
What you'll learn in this learning path
When you've completed the learning path, you will have a basic understanding of the Kotlin language, including (but definitely not limited to):
- Variable declarations
- Expressions versus statements
- Functions, including lambdas
- Classes, including properties and constructors, and inheritance
- Nested classes
- Null safety, smart casts
- Working with exceptions
You will also know how to work with some of its standard library, including:
Along the way, you'll watch videos, take quizzes, and write lots of code while you learn the basics of the Kotlin language. When you're finished with the learning path, you'll have the skills you need to work on a real Kotlin application.
Additional learning path features
Source code for the learning path
All of the source code you'll see in the learning path is in the GitHub repo for the learning path. Clone the repo, and the code is in the
Kotlin directory. That includes source code solutions to all of the programming problems too.
Each unit has its own directory, so each unit stands alone and is completely self-contained. You should create a separate project for each unit (don't worry, I'll show you how to do that in the video for Unit 2).
The odd-numbered units (except for this one) include a quiz. You'll see True or False, short answer, multiple choice, and programming exercises. These help you cement your understanding of the material in that unit.
Don't worry though, all of the questions have answers, and the programming exercises have solutions (with code in GitHub, too, as I mentioned earlier), just in case you get stuck (no peeking).
The even-numbered units have videos, which are designed to reinforce the material in the unit it goes with. I'll show you how to run and debug the code that accompanies that unit, and you'll get a chance to see Kotlin in action.
They say a picture is worth a thousand words, so a video is worth a thousand pictures (give or take). The learning path has eight videos, and each video is 5-10 minutes long and covers the material in the unit from a the perspective that only video can offer.
Learning path overview
The following items make up this learning path (Units 8 – 17 to come):
Understand why you should learn Kotlin and how this learning path will help you.
Install requisite software so that your computer will be set up and ready to write Kotlin code.
Get a basic understanding of object-oriented and function-oriented programming concepts.
Learn about statements and expressions, and all of the primitive data types the Kotlin language has to offer, with examples.
Gain a better understanding of type inference and static typing, variables, Kotlin operators, and basic function syntax.
Understand Kotlin coding conventions, what goes in a source file, how to write classes and subclasses, and much more.
Learn about default arguments, named arguments, nullable values, and how to use them as function arguments, smart casts, and more.