It’s been six years since the first Line of Code — Android was published in 2014.

It’s been six years since the first Line of Code — Android was published in 2014. During this period, the Android system version has undergone a huge upgrade from 4.0 to 10.0, and the development technology has changed dramatically. In 2016, I published the second edition of the book with a major update, the second Line of Code. Now, four years later, The Third Line of Code is finally getting a new look.

I have to say, “Line 1, 3rd Edition,” the book, in the process of publication has gone through so many twists and turns that it can only be seen today. Here to all readers: sorry to keep you waiting!

Back in 2017, Google announced at I/O that Kotlin would become a tier 1 development language for Android, putting it on par with Java. I had a hunch at the time that there would be a big shakeout in the Android application layer development language. The Turing Press had seen the news, and the Turing editor had contacted me immediately to ask if I was going to write a book on Kotlin.

I think it takes time to master a language. You can learn the grammar in two weeks, but to really get the hang of it, you need to hone and improve by writing code. At the time I didn’t think I had what it took to write such a book, so I didn’t say yes.

For those of you who have been following me for a long time, I’ve been working on GifFun for over a year. The project was originally written in Java and I switched to Kotlin halfway through. Because I know that the best way to master a language is to keep writing code in it. I took the opportunity to understand Kotlin better.

In 2019, the publisher and I had another round of discussions to update The first Line of Code for a third edition, this time using Kotlin for the entire book. The problem, however, is that Kotlin, as a new language, is unlikely to have a programmer base as large as Java’s. What if the language change makes it difficult for a large number of readers to understand?

The publisher came up with a plan for me to write a separate book on the Kotlin language to accompany The first Line of Code. But I didn’t say yes because I thought it would raise the bar for Line 1, 3rd edition.

After a lot of thinking, I came up with the best way to write a book that explains both Android and Kotlin technologies. This will be the first time a programming language has been introduced in Line One.

But how to arrange the content sequence between these two technologies is a very challenging thing. Since Kotlin is the development language for Android applications, it’s obvious that you need to know the language before you can develop Android applications. But if you spend half a book on Kotlin and then start learning Android development, it’s going to be pretty boring, because the worst thing about learning a programming language is optics.

To that end, I decided to talk about Kotlin and Android together in a way that perhaps no one else had tried before. Start by introducing Kotlin to the basics with a quick start section, and then use what you already know to start learning Android development so you can get up and running right away. After that, each chapter will combine a fair amount of Android content with some advanced Kotlin knowledge, and by the end of the book, you will have mastered both Android and Kotlin technologies.

This interspersed approach is a great test of my content design skills, because the Kotlin knowledge used in each chapter of Android development should not be too advanced, or the reader will not understand the situation. At the same time, the Kotlin knowledge explained in each chapter should be combined with the Android knowledge in the corresponding chapter, so as to better understand the usage and scenarios of this knowledge point. Their content is complementary to each other.

It took me nearly a month to make the initial table of contents, and two more months to write the Kotlin Quick Start chapter. Since I had never written a programming language book before, I took great pains to cover all of Kotlin’s important basics in this chapter. In the process of writing this chapter, the Google I/O 2019 conference officially announced the slogan Kotlin First, and Kotlin is no longer equal to Java, but has become a first-class citizen. Although I expected this to happen, it came earlier than I expected and made me more confident in writing the book.

“The Second Edition of the First Line of Code” was started in March 2016, finished in September of the same year, and published in December. Line 1, Version 3 started writing in March 2019, but was far from finished in September, as the changes and additions were much larger than in version 2. I spent almost all my spare time working on it, and it was barely finished by the end of November.

I originally thought that good things take time, the book is not afraid to be published a few months late, after the New Year should be able to meet everyone. Unexpectedly, we happened to encounter an epidemic disaster that we had never encountered before, including SARS 17 years ago, which was not as severe as the COVID-19 epidemic today.

