View all my open source projects "open Source Labs"
Welcome to join my QQ group: "201055521", this blog client source download "please click"
Summary
I first stated that I had not used Kotlin for a long time, and I wrote these articles almost at the same time as I was studying. I haven't tried any other alternative languages, such as go and Scala, so if you're really thinking about a different development language, I suggest you search for other people's comments on these languages.
This article original, reprint please specify address: http://blog.kymjs.com/
Body
Recently, a new understanding of a programming language, called Kotlin. Kotlin is an open source project that JetBrains initially used for in-house development, and this jetbrains company may not have heard of it, but IntelliJ idea you must have heard that, yes, the mom of your Android studio is the company's product. Kotlin is based on the JVM, the reason to introduce Kotlin is because it is very interoperability with Java and the IDE has good support for it, and of course, the most important, it is relative to Java as the language itself superiority.
Why use Kotlin
If a programming language is not enough to change your programming thinking, then it is a failure. We have been skilled in C, Obj-c, Java and other static language, it is time to learn the swift, Go, Kotlin this dynamic language.
For the second reason, Kotlin does omit a lot of code writing, as well as its unique language features.
The third reason, compared with Sala, go and so on, Kotlin can be perfectly compatible with existing Java code, that is to say, like we usually use the volley, kjframeforandroid, okhttp and other development framework, in Kotlin language can still run normally.
IDE Selection
is still my style, practice-oriented, this article first for everyone to explain the development of an Android app with Kotlin Hello World.
First of all, Ide,kotlin also supports the use of Eclipse development, although I am eclipse brain powder, but here I do not say, why you understand, eclipse old. Here is a tutorial on using Kotlin to develop Android apps in Androidstudio.
Development environment Configuration
1, start androidstudio,command+, open preference (under Windows Please find the corresponding shortcut), search plugin, open the plugin interface, click Browserepository, Search Kotlin, Double-click Install Kotlin and Kotlin Extension for Android. The first one is the Kotlin language support package, and the second is the enhanced package of features we'll use later.
If you are unable to download because of the wall, there is an offline package for the first plugin below my new blog home page (http://kymjs.com/).
2, with the language support package, we can create a new Android project. After creating a normal Android project, click Code->convert Java file to Kotlin file. The default shortcut key is a bit lengthy, here I directly set the shortcut key to Command+5, later conversion is much more convenient.
After the conversion we will find that our original Java class has changed, observing the file extension, you can see from. java into a. kt file.
3. Click Tool->kotlin->configure Kotlin in Project
(Incidentally, many of the online tutorials are translated from these four articles, said that need to manually configure the Build.gradle, but these four articles is a long time ago, and now the development of Kotlin can be configured with as one key, we choose the latest 0.12.613 version (perhaps you will see a lot of kotlin m12,m11 and other nouns on the internet, That means the 0.12 here is similar to ANDROID17,ANDROID22,JAVA8, so the version is called)
4, click OK, next is a long wait, Androidstudio is downloading the relevant configuration (can turn over the wall of the proposed wall), after the download is complete, we can run the Android app.
The above is Kotlin for Android HelloWorld, the next we explain the basic grammar of Kotlin and the development of the odd trick.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Developing Android with Kotlin