How to view Kotlin as the official Android support development language?

Source: Internet
Author: User

Google IO 2017 announced that Kotlin will become the official Android language. A time friends Circle and Android Circle are all kinds of brush screen. Of course, I also take advantage of the release of an article "Why I want to use Kotlin", really fiercely rubbed a wave of heat (although this will be despised). Now that the Android circle is agitated, even if it turns a blind eye to Kotlin, it doesn't look like a qualified Android programmer.

This article attempts to look at this matter from an objective and comprehensive point of view, and try our best to provide a more rational point of view for our reference.

Why do you choose Kotlin

I think there are two reasons why Google chooses Kotlin.

    1. In order to gradually get rid of the patented rogue Oracle. From last year's turn to OpenJDK, to the current support for Kotlin as the official language, some sense is to get rid of Oracle with 9 lines of code extortion to get sky-time compensation.

    2. Choose Kotlin, deserve it, this honor it deserves to have. Kotlin really has won the endorsement of many overseas companies and developers for its practicality and efficiency, such as the Jake God of Square has been pushing Kotlin. Kotlin has at least 2 years of practice in applied production environments abroad (non-jetbrains in-house practical applications). In mobile development, Android programmers are always lucky compared to iOS programmers, because we have a lot of great tools (Android studio, etc.), and choosing Kotlin is the consistent way that Google provides developers with efficient development tools.

What it means to become an official Android language developer
    • Official: Tool Support (Android Studio 3.0 with Kotlin), official propaganda (instructional videos, keynote speeches, etc.)
    • For the community, Kotlin versions of libraries and frameworks have sprung up
    • For Java, once with the help of Android this spring breeze, really let twilight it again brilliant, now and in the future in the Android field is match, Java in the Android development language market share will drop. But this is not necessarily a bad thing, there is competition to better progress.
    • For Android developers, we have one more language option to develop Android, and those who have been tempted by the uncertainty of the future will be relieved to use the Kotlin. Having a kotlin means that development efficiency should be improved.
    • For teams, this often brings up a choice of issues, use Kotlin or not, that's a question. There are always people in the team who want to try Kotlin, while others are less interested. Due to the historical burden, the interest of the team members, the use of Kotlin and Java long-term coexistence of existing projects is a practical solution. The new project should encourage the use of Kotlin, but it also requires a combination of team competencies and other factors.
What is the charm of Kotlin?

Kotlin has many features, such as simplicity, safety and practicality, high development efficiency and readability, and better functional programming support.

1. Concise, Kotlin code is indeed more concise than Java, such as type inference, omit the end of the semicolon, and so on, but this is far from being the reason why we switched to Kotlin.

2. Security, which is a very important feature of Kotlin. Kotlin is a null pointer safe, jetbrains do a very clever thing, they will run to the null pointer detection ahead of the compile time, the main way is to add any? This nullable type, after using Kotlin, our program's null pointer will be significantly improved.

3. Practical and efficient. The practical manifestation of Kotlin in

    • The introduction of object allows us to better apply a singleton pattern
    • The introduction of data class avoids our handwriting getter/setter/tostring and other methods
    • The introduction of parameter defaults and named parameters avoids unnecessary method overloading
    • Support extension methods, so that we can save a lot of necessary code

The 4.Kotlin introduces Lambda,streams API and functional programming support.

    • Lambda expressions can save us from creating many anonymous inner classes (note that the current kotlin based on JVM6,LAMBDA expressions will still be translated into the internal class form in the bytecode phase)
    • The Streams API combines lambda expressions and method references so that our code handles one thing in the form of a description, rather than the way the command is implemented.
    • Kotlin supports OOP (object-oriented programming) and FP (functional programming), the language itself is not limited, gives us the freedom to choose, Kotlin friendly support for FP, so we write more stable, easy to test, no side effects of methods and code

5. Readability from the objective, Kotlin syntax and characteristics of the code to make it more descriptive. However, it is important to point out that code readability relies on the writer's coding qualities and abilities .

For me personally, the two features of higher-order functions and methods are truly beneficial. The method extension gives me a sense of creativity, which is unmatched by the util approach of Java species.

Whether Kotlin will replace Java

This is hard to say, because the world is not a good thing, it will inevitably be widely used. The promotion of a thing depends on a group of people, but the resistance also often comes from a group of people, but the former is not the same crowd.

From the subjective perspective of this problem, I would like to see this phenomenon happen. The reason is not because I prefer kotlin, but because I prefer to see things progressing and becoming excellent, so even if one day Kotlin be replaced by a better language, I am very welcome.

Who is right for the first application Kotlin

Kotlin is suitable for multiple platforms and does not restrict learners. Anyone with a willingness to learn can acquire the language.

However, considering that the domestic Kotlin resources are not rich enough, the network is not smooth and so on, so many people have become eating melon masses to wait and see.

However, for a project and a team, there is always a need for the first person to advance. And the process is not going well, including

    • First you need to know enough about Kotlin
    • You need to convince the team that during this time you will receive a lot of challenges, sometimes you will be very depressed and angry
    • You need to provide a series of information or sharing, such as how to configure, sample code, troubleshooting, etc.
    • Sometimes even you work part-time to do mentor coaching, which means that your other work on hand needs to be interrupted

