Home  >  Article  >  Java  >  Can kotlin replace java?

Can kotlin replace java?

(*-*)浩
(*-*)浩Original
2019-05-11 15:25:304911browse

When it comes to Android app development, which programming language comes to your mind first? I guess you will immediately think of Java, after all, most Android applications are developed in Java.

Recommended tutorial: Java tutorial.

But since its launch at the Google I/O conference two years ago, Kotlin has now also taken its place in the field of Android application development.

What is Kotlin? What are its prospects?

Kotlin

Kotlin is a statically typed open source programming language that efficiently runs on the Java Virtual Machine (JVM). Kotlin is developed by JetBrains and strongly supported by Google.

In a recent Jexenter survey, Kotlin ranked sixth on the list of hottest technology trends. The latest statistics from App Brain show that the Kotlin language held a 25.30% market share among the top apps in 2018 and accounted for 40.76% of new app installs. Today, business giants such as Pivotal, Atlassian, Pinterest, Evernote, and Uber are using Kotlin for Android application development.

Advantages of Kotlin

1. Extremely efficient

Kotlin’s syntax is simple and intuitive, requiring less code and less time to write and deploy programs It is also shorter, which greatly improves the development efficiency of the development team. Therefore, developers can quickly develop Android apps.

2. Ability to call Java code

This feature not only benefits developers, but is also good for companies with large Java code bases.

3. Easy to maintain

Kotlin is strongly supported by a variety of IDEs, such as Android studio, etc., which facilitates developers to maintain code.

4. Reliable

The latest version of Kotlin is compatible with all previous old versions, which solves the biggest pain point for Android developers: the need to deal with multiple versions.

5. Easy to learn

Since it does not require too much background knowledge of mobile application development, developers can more easily start learning Kotlin.

6. Android Studio support

Android Studio provides strong support for a variety of extension tools, and developers can use both languages ​​at the same time.

Disadvantages of Kotlin

1. Slow compilation speed

Many developers have mentioned that the compilation speed of Kotlin code is erratic, and sometimes it fails to compile Very quickly, sometimes very slowly.

2. Limited community support

The Kotlin developer community is relatively small, so the learning resources it provides are limited, and developers will face many unanswered questions.

3. Developer scarcity

The number of developers in Kotlin is relatively small, so the number of popular Android applications developed with Kotlin is limited.

Java

Java Considered one of the best programming languages ​​for developing applications, December 2018 The TIOBE index shows Java ranking first among programming languages.

Advantages of Java over Kotlin

1. Portability

Java can run on almost any system, so most of the programs written in Java Android application.

2. Huge community

With the help of large technical communities such as GitHub and Stack Overflow, developers can get almost all solutions to Java code problems.

3. Cross-platform

Java is not limited to Android application development, but also supports cross-platform application development.

4. Rich resources

Android developers can use Java’s rich libraries and SDK to improve their development efficiency.

Shortcomings of Java

1. Slow running speed

Compared with other languages, Java requires more memory and Much slower.

2. Cumbersome

Compared with other languages, if you want to implement the same function, Java requires more code. This not only takes more development time, but also makes bugs more likely to occur.

Why do you need kotlin?

Empty type safety

Lambda expression

Extension method

Type derivation

Competent java can do Everything is even harder

without a semicolon! ! ! !

Mom, you don’t have to worry about my NullPointerExpection anymore, because usually, if your project has a null pointer, an error will be reported after running it, but if you use kotlin, the compilation will directly fail, but the NullPointerExpection is missing. Is coding a lot less fun? Don’t know what a lambda expression is? I don't know either! ! ! But with Kotlin, you don’t have to worry about not knowing Lambda. At that time, I gave up because I couldn’t understand it. But in Kotlin, if you don’t understand it, come talk to me and I’ll beat you to death! ! Hum~~~

Androidstudio 3.0 automatically adapts to Kotlin. Of course, now you can install plug-ins, or use IntellJ directly. We will talk about this later. We can directly convert all the java files in our project into Kotlin files. Finally, Kotlin has a Advantage, no semicolon! ! No semicolon! ! No semicolon! ! Say important things three times, and you don’t have to worry about too many parentheses or where to add semicolons~~~

Comparison between Java and Kotlin

Java
Kotlin
Static member
String template
Non-class primitive type
Single instance
Non-private domain
Empty safety
Wildcard type
Extension function
Check Exceptions Smart Casts

##Summary:

kotlin essence It is another expression type of Java. According to the current development situation, it is following the banner of Java. It should be used more mixedly in the next few years, but it cannot replace it

The above is the detailed content of Can kotlin replace java?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn