Modern Features and less Code: the promise of young programming language Kotlin. As an Alternative to Java, takes you quickly to the universal language. Also Android, and Web developers should sit up and take notice.
From Zero to Hero: The this year’s developer survey from Stackoverflow to Kotlin revealed. For the first Time, was asked about the programming language. The result: The language ended up in the category of the most popular programming languages directly behind Rust in place. Explicitly more than 100,000 developers were asked what languages do you use on a regular basis and to continue to want to work. Only about half of the Java developers agreed that, in Kotlin there were more than 75 per cent. But where Kotlin is coming so suddenly, and why it is such a high popularity?
The Czech software company Jetbrains, which is mainly used for the Java development environment Intellij Idea is known, called the Kotlin project in 2011. The objective is to develop a better programming language than Java. The Team had a base at this time a variety of projects with a large Java Code, and was everything else than pleased. But all of the other available languages, could not meet the demands of the company, although these were more likely to have been modest, said the lead language designer of Kotlin, Andrey Breslav, in an Interview with the Blog Rebellabs 2013. Essentially, it’s gone to a smooth Integration into the existing infrastructure, efficient Tools and a good Compiler and run-time Performance. In the absence of Alternatives Jetbrains took the matter into their own hands and published finally in 2016 the first stable Version of Kotlin.
The young programming language, whose Name goes back to an island and Saint Petersburg, where Jetbrains maintains a branch, and is responsible for many modern Features. This is not to say, however, that the language would not be Mature. Finally, it was developed five years before the first stable Version has found its way to the Public.
Who deals with Java and your Challenger Kotlin, and it is clear: It makes a big difference whether a language dates to the last century and modern features were added after the other, or whether the language design from the beginning was planned with all the Features that come in use in modern team projects. This does not seem to have been confirmed only in the case of Kotlin, because the top-ranked programming language in the Stackoverflow rankings were published in its first version, all within the last ten years. This applies to Rust and Go, Typescript and Swift. All are more popular than the classic programming languages. Python is connected to the third place is the only exception.
Java and Kotlin: Not an Either-Or
Who wants to has a large Java Code Base and its existing project, at a stroke, completely re-write the Kotlin provides a charming and Transition. Because the Jetbrains programming language is compatible to Java. So can be called in the Kotlin Code without problems, a Java class and Vice versa. The Source Code of Kotlin is, by the way, in the same way as the Java, Bytecode is translated, which is then read by the Java Virtual Machine (in short: the JVM).
But if Kotlin has to be for the JVM translated, could not write his project also, as before, directly in Java? That’s probably not entirely wrong, however, Kotlin, the veteran Java and many other languages – some of it ahead of time. This is not least due to the fact that the language is developed by a company such as Jetbrains, the seven IDE in the market proven Expertise in programming languages and through the many years of experience with Java-projects-and-white, where, in practice, the Shoe pinches.
Probably the most fundamental advantage of Kotlin compared to Java, the reduction of redundant Code. A look at a classic example of the project-oriented programming can illustrate this: the Writing of a certain class for an object. In Java must be written typically in addition to the attributes of any lot Setter and Getter methods, and an Equals, Tostring and Hashcode method. A class a couple of more attributes, has a few lines of Code come together there. Also during the subsequent Complement other attributes not only re-Setter – and Getter must be added to the methods, but also the other functions.
However, a project has, of course, far more than one such class. There must then be written to the Whole in a similar way again, or better yet, be copied together. One of the most common programming paradigm that says: “Don’t Repeat Yourself.” However, the developer should keep in mind, if the language design fail?
A view in Kotlin shows that it is different, and is revealed by the way, one of the most popular Features of the language: data classes. There must be written neither for Setter and getter methods for the other above – mentioned features Extra Code. For the above example Java equivalent in Kotlin written neckline requires only a single line of Code. This contrast is also reflected in some of the other components of the language design. So Jetbrains is a further Problem in many languages: – Null-Pointer Exceptions. Program crashes, which occur during the term, because a Variable is accessed, which refers to the Emptiness. They are particularly excerpts in a rarely used Code-tricky, because the error occurs like only then, if the application has already been published. In Kotlin can occur during the term of such an error simply, if you are also permitted explicitly – and what you should do good Kotlin Code only rarely.
Because Normal variables may not be set in Kotlin by default to Zero. If the is sometimes necessary supplies with the Kotlin Syntax. A question mark, which is hung behind the type of the variable to the null reference. Now the Compiler gives direct access to the value of such a Variable is an error: The Variable could show into the Void. More intelligent Syntax allows the access to such a Variable, without the classic If-not-Null-query must be used.
What sounds complicated, is in practice a more than useful tool, as there are simply fewer unforeseen things can happen. Programmer greater control over the program code and what happened to him during the term.