The above-mentioned promotion Kotlin views are part of the reference from life is great and everything would be Ok, Kotlin are here (Google I/O ' 17) Christina Lee (Pinterest Soft Ware Engineer, one of the foreign Kotlin Beauty evangelists) shares content.

Although Kotlin is very good, it is not easy to push the Kotlin application in the project, because it is normal for new things, like the Meiji Restoration looks very bright and successful, but its process of change is not smooth, first bloody of the inverted curtain movement, The six-year-old war that marked the end of the samurai era, after decades of hard work, has been a success.

Therefore, I think it is necessary to have the following points about which people are suitable for the first application of Kotlin

    • It's important that Java technology and fundamentals are better.
    • English is better, because the current Kotlin information is almost all in English, of course, also recommended to see English
    • Willing to take on the project team to advance work, be patient, dare to challenge, responsible
Some concerns about the application of the Kotlin project

Some of the concerns about Kotlin applications in the project are now being thought of. These concerns are not comprehensive at the moment, but they have been put forward in the hope that we can evade and improve.

1. The code written is not Kotlin style. To solve this problem, still need to learn and think more

2. The abuse of extension methods, Kotlin extension method is very good, we can expand a lot of ways to compensate for some of the framework of imperfect, but we need to be careful in the extension, we must put the appropriate method to the appropriate type, not to simply increase the non-conforming to certain classes should not have responsibilities. Specific needs of the following two points best

    • Choose the most abstract class addition method within a reasonable range, for example, if we want to add a longtoast to the activity, think about whether it would be better to put it in a more abstract context.
    • It is also not possible to add methods that are not relevant to the current class for convenience, such as we want to add a simple dialog extension method for each context, which is obviously not very reasonable because there is a problem with the non-UI context.
What are the core competencies of Android programmers?

After the Kotlin came out, two different sounds were heard:

    • Good, finally can have reason to switch to Kotlin, write code more efficient. You can gradually start abandoning java.
    • WTF, but also learn new language, feel good tired, will not be kotlin after interview will be pass off it.

The presence of these two different sounds has forced us to think about the core competencies of Android programmers. So what exactly is the core competency of Android programmers?

Android programmers and other programmers, and even other professions, do not have two, I think this competitiveness performance in the ability to solve problems . To have this ability, we rely heavily on our accurate understanding of the problem and technology and our solid foundation.

A programming language is essentially a tool, a good tool can bring better results, but how to use it well, and improve efficiency and quality to the highest, is still a major reliance on the ability of developers.

The use of good tools, more emphasis on the consolidation of the foundation and enhance the nature of things to understand the ability, I think this can make us more competitive.

In summary terms, Kotlin is a better tool without it and does not affect our daily Android development work. But I still suggest that developers and teams try the language and seize the little certainty that is near.

Extra words

The development of things more and more appear to be uncontrolled, the introduction of Kotlin and not optimistic about the Kotlin people gradually differentiated out, more accurately, even this matter has become a change from the right to the person.

Kotlin become the official language of the Android news came out, suddenly came out a lot of Kotlin as speculation hot spots, of course, there are some people who do not like these practices, they think the former deliberately overstating the Kotlin. Thus the discussion becomes more and more biased from the thing to the human aspect. What I want to say is that, just as businessmen pursue profits, capitalists grab surplus value, speculators rub hot spots and invite others to criticize, which is normal, but we can not let the discussion out of the nature of the problem, we need to return.

Many people say that Kotlin is nothing but a lot of grammatical sugar, no breakthrough

Yes,Kotlin is a lot of grammatical sugars . It is necessary to simply popularize the concept of grammatical sugars (excerpt from Wikipedia)

In computer science, syntactic sugar was syntax within a programming language that's designed to make things easier to Rea D or to express. It makes the language "sweeter" for human use:things can is expressed more clearly, more concisely, or in an alternative Style that some may prefer.

By definition, the purpose of the syntax sugar is to make the code simpler and more readable.

The decision to use so many syntactic sugars in addition to Kotlin is a reason for the fact that the class file generated by Kotlin compilation is targeted to JVM 6 (based on JVM 6 as a tradeoff), such as when we use lambda in Kotlin, It is not possible to compile into invokedynamic instructions, because that will cause the JVM6 to not be recognized at all, so it is often done by translating them into the form of internal classes.

The use of syntactic sugar, and its purpose is good, after all, it is true to introduce the developer's Code volume.

Kotlin is a practical language, this is its gene, it is not an academic language, its goal is to alleviate the burden of developers. It's good for Android, because most Android programmers are doing engineering.

There's nothing wrong with JVM-based

Kotlin is a JVM-based programming language, but there is nothing wrong with the JVM-based programming language. (J) The emergence of VMS is nothing more than a balanced result. Under the premise of sacrificing partial execution efficiency, it provides some abstraction and accelerates the efficiency of the developer. This kind of tradeoff is actually more advantageous to the human side, this is also the programming language development tendency and the goal

Kotlin in the domestic application of the road is a long way to repair far XI. So it is more necessary to really practice that the people who go to the pits start on board to produce more articles that really drive the Kotlin application, and share such meaningful actions.

For more information about Kotlin and Android content, please visit my standalone blog technology Little Black House

How to view Kotlin as the official Android support development language?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.