It takes a week to travel the 8,000 miles overland from Java to Kotlin. If you’re an experienced Java developer who has tried the Kotlin language, you were probably productive in about the same time.
You’ll have found that they do things differently in Kotlin, though. Nullability is important, collections are different, and classes are final by default. Kotlin is more functional, but what does that mean, and how should it change the way that you program? And what about all that Java code that you still have to support?
Your tour guides Duncan and Nat first made the trip in 2015, and they’ve since helped many teams and individuals follow in their footsteps. Travel with them as they break the route down into legs like Optional to Nullable, Beans to Values, and Open to Sealed Classes. Each explains a key concept and then shows how to refactor production Java to idiomatic Kotlin, gradually and safely, while maintaining interoperability.
The resulting code is simpler, more expressive, and easier to change. By the end of the journey, you’ll be confident in refactoring Java to Kotlin, writing Kotlin from scratch, and managing a mixed language codebase as it evolves over time.
From the brand

Explore Java resources
More Java
More From O’Reilly

Sharing the knowledge of experts
O’Reilly’s mission is to change the world by sharing the knowledge of innovators. For over 40 years, we’ve inspired companies and individuals to do new things (and do them better) by providing the skills and understanding that are necessary for success.
Our customers are hungry to build the innovations that propel the world forward. And we help them do just that.
Publisher : O’Reilly Media
Publication date : September 21, 2021
Edition : 1st
Language : English
Print length : 422 pages
ISBN-10 : 1492082279
ISBN-13 : 978-1492082279
Item Weight : 2.31 pounds
Dimensions : 7.25 x 1 x 9.5 inches
Best Sellers Rank: #1,540,985 in Books (See Top 100 in Books) #83 in Functional Software Programming #344 in Object-Oriented Design #1,405 in Software Development (Books)
Customer Reviews: 4.6 4.6 out of 5 stars (32) var dpAcrHasRegisteredArcLinkClickAction; P.when(‘A’, ‘ready’).execute(function(A) { if (dpAcrHasRegisteredArcLinkClickAction !== true) { dpAcrHasRegisteredArcLinkClickAction = true; A.declarative( ‘acrLink-click-metrics’, ‘click’, { “allowLinkDefault”: true }, function (event) { if (window.ue) { ue.count(“acrLinkClickCount”, (ue.count(“acrLinkClickCount”) || 0) + 1); } } ); } }); P.when(‘A’, ‘cf’).execute(function(A) { A.declarative(‘acrStarsLink-click-metrics’, ‘click’, { “allowLinkDefault” : true }, function(event){ if(window.ue) { ue.count(“acrStarsLinkWithPopoverClickCount”, (ue.count(“acrStarsLinkWithPopoverClickCount”) || 0) + 1); } }); });
9 reviews for Java to Kotlin: A Refactoring Guidebook
Add a review
Original price was: $65.99.$36.49Current price is: $36.49.


Torbjörn –
Valuable
Kotlin is a really nice language but is not so common that you have the opportunity to start writing software from scratch, not professionally anyway. This book describes in a really good way how you transform your existing Java code base to Kotlin, step by step, concept by concept. It is pedagogical, mixing the rational behind what you want to accomplish (immutability for instance) and then it shows how to transform the Java example to Kotlin.Highly recommended.
Jswizzy –
Effective Java for Kotlin
This book is not for those new to Kotlin but it is probably the best book for learning how to write Koltin. Much of what was best practice in Java no longer applies in Kotlin because it doesn’t have the heavy handed OOP restrictions on it that Java has and is more of a hybrid language allowing OOP, FP, and DOP to all merge.
Anon –
not useful
Not for those that want to learn Kotlin’s basics.
George –
Do not fight the grain of the language!
As the authors describe in the book, every language has its own grain and so does Kotlin. Kotlin although promoted as a better Java is so much more. It has its own grain, its own idioms.This is a book for all levels of developers that would like to try Kotlin and especially for people coming from Java.Make no mistake though! This book has, also, its own grain and its not simply a java to kotlin book. You will delve into TDD, functional programming and a plethora of refactoring techniques that you will be able to use day in day out.Do not falter and buy this book as fast as possible!
Piotr Krzemiński –
When buying the book, I thought: “I’m already past that point where I need to be guided how to go from Java to Kotlin”. I was sure that it was about just migrating to Kotlin, forget Java, it’s crap and let’s be fanboys of Kotlin. However, after first pages I actually learned about the history of Java and where the differences between Java and Kotlin come from. I’ve been just 6 years in the industry, and started with Java 8, so such retrospective was very valuable. The great term introduced in the book – language’s grain – is the answer to most differences and was one of the “aha!” moments for me. This book is a great read for Java developers that even doesn’t really want to go into Kotlin (yet), so that they see that Kotlin offers what Java has been trying to be for several years now. It articulates the strengths and reasons first, then you go on a sort-of-pair-programming session with the authors (well, unidirectional, but always), and in a very informal way, play with the code and refactor it in different ways. The authors share the reasons of each refactoring steps and explain the trade-offs. All of this is with keeping compatibility with existing Java code base in mind, because the authors realize that it’s nearly impossible to do a big-bang refactoring to Kotlin.Note: this is not a book which I would recommend as a first read about Kotlin. As the authors state themselves, they didn’t mean to teach the language, but rather build on top of the basic knowledge that someone should gather somewhere else. Once you have a nice grasp of the syntax and basics, you are good to go with this book.
Peter Storch –
After nearly 20 years of Java programming I started in a new team to develop a Kotlin application. Only a few members had prior basic Kotlin knowledge. So we learned on the go. We even learned a few things about idiomatic Kotlin.After 1.5 years I wandered if I could still improve my knowledge by a book.Via the videos of Duncan I stumbled upon this book.It is a good summary of the Java history to understand the intentions and origins of Kotlin.I learned a good deal more about the grain of Kotlin. More functional thinking as I already had.And the practice of little steps refactorings is always a good refresher. It was fun and instructional to follow the progress.
Andrew Farrell –
As a Java developer who now using Kotlin as my core JVM language, I found my self constantly thinking the Java way and my verbose bloated Kotlin reflected this.Following along with Nat and Duncan has been great, they have used a learning model based on the gradual refactoring and conversion of the test project using a bite size incremental git commit history, which has been great to review after every few paragraphs to internalise the point being illustrated.The mutability pit falls of Java and the immutability opportunity in Kotlin is frequently presented in the book.Highly recommended
Hans Kruse –
Clearly explained how to migrate. Then Kotlin 2 came.
Amazon Customer –
I am half way through, but I have to agree with other reviewer — book is useful but unnecessary opinionated. Assuming book target audience are experienced software engineers, it doesn’t read as such, due to ill-balanced and one sided examples, and the tone.This is particularly striking, as certain topics are actually omitted, if not fit authors point of view, whereas others are too verbose, even when irrelevant.Rating 4/5 as it covers relatively large number of topics.