- Should I learn Kotlin for Android and other FAQs
- Original address: medium.com/androiddeve…
- By Florina Muntenescu
- Translator: hi – DHL
- This paper has been included in the warehouse Technical-Article-Translation
This post was shared by Google development technology outreach engineer Florina Muntenescu, in which she picks up some of the most popular questions Google has received since announcing support for Kotlin. Answer whether and how you should learn Kotlin. The thesis is divided into two parts: translation and translator’s thinking.
The translation
Since we announced support for Kotlin in 2017, we’ve received a lot of questions about Kotlin on Android: How to learn Kotlin, how to use Kotlin in apps, what are good Kotlin tutorials, whether Google is using Kotlin internally, and what are the future plans for the Java language?
Q: Should I learn Kotlin?
We received many similar questions, summarized as follows:
- For Android beginners, should YOU start with Java or Kotlin?
- If you’ve mastered the Java basics, should you now switch to Kotlin to develop Android?
- For Java developers, if they want to learn Android, is it recommended to learn Kotlin or Java first?
In one short sentence, answer the above question: Yes, start learning and using Kotlin.
The long text below analyzes why you should learn and use Kotlin.
Kotlin & Android
We announced support for Kotlin on Google I/O in 2017, and since then we’ve been preparing apis, documentation, and cases for Kotlin, and after Kotlin became the preferred language for Android in 2019, We’ve come to rely more on Kotlin’s features, for example, recommending the use of coroutines for asynchronous tasks.
Kotlin-first libraries
First we added coroutine support to Jetpack(Room, LiveData, ViewModel, and WorkManager) to change the way asynchronous operations are performed on Android, The Firebase Android SDK and numerous Jetpack libraries use the Kotlin Extension Libraries (KTX).
Many libraries such as Paging 3.0 and DataStore were first developed using Kotlin. Jetpack Compose is our new, unbundled declarative UI toolkit, which was also developed using Kotlin.
Tooling
Development efficiency comes from powerful tools. As a result, we made a number of improvements to the Kotlin compilation tool, including improvements to the Kotlin JVM compiler, R8 optimizations for Kotlin, and even the development of Kotlin Symbol Processing. We added the Android Kotlin Live template, which automatically adds some generic modules to the App, and the new Kotlin Lint checker helps you check the Kotlin language specification when you transfer code from Java to Kotlin. This tool is particularly useful.
Q: Is Kotlin being used internally at Google
Internally at Google we are also recommending Kotlin, we have over 60 applications (Home, Drive, Maps, etc.) that have been developed using Kotlin, and so far we have over 2 million lines of Kotlin code in our code base.
Q: Should I migrate my App to Kotlin?
We’ve received a lot of similar questions, but it’s up to you to decide whether to migrate to Kotlin, and if you’re comfortable with your current codebase and technology stack, are skilled in using your solution to manage asynchronous tasks, and have an efficient way to catch errors, migrating to Kotlin may not be a good option.
If you like Kotlin and want to use the latest Jetpack API, then you should consider adding Kotlin to your App. One of the advantages of Kotlin is that it has great interoperability with Java and you can use it gradually in your project. You might first use Kotlin in a test case, then use Kotlin in a new function, and once you’re familiar with it, try converting Java code to Kotlin code.
If you want to migrate to Kotlin, check out our tutorial Converting to Kotlin Codelab.
Q: What about using Java on Android?
Kotlin compiles to Java code, they can coexist, we like Kotlin because it’s simpler and safer to write code with, and we’ll continue to support the Java language. For example, in Android 11, we added support for the OpenJDK 13 series of apis, and Android Studio also allows you to use some of these apis on all Android devices, Regardless of the operating system version, click here to read more about the new API.
Q: What’s the best way to learn Kotlin?
Switching to a new language isn’t easy, but we’re trying to make it easier.
- Click courses to get started with Kotlin. These courses will help you improve your use of Kotlin on Android for developers at all levels, from beginner to advanced. Android Basics in Kotlin is a new online course for the inexperienced, as well as some advanced courses on how to use coroutines.
- All of the documentation includes Kotlin snippets that make it easy to compare the two languages, and all of the examples are available in Kotlin versions.
- You can check out articles and videos to learn how to use Kotlin.
- For developers or teams want to switch to the Kotlin we offer some guidance, developers.android.com/kotlin can view the web page
It’s been three years since we announced our support for Kotlin, and we’ve been working hard to support Kotlin and the ecosystem, working with JetBrains to build a foundation for Kotlin to make sure the language works well. Not only that, we have a team inside Google working on the Kotlin compiler, we’re building a Jetpack API that not only supports Kotlin, but will support Kotlin first, and we’re working on making the Kotlin experience better on Android.
The translator think
Ever since Google announced Kotlin as the language of choice for Android development, Google has been trying to make Kotlin easier.
Anko is a very powerful library developed by JetBrains. The main purpose of Anko is to replace XML with code to generate UI layout, and it packages a series of tools to help developers quickly use Kotlin. Kotlin simplifies use on Android and has several extension libraries:
- Anko Commons: A lightweight library that includes intents, Dialogs, logging, and more
- Anko Layouts: Replacing XML with code to generate UI Layouts
- Anko SQLite: Simplifies SQLite usage
- Anko Coroutines: Developed based on Kotlinx. Coroutines, simplifies the use of Coroutines
Anko was a very successful project that made the Kotlin experience better on Android, but unfortunately in 2019 the library was no longer maintained, no longer maintained, no longer maintained because since Google announced support for Kotlin, Starting with Making Kotlin the preferred language for Android development, Google created a number of libraries to make Kotlin a better experience on Android and completely replace all parts of Anko, so the Anko team announced that it was no longer being maintained.
- Android KTX: The Kotlin extension library encapsulates a set of tools that simplify the use of Kotlin
- Jetpack Compose: a tool for building native UIs instead of XML
- Room: ORM framework provided by Google simplifies SQLite usage
- Flow: Flow is an extension of the Kotlin coroutine that allows you to run asynchronous code as if it were synchronous code, simplifying the use of coroutines and making them very powerful
MAD Skills
MAD Skills (Modern Android Development) is a new series of tutorials designed to help developers build better applications using the latest technologies. This includes Kotlin, Android Studio, Jetpack, App Bundles, and more. Google only provides videos and articles. I’ve built on this and made some extensions:
- Chinese and English subtitles have been added to the video to help students learn the new technology
- The actual combat cases will be provided, corresponding to the video one by one
- In addition to the actual case, will also provide the corresponding source analysis
Google releases a series of tutorials every few weeks, and has already started a series of videos on Navigation Components.
The bilingual video has been synced to the GitHub warehouse mad-Skills. You can watch the video first. The articles and cases are coming soon.
This is the end of the full text, if there is a helpful point like is the biggest encouragement to me!
Finally, I recommend the projects and websites I have been updating and maintaining:
-
Androidx-jetpack-practice androidX-Jetpack-practice androidX-Jetpack-Practice androidX-Jetpack-Practice AndroidX-Jetpack-Practice
-
LeetCode/multiple thread solution, language Java and Kotlin, including a variety of solutions, problem solving ideas, time complexity, spatial complexity analysis
- Job interview with major companies at home and abroad
- LeetCode: Read online
-
Android10 Source code Analysis series of articles, understand the system Source code, not only help to analyze the problem, in the interview process, is also very helpful to us, the warehouse continues to update, welcome to check android10-source-Analysis
-
Collate and translate a series of selected foreign Technical articles, each Article will have a translator’s thinking part, a more in-depth interpretation of the original text, the warehouse continues to update, welcome to visit the Technical-Article-Translation
-
“Designed for Internet people, navigation of domestic and foreign famous stations” includes news, sports, life, entertainment, design, product, operation, front-end development, Android development and so on. Welcome to check the navigation website designed for Internet people
Article history
- Kotlin’s Technique and Principle Analysis that few people know (1)
- Kotlin’s Technique and Principle Analysis that few people know (II)
- AndroidX App Startup practice and principle analysis of Jetpack’s latest member
- Jetpack member Paging3 Practice and Source Code Analysis (PART 1)
- Jetpack Member Paging3 Network Practice and Principle Analysis (II)
- Jetpack member Paging3 retrieves network page data and updates it to the database
- Jetpack member Hilt practice (1) Start a pit
- Jetpack member Hilt with App Startup (ii) Advanced article
- New member of Jetpack Hilt and Dagger are very different
- All aspects of Hilt and Koin performance were analyzed
- PokemonGo Jetpack + MVVM minimalism
- What is Kotlin Sealed? Why does Google use them all
- Kotlin StateFlow search features practice DB + NetWork
- Bye-bye buildSrc, embrace Composing builds for faster Android builds
- Jetpack DataStore SharedPreferences
- Jetpack DataStore (2)