Kotlin has raised the bar for programming languages on the Java Virtual Machine with its compatibility, readability, efficiency, and tool support. But adopting a new language can be daunting, especially when you're working with business-critical Java code that must meet changing requirements.
This book takes a novel approach to introducing Kotlin to Java programmers: showing you how to gradually refactor Java code to idiomatic Kotlin while continuing to evolve its functionality. But converting Java to Kotlin is just the starting point. Kotlin has many features beyond Java.
Using worked examples, authors Duncan McGregor and Nat Pryce guide you through honing the converted code to make it simpler, more efficient, more expressive, and easier to change. You'll learn how to take advantage of functional constructs to improve program structure, reliability, and error handling.
Once you finish this book, you'll be confident writing Kotlin from scratch, converting your existing Java when appropriate, and managing a mixed Java-Kotlin codebase as it evolves over time.
As I started a book, I found it boring. Some early chapters demotivate me, but I decided to continue, and after some chapters, things changed, and I am amazed. There is a ton of knowledge. I found some chapters pretty difficult they need 100% attention. I had a plan to revise some chapters of this book again. Thank you, the authors, and the team for your time and effort.
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.
A book on Kotlin that introduced me to "The Grain of a programming language", and if the book had just been about that it, would be already worth a read.
Duncan and Nate show in small steps not only how to refactor from Java to Kotlin but also from Kotlin to better Kotlin. They are very good at explaining the why, next to the how.
Their pragmatic view on programming (languages don't HAVE to be either OO or FP, why not both?) is a refreshing break from heavily opinionated/dogmatic manifestos on how to write code.
I felt privileged getting insights into the minds of these well-traveled journeymen.
There's also a companion github repository that allows for following along in code.
Very happy to have read this in a reading group at work, because it sparked some enthusiasm for doing (current and) future projects in Kotlin; combining it with code kata's it builds confidence and a common language, much like Martin Fowler's Refactoring book.
This is a great piece for every Java programmer who thinks about trying out Kotlin. It doesn't cover every language feature and is by no means a replacement for the reference documentation, but it is something more important in my opinion. As rarely (if ever) in the real world there is a chance to suddenly migrate your project from one language to another, it is crucial to know how you can do such a thing incrementally and where it may bring the most value for your buck. And this book pretty much gives you just that.
I also really liked that the authors put a lot of focus not only on the language itself but also generally on best practices of software development and functional programming especially. The examples are rather simple, but they convey the message pretty well. The text is easy to read and understandable. Overall, I can truly recommend this book.
Great intro book for Java Engs thinking about switching to Kotlin. I enjoyed the start of the book more, as it explains the motivation behind Kotlin, it's idiomatic ideas, and why it provides the best dev experience. The second part of the book is mostly examples of refactoring existing Java code to Kotlin. Which is OK, but more water than I expected. Good examples tho, but a bit boring. Nevertheless, I think it's a great book, totally worth reading
One of the best books on Refactoring, Object-Oriented Design and of course Java and Kotlin. A must read if you are interested in any of these topics. Highly recommended from my side.
Great book. Title doesn’t make justice for it. Don’t be afraid that you are beyond the Java -> Kotlin transition. The book is so much more than that.
You will learn how to use Kotlin effectively and in a idiomatic way, leveraging it’s tools like functional programming, top level functions, extension functions etc You will also take a peek on how to test drive your way and quite a bit of refactoring techniques.