Why kotlin

With the increasing use of Kotlin in Android development and the ongoing feud between Google and Oracle, it’s a foregone conclusion that Kotlin will become the dominant language for Android development in the future.

Kotlin is also an excellent high-level language with many features that are interlinked with other languages, including Groovy, Swift, Dart, etc. Learning another language after Learning Kotlin can be a bit of an insight.

Development tool IDEA

Why IDEA and not Android Studio

Idea has the option of creating Java projects that can test kotlin code features very quickly, with almost no single compilation time.

If you test Kotlin in an Android project, it’s fine, but each time you wait for the project to compile, it takes too long.

Check out Kotlin’s Bytecode

Idea has a built-in plugin to view kotlin’s compiled bytecode. Double-click Shift and type Kotlin Bytecode

Because bytecodes are generally difficult to learn quickly, we can choose Decompile to generate Java code to help understand some of the implementations of Kotlin’s features.

This is important!! This is important!!

Version selection

Select IDEA Community Edition for free,

Download address

Select the chip type for MAC

engineering

  • File-new – Creates a Java project
  • kotlin/jvm

The script to choose

  • Create a new Kotlin file, mainly without class
  • You can freely run and test Kotlin’s features

fun main(){
    println("hello world")
}
Copy the code

Script debugging

While testing the Kotlin feature, we create multiple kotlin files, and if we need to run different Kotlin files, we need to do two things

  • Declare the main method in the file, which isfun main(){}It is actually converted to a Java entry function class so that the compiler can recognize it as a Kotlin file that can be executed separately
  • Select Edit Configuration from run Configuration. In the configuration window that is displayed, enter the name of your new file, for example, test.kt. Then enter TestKt in uppercase to debug the code in the test.kt script