Google promoted Kotlin as a first class language on its Java-based
Android platform back in May. Since then, the whole development world
has been wondering: what is this language? Kotlin has been around for a
few years and has been running on production systems, after the
languages 1.0 release in February 2016, for a year or so. The language
has received a lot of praise and loving words from the developer
community. It is a breath of fresh air, a good upgrade to systems
running older versions of Java, and still somehow an old dog in a
familiar playing field.
What is Kotlin? What does it bring that the JVM doesn't already have?
Kotlin vs. Java
There are a few approaches we can take when introducing Kotlin. We can
discuss it through Java, the language Kotlin needs to be based on due to
its JVM runtime, or we can do it through Scala, the language Kotlin is
heavily influenced by. There is no doubt that Kotlin is better than
Java. It is much safer and more concise. It provides you with a bunch of
additions to your standard Java language and enhances a few bits and
pieces that Java developers have grown to dislike. Additions include
things like null safety, extension functions, data classes, objects,
first class functions as well as extensive and expressive lambdas.
Kotlin also enhances Java’s type inference and type system and takes
massive leaps forward with collections.
Kotlin vs. Scala
Perhaps, it’s better to compare Kotlin against Scala. This comparison
might scare some of you quite a bit because Scala has the reputation of
being simultaneously intriguing and frightening. It heavily introduces
functional programming paradigm to you while still mixing it into
familiar object orientation (hence in an awfully lot of cases creating a
mishmash of advanced techniques from both paradigms), brings in some
new build tools, and gives your internal flow state a frustrating break
every now and then due to long compile times.
I come bearing both good news and bad news. Let’s star
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A practical, step-by-step introduction to Kotlin for programmers coming from Java or other JVM languages, covering syntax, object-oriented features, and functional additions—ideal for Android developers or backend engineers wanting a concise, safer alternative to Java.
【Book Arc】
- **Opening (~0%–4%)**: Introduces Kotlin's position in the JVM ecosystem, comparing it to Java (safer, more concise) and Scala (less complex, better tooling). Sets expectations for a language that's 100% Java-compatible but adds modern features like null safety, extension functions, and lambdas.
- **Early (~4%–12%)**: Covers fundamental data types, type conversions, and string handling. Highlights Kotlin's improvements over Java, such as string interpolation and cleaner value object declarations, while explaining numeric type conversions and floating-point comparison rules.
- **Early (~12%–20%)**: Moves into arrays and collections, emphasizing Kotlin's invariant arrays (unlike Java) and primitive-type arrays (IntArray, etc.) to avoid boxing. Also introduces string templates and shows real-world adoption examples like Corda and JetBrains Account.
- **Early (~20%–28%)**: Explains control flow: `if` as an expression, `when` as a powerful replacement for switch, and `for` loops with iterators. Emphasizes Kotlin's expression-oriented design, where conditions return values, reducing boilerplate.
- **Early (~28%–36%)**: Delves into classes and constructors, covering primary/secondary constructors, `init` blocks, and default parameter values. Shows how to create instances without `new` and introduces inheritance with `open`/`override` keywords, plus property overriding rules.
- **Middle (~36%–52%)**: Explores advanced class features: abstract classes, property getters/setters, compile-time constants (`const`), and delegated properties. Then covers extension functions/properties (adding methods to existing types), companion objects (static-like members), and object expressions for anonymous classes—key Kotlin features for cleaner, more expressive code.
【Key Takeaways】
- **Kotlin is a safer, more concise Java** (Opening): It adds null safety, extension functions, data classes, and expressive lambdas while remaining 100% Java-compatible. This makes it a low-risk upgrade for existing JVM projects.
- **String interpolation simplifies text handling** (Early): Using `$variable` or `${expression}` inside strings eliminates Java's cumbersome concatenation. This is a small but daily productivity win for developers.
- **Arrays are invariant, preventing runtime failures** (Early): Unlike Java, `Array<String>` cannot be assigned to `Array<Any>`, catching type errors at compile time. Use `Array<out Any>` for covariance, and primitive arrays like `IntArray` to avoid boxing overhead.
- **`if` and `when` are expressions, not statements** (Early): They return values, so you can replace Java's ternary operator and verbose switch statements with cleaner, more readable code. This reduces boilerplate and improves clarity.
- **Classes use `open`/`override` explicitly** (Early): Unlike Java's default-open classes, Kotlin requires marking classes and methods as `open` to allow inheritance. This prevents accidental overrides and makes the design intent explicit.
- **Extension functions add methods without inheritance** (Middle): You can add `swap()` to `MutableList<T>` or define custom properties, avoiding decorator patterns and keeping code organized. This is a powerful tool for enhancing third-party libraries.
- **Companion objects replace static members** (Middle): They allow static-like access while remaining real objects that can implement interfaces. Use `@JvmStatic` for true static methods on the JVM, bridging Kotlin and Java interop.
【Reading Tips】
- **Skim the Kotlin vs. Java/Scala comparisons** (Opening): These are motivational and contextual; focus on the bullet lists of Kotlin's advantages rather than the philosophical discussion.
- **Deep-read the data types and arrays sections** (Early): These are foundational and include subtle rules (e.g., floating-point comparisons, array invariance) that will trip you up later. Take notes on type conversion functions like `toByte()`, `toShort()`.
- **Practice the control flow examples** (Early): The `when` expression and `if`-as-expression are core to idiomatic Kotlin. Rewrite Java switch statements in Kotlin to internalize the syntax.
- **Pay attention to class inheritance rules** (Early): The `open`/`override`/`final` keywords are non-negotiable for correct code. Work through the examples with `super` calls and multiple inheritance to avoid confusion.
- **Treat extension functions as a highlight** (Middle): This is where Kotlin shines. Experiment by adding a utility function to a built-in type (e.g., `List<T>.lastIndex`) to see how it improves code readability.
【Coverage Limits】
This guide covers the first half of the book (up to ~52%), focusing on syntax, types, control flow, classes, and extensions. Excerpts do not cover later topics like coroutines, collections API details, or advanced functional programming patterns; those would require reading the full book.
Page 7
of advanced techniques from both paradigms), brings in some new build tools, and gives your internal flow state a frustrating break every now and then due to...
Chapter III the conditions As in any programming language, Kotlin contains expressions to control flow: if, when, loop, and while. It also supports the words...
mplementation of any other element of the type of overtrid). To avoid this, elements of the open type must not be defined in the base class in any of the Or...
for additional properties Companion Object Extensions When a class contains an object, it can then define additional functions and properties for that object...
to return these functions to static types, such as: (It is good to use Set instead of HashSet and use the function that returns the static type List <T> inst...
or not. Exceptions in Kotlin present it with a simple example; the following code is from the JDK interface that is implemented in the StringBuilder class: A...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
The Ultimate Beginners Guide to Learn kotlin Programming Step by Step - 2020 (Moaml Mohmmed)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
The Ultimate Beginners Guide to Learn kotlin Programming Step by Step - 2020 (Moaml Mohmmed)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment