Since we announced support for Kotlin in 2017, we have received a lot of questions about using Kotlin for Android development: Everyone wants to know whether it is suitable for learning Kotlin, whether to introduce Kotlin in application development, and what is the best course or tutorial for learning Kotlin, Is Kotlin being used internally at Google, and what is our plan for the Java programming language? This article will answer one by one.
: Should I learn Kotlin for Android development?
Most of the most frequently mentioned issues revolve around the same topic:
- "For beginners, should I choose to learn Kotlin or the Java programming language?"
- "If you have mastered the basics of Java, is it suitable to use Kotlin for Android development now?"
- "For senior Java developers who are learning Android development, is it recommended to get started directly with Kotlin or get started with Java?"
simply put:
Yes it is! Start learning and using Kotlin!
expand to answer:
Kotlin and Android
In 2017, we announced support for Kotlin at the Google I/O Conference. Since then, we have set out to ensure that our APIs, documentation, and examples are applicable to Kotlin. In 2019, Kotlin became the language of choice for Android development, which made us begin to rely more on the features of Kotlin. For example, coroutines have become our recommended solution for implementing asynchronous operations.
We have also done the following:
Kotlin priority library
First of all, in several Android Jetpack APIs (such as Room, LiveData, ViewModel, and WorkManager), we added first-class support for Kotlin coroutines, thereby transforming the way to perform asynchronous operations on Android. Firebase Android SDK and many Jetpack libraries have Kotlin extension library (KTX), which is more smooth to use through Kotlin.
Now, many of our libraries prefer Kotlin, such as Paging 3.0 and DataStore. Jetpack Compose is a brand new, independent, declarative UI toolkit written in Kotlin from start to finish.
tool
Development efficiency comes from powerful tools. Therefore, we have made many Kotlin improvements to the compilation tool chain, including improvements to the Kotlin JVM compiler, R8 optimizations for Kotlin, and even new tools such as Kotlin Symbol Processing We have added a built-in Android Kotlin Live template for you to use shorthand syntax to apply common Android code structures to Kotlin code. At the same time, the Lint check for Kotlin can help you ensure that Kotlin code is more in line with language habits. This tool is especially useful when you transition from the Java programming language to Kotlin.
: Is Kotlin being used internally at Google?
Within Google, we are also working hard to promote the use of Kotlin. We have more than 60 applications (such as Google Home, Drive, Maps, etc.) that have added Kotlin to the code base. There are already more than 2 million lines of Kotlin code in our huge internal code base.
: Should I migrate applications to Kotlin?
We often receive this question, but the final answer varies from person to person. If you are satisfied with the current code base and technology stack, can use your solution proficiently to manage asynchronous tasks, and have efficient error capture methods, then migrating to Kotlin may not be the right solution for you.
If you like Kotlin after trying Kotlin or learning the language through some of the courses mentioned below, and you want to take full advantage of the latest Jetpack API, then you should consider adding Kotlin to your application development. A big advantage of Kotlin is that it has good interoperability with Java. You can adopt Kotlin step by step. For example, you can try it out in the test first, then try it out in the new features, and then try to convert part of the old code in the process of getting in touch slowly.
To start migrating to Kotlin, please refer to the Codelab Tutorial-Converting to Kotlin .
: How will the Java programming language develop in Android development?
We added support for Kotlin on the basis of Java, because both languages can be compiled into the same bytecode and can coexist. We like Kotlin because it is easier to express and safer to write code. At the same time, we will continue to and promote support for the Java language . For example, in Android 11, from the newer version of OpenJDK to version 13, we have added support for many APIs. Android Studio even supports the use of some of these APIs on all Android devices, regardless of the operating system version. Check out the article to learn more about 's support for the new API in OpenJDK .
: What is the best way to learn Kotlin?
Adopting a new language is not easy, but we are trying to make it as simple as possible:
- Start with the training course . These courses are for all developers, ranging from beginners to professional developers. It contains the new online course have no programming experience 160da9acd3ee07 without programming experience 160da9acd3ee0a using Kotlin to build Android applications , as well as an advanced tutorial explaining how to use the to help you improve your Android development skills.
- All of our documentation pages include Kotlin code snippets, so you can compare the effects of running the API in two languages, and all examples have Kotlin versions.
- You can view the article and watch the video to learn about various Kotlin topics.
- For those who want use Kotlin of developers and team , please visit official document understanding of the relevant guidelines.
Since we officially added support for Kotlin 3 years ago, we have been stepping up our efforts to support this excellent language and ecosystem. Together with JetBrains, we have established a solid foundation for Kotlin to ensure the healthy development of the language, for example, through careful processes to review major changes. Our contribution does not stop here: Google has a team of engineers dedicated to researching Kotlin compilers; the Jetpack API we are building not only supports Kotlin, but also Kotlin as the preferred language; we are also committed to providing seamless Android development with Kotlin Experience.
Java is a registered trademark of Oracle Corporation and/or its subsidiaries.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。