Java becomes obsolete due to Kotlin
Kotlin vs. Java - what is suitable for what?
Key facts at a glance
- Kotlin saves on lines of code, but not on legibility.
- Thanks to Kotlin, getters and setters are moved to the compiler.
- NullPointerExceptions are also almost eliminated.
- The compiled Kotlin code is highly compatible.
What exactly is Kotlin?
Compatibility with Java
A big advantage is that the codecompatible with Java is. As an example: A code that is created with Kotlin can be addressed from Java classes. Can the other way aroundJava classes alsoin Kotlin be used. Many existing Java projects can gradually be rewritten in Kotlin without any losses. In this way, you can supplement existing projects with currently secure code without having to change the rest.
Kotlin offers the same performance with less code
Another advantage of Kotlin is thatAvoided a lot of boilerplate code becomes. Often it is part of good programming style, but it bloats the code unnecessarily. With Kotlin, simple tasks that require almost 100 lines of code in Java can be reduced to less than ten percent. In doing so, neither the readability nor the functionality is impaired. Although this is an extreme example, the Java code can usually be avoidedCut 20 to 30 percent.
💡 Good to know: Less code means fewer and fewer possible bugs,less bug fixing and complete projects faster. This not only saves nerves, but also time and money.
NullException checking is no longer necessary
To avoid program crashes, Java must first accessevery variable be checked whether the valuezero amounts. It looks like this:
These calculation steps can theoretically be avoided. In Kotlin it is possible to report directly whether an attributenullableis. When adefault value is set, this check is omitted:
Of course, a zero value can also be allowed, the corresponding test then looks like this:
If a zero value should now appear, is the result of the variablelength also the valuezero. This can be bypassed with the Elvis operator and the assignment of a standard value:
Then no longer has tozero checked and the code becomes shorter. This function is similar to that of Optionalin Java, but gives the option of abbreviation as follows:
Support for programming Kotlin
In many cases, Kotlin overtakes Java as the standard programming language for Android. thats whyKotlininto the development platformAndroid Studio integratedso you can build and test apps right there.
Since version 5, the Spring framework supports Kotlin without additional plugins. In addition, support for Kotlin is already available in the IntelliJ (Community and Enterprise) and Eclipse development platforms. So Java and Kotlin can be easily connected to each other.
Use as a native programming language is being used more and more
Kotlin is not only at home with Android programming. The tool is now also available as a native programming languageavailable for some widely used systems. Kotlin / Native can currently be used on these operating systems:
- iOS (arm32, arm64, simulator x86_64)
- MacOS (x86_64)
- Android (arm32, arm64)
- Windows (mingw x86_64, x86)
- Linux (x86_64, arm32, MIPS, MIPS little endian, Raspberry Pi)
- WebAssembly (wasm32)
In which cases is Java better suited than Kotlin?
Despite the good support and push from Google, there are still cases whereJava as a programming language does a better job. We have put together the advantages of Java in this overview.
Is Kotlin really the better Java?
Considering all the facts, that could be assumed. Java has long been the top dog when it comes to apps.Java programs run on all platformsthat have a runtime environment. This fact made Java what it is today - one of the most popular programming languages. However, it is also a fact that Java often seems confusing because of its many lines of code in smaller apps and is therefore avoided by many programmers.
The recurring security problems are also slowly causing a decline. SelfOracle recommends meanwhile theUninstalling Javawhen it is not absolutely necessary. Hearing something like this in-house can put off potential programmers. Kotlin will therefore sooner or later replace Java, at least for smaller projects. For larger projects, however, Java is still the better choice.
More articles on the topic:
End of article
- The rules of fashion really apply
- What are the cheapest 1080p 144Hz monitor
- What are the types of meaningful existence
- Is it a bad thing to be called silly?
- How would you describe an interesting life
- Where does time exist?
- What exactly do aquarium frogs eat?
- What is the closest beach to you
- Gout may cause ankle pain
- Who are Outreach io
- What are the best data science consulting firms
- It is rude to tip in Singapore
- Rachel Maddow is a polite person
- How do you define customer service
- Can users see my questions about Quora
- Why do I feel isolated 1
- Why a business intelligence career
- Are Harvard graduates special?
- Why are vegans suing Burger King
- Love to eat frog legs
- What is data intelligence
- How vegan friendly is Arizona
- Swims badly for the skin
- What temperature is sushi quality
- How is job placement in information technology
- How many 20 bills do 1440
- How dirty is Los Angeles
- Why did Yoda burn the tree
- How to fish in Galveston Bay
- How thoughts and feelings become one
- What is the nature of psychology
- What is a needy man
- What does underestimated and overrated mean?