Kotlin 简明教程

Kotlin - Architecture

Kotlin 是一种编程语言,拥有自己的体系结构来分配内存并向最终用户提供高质量的输出。

Kotlin is a programming language and has its own architecture to allocate memory and produce a quality output to the end user.

以下是 Kotlin 编译器将以不同方式工作的不同场景。

Following are the different scenarios where Kotlin compiler will work differently.

  1. Compile Kotlin into bytecode which can run on JVM. This bytecode is exactly equal to the byte code generated by the Java .class file.

  2. Whenever Kotlin targets JavaScript, the Kotlin compiler converts the .kt file into ES5.1 and generates a compatible code for JavaScript.

  3. Kotlin compiler is capable of creating platform basis compatible codes via LLVM.

  4. Kotlin Multiplatform Mobile (KMM) is used to create multiplatform mobile applications with code shared between Android and iOS.

kotlin architecture

每当两个字节编码文件(Kotlin 和 Java 的两个不同程序)在 JVM 上运行时,它们可以相互通信,这就是在 Kotlin 中为 Java 建立可互操作特性的方式。

Whenever two byte coded files ( Two different programs from Kotlin and Java) runs on the JVM, they can communicate with each other and this is how an interoperable feature is established in Kotlin for Java.

Kotlin Native

Kotlin/Native 是一种将 Kotlin 代码编译为本机二进制文件(可在没有虚拟机的情况下运行)的技术。Kotlin/Native 支持以下平台:

Kotlin/Native is a technology for compiling Kotlin code to native binaries, which can run without a virtual machine. Kotlin/Native supports the following platforms:

  1. macOS

  2. iOS, tvOS, watchOS

  3. Linux

  4. Windows (MinGW)

  5. Android NDK

  6. Many more…​

Kotlin/Native 主要设计用于在虚拟机不受欢迎或不可用的平台上进行编译,例如嵌入式设备或 iOS。

Kotlin/Native is primarily designed to allow compilation for platforms where virtual machines are not desirable or possible, for example, embedded devices or iOS.

很容易将编译的 Kotlin 代码包含到用 C、C++、Swift、Objective-C 和其他语言编写的现有项目中。

It is easy to include a compiled Kotlin code into existing projects written in C, C++, Swift, Objective-C, and other languages.