This epidemic has caused great trauma in all aspects of China. Schools and businesses have been closed. Everyone can only stay at home. Affected by the epidemic, publishing houses, printing plants are delayed work, unable to resume work. Every day, I am asked by readers on my wechat account when the new book will be published. I really could not answer this question at that time. No one really knew how long the impact of the epidemic would last.

It was not until March, when the epidemic was gradually under control and most companies were slowly returning to work, that the book was finally published. But while the epidemic at home has abated, it has followed with an overseas outbreak that, as of this writing, shows no sign of abating. While it is still unclear how long the global impact of this pandemic will last, I do hope that by the time you read this, COVID-19 will be a thing of the past and everyone is getting back to their normal lives.

I hope that this book, which was born after so many hardships, will give you more knowledge.

I’m sure many readers would like to ask a question: What exactly does Line 1 Code Version 3 change from Line 1 Code Version 2? Here I would like to give you a detailed overview of the main changes.

The first is the programming language change. The first two editions of the book used Java as the programming language for applications, while the third edition uses Kotlin, which is currently the most recommended programming language by Google.

In the first two editions of this book, there is no language instruction, and the default is Java language proficiency. The third edition of the Kotlin language is very comprehensive and does not require any basic knowledge of the Kotlin language.

You also need to know that Line 1, 3rd Edition is an updated book, not a brand new book, so the overall knowledge structure is still the same as Line 1, 2nd Edition.

Although the overall knowledge structure remains the same, some chapter changes are involved.

In the third edition, chapters 11 and 15 from the previous second edition have been removed. These two chapters respectively explain LBS development and App launch.

In fact, LBS development mainly explains the usage of Baidu Map SDK, but Baidu map SDK is likely to be updated frequently, and the content in the book can not be changed at will, so I think this part of the content should go to baidu Map developer’s official website for learning.

As for App listing, it mainly explains the process of App listing in 360 App Store. Since App listing in China has become very complicated, individual developers need to apply for software copyright to put their own App on App store, so the content in the book is no longer applicable, so it is removed.

In the third edition, three new chapters were added, namely, Chapter 2, Chapter 13 and Chapter 16.

Chapter 2 is the aforementioned Quick start to Kotlin. This chapter will introduce you to Kotlin programming quickly, explaining the most basic and core knowledge of Kotlin, such as variables, functions, logic control, object-oriented programming, Lambda programming, null pointer checking, etc. With this chapter behind you, you’re ready to use Kotlin to write some Android applications.

Chapter 13 is a chapter devoted to Jetpack. Jetpack is a set of development component tools launched by Google in recent years to help us write applications that are more architecturally designed and conform to high-quality code specifications. Yes, now we can’t just implement features and be done with it. We need to implement features with higher code quality and architecture. Chapter 13 covers ViewModel, Lifecycles, LiveData, Room, WorkManager, etc., basically covering some of the most important components of the Jetpack architecture module.

Chapter 16 is a new field chapter added to the third edition. The first two editions of the book had only one combat chapter, while the third edition will have two combat chapters. Chapter 16 takes you through the process of writing and publishing an open source library. Since I’ve written a few well-known open source projects before, and my main job at the company is SDK development, I’m actually pretty good at this. What could be more exciting than seeing your own open source library referenced in someone else’s project?

Having introduced the changes in the chapter as a whole, let’s look at some of the specific changes.

In response to Google’s call of Kotlin First, all the code in the book has been changed to use Kotlin language for implementation in the third edition. The continuous Kotlin of Android is also the inevitable trend of long-term development in the future. However, since the new chapter 2 only covers the basics of Kotlin, the third edition includes a Kotlin class session at the end of almost every chapter in order to give you a fuller understanding of all aspects of Kotlin. There are 12 Kotlin lessons, covering common techniques, higher-order functions, generics, coroutines, DSLS, and more, which is enough to make you proficient in Kotlin.

In addition to a lot of changes in the programming language, Android development is certainly not static. Since The release of Line 1, Version 2, Android has gone through rapid iterations of OS 8, 9, and 10. New features are added to each new system release and development adaptations are required, and release 3 covers them all.

