I have to preach a wave of Kotlin today.

Source: Internet
Author: User

Kotlin has been the official language of Google for more than a year, but in addition to announcing the extreme popularity of that month, the back of life has returned to calm. Many small partners follow the pace of Google's father, but also to Kotlin have a more or less understanding, GitHub also has a considerable part of the Kotlin open source projects.

But perhaps after the understanding, still have a considerable part of the small partners, and the same as the southern dust, just in the Kotlin very fire that period of time, simple to understand, just like the original small program. Then life is still returning to peace, still staying on to it to know the extent.

Start by recommending recent projects that have been updated on GitHub

But after more than a week of detailed learning, I have aiyagirl the Open source project on GitHub, and have opened up a new branch entirely using the Kotlin language.

Aiyagirl Address: Github.com/nanchen2251/aiyagirl

There may be a lot of small partners still do not know Aiyagirl, this is the South dust last year on GitHub on the open source of an app, the function is relatively simple, mainly using Retrofit && RxJava && MVP mode, data from the code home GANK.I O, currently on GitHub there will be nearly 1k Stars.

GitHub has a lot of different features of the complete architecture APP, they each have their own advantages, I am very touched, you see here, this is my lucky.

Now I have added a Kotlin branch, has completely adopted Kotlin rewrite completed, I hope you can like.

If you are not very familiar with RxJava, I highly recommend you can look at my rxjava2examples Open Source Library, we use code && Blog on RxJava2 way to show you RxJava 2 of the various operators and some of the use of details, hope will not let you down. At present, more than 500,000 of reading shows that RxJava is really a concern, if you are not RxJava2, I advise you to go through the document, write a Demo.

Rxjava2examples Address: Github.com/nanchen2251/rxjava2examples

GitHub and the public number I will maintain and expect you to communicate with me.

Because I have encountered a variety of difficult problems, everywhere to ask the answer.

Then I, perhaps just as you are now.

And I, still on this road silently forward ~

Seems a bit tricky, but as long as I still want to recommend Aiyagirl, because I believe that both Java implementation and Kotlin implementation of the contrast, will make your Kotlin learning more than a multiplier.

Why Preach Kotlin

Still have to go back to the point, before perhaps for various reasons, I have not put Kotlin study on the agenda, but struggle on the path of Python. But since the interview has been repeatedly asked Kotlin, I have to keep up with the pace of society, began to Kotlin study, after all, I am an Android development Ah!

A few days down, to Kotlin do not dare to say very well, but it is really the simplicity and ease of use to attract to explode, whether it is its excellent functional programming support, or it is extremely efficient programming way, let me always excited.

Simply use a little bit of code to show you how flexible it is.

For example, we have a bunch of code in Java:

int score =Some score; String grade;Switch (score) {Case10:Case9:grade ="Excellent";Breakcase 8: case 7: case 6:grade = " good "; break; case  5: case 4:grade =  "OK"; break; case  3: case  2: case 1:grade = " Fail "; break; default:grade =  "Fail";}        

When you're done with Kotlin, you'll find out, how can it be so simple?

var score = // some scorevar grade = when (score) {    9, 10 -> "Excellent" in 6..8 -> "Good" 4, 5 -> "OK" in 1..3 -> "Fail" else -> "Fail"}

Well, there's support for data classes that makes people crazy.

PublicClassDeveloper {private String name;Privateint age;PublicDeveloper(String name,int age) {THIS.name = name;This.age = age; }Public StringGetName() {return name; }PublicvoidSetName(String name) {THIS.name = name; }PublicIntGetage() {return age; }PublicvoidSetage(int age) {This.age = age; }@OverridePublicBooleanequals(Object o) {if (this = = O)ReturnTrueif (o = =null | | GetClass ()! = O.getclass ())ReturnFalse Developer Developer = (Developer) o;if (age! = developer.age)ReturnFalsereturn name! =Null? Name.equals (developer.name): Developer.name = =Null }@Override public int hashcode() { int result = name! = null? Name.hashcode (): 0; result = + * result + age; return result;} @Override public String toString() { return ' developer{' + ' name= ' + ' + name + ' \ ' + ", age=" + Age + '} ';}}              

What will happen to Kotlin?

data class Developer(val name: String, val age: Int)

Yes, you're not mistaken, just one line of code.

It's always irresponsible to stick to code, so I'll give you two examples, and if you like, join our Kotlin army.

Whether Kotlin will replace Java

Many small partners in the backstage asked me this question, oh ...

This is really hard to say, this world is not saying a thing good, it will inevitably be widely used. The appearance of a thing, there will be a group of people to promote, but also will be someone to stop, can only see who do more in place it ~

Extra words

Well, since the Kotlin out, the development of things become extremely uncontrolled, a lot of referrals on a good big wave flow, and the southern dust so late to preach, should not be beaten it?

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.