Kotlin
Kotlin is a modern but mature programming language designed to make developers happier. It is simple, secure, interoperable with Java and other languages, and provides multiple ways to reuse code across multiple platforms for efficient programming.
Kotlin Profile
Kotlin is a statically typed programming language that runs on the Java Virtual machine and is known as the Swift of the Android world, designed and developed by JetBrains and open source.
Kotlin can be compiled to Java bytecode or JavaScript for easy running on devices without a JVM.
At Google I/O 2017, Google announced Kotlin as the official development language for Android.
Kotlin is a static programming language developed by JetBrains for the JVM, Android, and browser, and is currently open source under license from the Apache Organization. With Kotlin, developers can easily develop mobile Android applications, server applications, and JavaScript applications. Kotlin can compile code into Java bytecode or JavaScript for easy running on devices without a JVM.
Kotlin comes from the name of an Island, the full name is Kotlin Island, which is located near St. Petersburg, Russia. The name Kotlin comes from the fact that the main development work of Kotlin is done by the team located in the St. Petersburg branch.
In the era of pure imperative programming, Sun created Java and the standard library, but Sun has never provided a good IDE for Java. In this situation, IBM timely launched an IDE called Eclipse, which became a weapon against Sun.
Over the past decade, Eclipse has triumphed over one rival after another (JBuilder, NetBeans, etc.) with its open source and extensible platform (OSGi) to establish itself as the standard development environment for Java. However, like all successful products, Eclipse has had its share of problems along the way. In recent years, Eclipse's market share has been slowly declining under the impact of a series of products from JetBrains.
As a popular IDE provider, JetBrains provides developers with mainstream software development environments: IntelliJ IDEA, WebStorm, PyCharm, etc. These ides almost cover the mainstream programming languages.
Prior to developing Kotlin, the JetBrains team had been using Java to create their IDE as well as using Java for business logic development. Kotlin was developed because JetBrains engineers found a number of problems while developing applications in Java. In order to improve the development efficiency and solve the problems caused by the use of Java development, after learning from Scala, Groovy and other languages, they decided to develop a programming language dedicated to solving Java problems.
JetBrains understands the needs and pains of developers, and strives to provide developers with the most practical and efficient IDE, while also providing developers with new programming languages to solve current technical problems.
Why use Kotlin
Nowadays, in the field of software development, in addition to the more popular artificial intelligence technology and big data technology, mobile development is still a branch of the field of attention, and the most important technology of mobile development is Android development. Java as the official standard language for Android development, its syntax design ideas still stay in the era of pure imperative language, in the context of functional language, Java seems a little outdated. Although with the release of Java8 and Java9 versions, Java is also moving towards a functional language, but the market share of Java8 and Java9 is not high, and many projects are still stuck in the era of Java 6. For Android developers in particular, the benefits of functional programming seem too far away. So, using Kotlin is the best choice.
As a star language, Kotlin has long been a hot topic in Android development before it was officially announced as a supported language by Android, and many open source projects use Kotlin development. It is for these reasons that at this year's Google I/O conference, Google named Kotlin as the official support language for Android development. In the recent TIOBE hot programming languages list, it once entered the top 50 programming languages, and has also earned over 19K stars on Github. I believe that with the continuous release of Kotlin version and performance optimization, Kotlin will definitely go further.
In the process of creating the Kotlin language, Kotlin took inspiration from a number of programming languages, such as Java, Scala, Groovy, and can be said to be a wide range of strengths. Code written in Kotlin not only compiles faster, but also implements the same functionality with much less code than Java implementations.
The main advantages of using Kotlin are:
Cross-platform development capability
Because Kotlin is developed on the JVM, it also has Android development, Web browser development, and Native development capabilities. In regard to the development of Native Native, is currently Kotlin official open source on making the Native source (making address: https://github.com/JetBrains/
kotlin-native). In terms of Web development, Kotlin can be used in conjunction with the Spring framework, and it can also be compiled and generated JavaScript modules, which are convenient to compile and run on some JavaScript virtual machines.
Open source
In the 1980s, the free software movement began, and open source software provided a steady stream of power for the rapid development of the software industry. For a new technology, a new language, open source can find bugs more quickly, so as to use the power of open source to promote the development of new technologies faster. In the open source space, Java is a good example, from language standards, to Core apis, virtual machines, developer tools, these can find the shadow of openness.
100% compatible with Java
Kotlin is 100% interoperable with Java, which means that you can still use Kotlin to call Java's existing code or libraries, or you can use both Java and Kotlin to write mixed code. At the same time, in order to facilitate the transition of the project, JetBrains provides development tools to easily implement the conversion of Java code to Kotlin.
Null pointer safety
In the process of programming in Java, the most talked about topic is how to avoid nullpointerexceptions. For the null pointer problem, Kotlin has special syntax to avoid the null pointer problem.
The language is simple and the learning cost is low
Kotlin's syntax is simple and intuitive, and looks a lot like Scala, but is much easier to learn. At the same time, Kotlin uses a lot of syntactic sugar to make the code more concise. Kotlin does not follow a specific programming specification; it borrows many of the advantages of both functional and object-oriented styles.
Lambda expression support
Functional programming is the development direction of software technology, and Lambda is the most basic content of functional programming, therefore, in the recent Java 8 version, Java to add Lambda expression itself is in line with the development direction of technology. One of the most intuitive improvements with Lambda is that you don't have to write a lot of anonymous inner classes anymore. In fact, there are many more performance benefits due to the nature of functional programming itself. For example, the code is more readable, higher-order functions introduce the concept of function composition, and so on.
In addition, collection operations have been greatly improved with the introduction of Lambda. For example, the stream API was introduced to combine basic functional programming concepts such as map, reduce, and filter with Java collections. In most cases, Java programmers can dispense with complex for, while, if, and other logical statements when working with collections.
However, the use of Lambda expressions is not all good and bad, as Anders Hejlsberg, the father of C#, said in the article "Programming language Trends", the future of programming languages will gradually integrate their own characteristics, rather than just a simple declarative language or a simple functional programming language.
Type inference
With Kotlin programming, developers don't have to explicitly specify a type for each variable, and the compiler can derive the data type of a certain parameter at compile time, making the code more concise. Java also introduced this feature in the recent Java 8 release.
Support for custom DSLS
A domain-specific Language (DSL) is a computer language that focuses on a Specific problem Domain. Unlike General Purpose Computer Languages (GPL), domain-specific languages are used only in certain domains.
The DSL language allows developers to express and solve domain problems in a more elegant and concise way. For example, gradle is a dsl defined in groovy. Kotlin's lambda system makes it ideal for creating DSLS.
IDE environment support
As a JetBrains product, JetBrains' numerous ides provide seamless support for Kotlin development and collaborate with each other.
Because of these advantages of Kotlin, at this year's Google I/O conference, Google listed Kotlin as the first language for Android development. At the first Kotlin Conference recently held in San Francisco, Kotlin officially announced that it will add features to support iOS development in version 1.2. This is not going to be a full-stack language rhythm.
Kotlin compared to Java
As a star programming language in the era of object-oriented programming, Java has won the support of Oracle, Google, Apache, Eclipse Foundation and other major manufacturers in an open ecological environment, and the support of these major manufacturers has accelerated the construction of the Java ecosystem. For a time, the Java ecosystem is extremely prosperous, and a variety of excellent open source frameworks emerge in an endless stream, the more famous ones are: Spring Boot, Spring Cloud, Hadoop/Spark and Kafka and other excellent frameworks.
Although the Java ecosystem is extremely powerful, as a product of the era of pure imperative languages, Java is increasingly backward in terms of types, syntax, and programming paradigms compared to the current popular functional programming languages. Therefore, to find a language that can break through these limitations of Java and coexist harmoniously with Java has become the direction of the software industry. Fortunately, James Gosling, the father of Java, had these problems in mind when he created the Java language, so at the beginning of the design, he intentionally separated the Java language from the runtime environment JVM. The JVM is responsible for the interaction with the operating system, masking the details of the specific operating system, which allows a system developed on the JVM to run on any operating system. Today, many emerging languages are running on the JVM, Groovy, Scala, Kotlin, Clojure are some of the best.
So, what are the advantages of Kotlin over Java?
Easier to learn
Kotlin is an object-oriented programming language with a functional programming mindset that has many of the characteristics of a static programming language, making it easier to learn.
Faster compilation speed
When compiling Kotlin code for the first time, it takes longer than Java, and when compiling incrementally, Kotlin is faster than Java.
Better performance
Due to the very similar bytecode structure, Kotlin applications run at a speed similar to Java. With Kotlin's support for inline functions, code that uses Lambda expressions generally runs faster than code written in Java.
Null pointer safety
One of Kotlin's biggest advantages over Java is that it can effectively solve the null pointer problem, after all, not everyone can make a "billion dollar mistake".
Cross-platform development features
In addition to developing mobile Android apps, Kotlin can also be used for server-side framework development and Web browser development.
Seamless integration with IDE
In the latest version of Android Studio 3.0 released by Google, Kotlin has been integrated by default, and for some older versions, Kotlin can also be integrated by means of plug-ins. Therefore, using the IDE provided by JetBrains can provide the best environment support for Kotlin development.
Of course, in addition to some of the advantages mentioned above, Kotlin also has many of the programming features of modern static programming languages, such as type inference, multi-paradigm support, nullability representation, extension functions, DSL support, etc., which Java has only added in recent versions.
In addition, Kotlin also provides the Kotlin Android extension and Anko library for Android development. Among them, the Kotlin Android extension is a compiler extension that lets developers get rid of the cumbersome findViewById() calls in their code and replace them with synthetic compiler-generated properties. Anko is a wrapper library developed by JetBrains around the Android API to build UI layouts as an alternative to traditional XML.