In addition, in recent years, there are more and more developers who pursue architectural design, and architectures like MVP and MVVM are being used more and more widely. The traditional MVC architecture is gradually being abandoned. Chapter 15 of version 3 covers the MVVM architecture in great detail, and with the Jetpack component provided by Google, an MVVM architecture weather forecast program is finally completed. Although I have written three versions of this weather forecast program, this one will be the most architectural and compliant with high quality coding specifications. I believe it will be of great help to you in the future development of the company’s actual projects.

In addition to the major changes mentioned above, there are many minor changes that are not listed here, and you will find them in your own reading.

Although this is an upgraded book, I spent as much time and energy on it as writing a new one. So, both in terms of content and in terms of design, I wanted it to be more distinct from version 2. So Turing’s designers had a hard time.

The first is the cover design. Just like the second edition, the third edition of the cover was also made by The Designer of Turing. Then I launched a poll on the official account for the majority of readers to choose the most satisfactory cover.

The blue cover won by a landslide, and The First Line of Code finally got the red, green and blue triad together. The cover of the 3rd edition is officially confirmed:

Then there are bookmarks, which were included in books for the first time in the second edition, so the third edition will certainly carry on the good tradition. Bookmarks should be designed to reflect as much of a book as possible, and I think Line 1, 3rd Edition features two parts: Android 10 and Kotlin. So I also asked the designer to create two bookmarks for these two themes. Let’s take a look:

     

These two bookmarks are included with each book, and while giving two bookmarks to one book might be a bit superfluous, I think it gives a more complete feeling.

In addition, for the first time, a mind map of the book’s knowledge structure is provided in the third edition. This is sorted out according to the main knowledge points in the book and drawn by zhang Xia, the editor of the book. It is divided into two diagrams of Android and Kotlin.

Mind maps allow you to see the big picture of Android and Kotlin in the book and help you sort out the key points from each chapter.

The Android mind map looks like this:

Kotlin’s mind map is as follows:

Both mind maps are bound in color pages so you can check them out at any time.

Finally, it is a good news for college teachers. Since the first two editions of this book are used as teaching materials by a large number of colleges and universities, this time in order to facilitate the teaching of college teachers and training institutions, the third edition is specially equipped with corresponding PPT courseware. In the preface section of the book attached with all the resources to download the address.

I have found that some readers have misconceptions about how books are priced, so here is a brief introduction.

Any book should be priced on the basis of cost, not content. Cost refers mainly to the cost of printing the book, so a book with many pages must be more expensive than a book with few pages, and a book with color pages must be more expensive than a book with black and white pages.

In my previous post, some readers commented that a book should be priced according to its content, which is impossible. There may be a good book that raises its price because it has a good reputation, but there certainly isn’t a bad book that lowers its price because it feels bad.

The price increase is inevitable because of the addition of Kotlin’s knowledge in Line 1, 3rd edition, and the total number of pages in the book has increased from 500 pages in the 2nd edition to 700 pages now.

At the beginning, Zhang Xia, the editor of the book, suggested that the price of the third edition be 99 yuan. I thought it was a bit higher than the 79 yuan of the second edition, and asked her if she could lower the price to 89 yuan. She told me that there was a good chance that the publisher would reject a 700-page book priced at 89 yuan, but she still submitted it for that price. Sure enough, it failed to pass the price review, as more than 700 pages of books on the market were priced at least 100 yuan. Eventually I gave in and agreed to price version 3 at 99 yuan, at least within 100 yuan. But that’s just the price of books, and we usually get discounts when we buy books online. The number of specific discount is decided by each shop, I can not participate in, but it is generally 70 or 80 dollars to buy.

Knowing so much, I wonder if you have decided to buy one? Currently, the 3rd edition of the 1st Line of Code has been pre-sold on jd.com, Dangdang and other online bookstores. Limited edition signature edition is first come, first served. If you need it, please buy it on jd.com, Dangdang and Tmall.