Computers, Dart

Dart Compilation Techniques

Dart Compilation Techniques

Dart is a compiled programming language that supports different types of compilation techniques for different platforms. Dart’s compiler lets you run code in many ways:

  • Native platform
  • Web Platform

Native platform

Dart apps targeting mobile and desktop devices, Dart includes both a Dart VM with Just-in-Time (JIT) compilation and an Ahead-of-Time (AOT) compiler for producing machine code.

Web platform

Dart apps targeting the web, Dart can compile for development or production purposes. Its dart2js compiler translates Dart code into JavaScript code. This code can run on all major web browsers.

Dart Compilation

Some of the compilation techniques that Dart uses are as follows:

  • JIT Compilation(Just In Time)
  • AOT Compilation(Ahead of Time)
  • Dart Native

The choice between AOT and JIT compilation depends on the target platform and the specific requirements of the Dart application.

 

Dart Compilation Techniques

JIT

JIT compilation is the default compilation technique in Dart. Dart JIT compiler compiles the Dart code to intermediate bytecode, which is then executed by the Dart VM (Virtual Machine). JIT-compiled code runs on a Dart Virtual Machine (VM) and is interpreted at runtime.

JIT compilation is used during development. It allows the hot-reloading of code. This feature enables Dart developers to see changes in their code immediately without restarting the application. JIT compilation enables fast development cycles. However, the code is not as optimized as the AOT compiler.

AOT

AOT compilation technique involves compiling Dart code into highly optimized native machine code ahead of time. This native code can be executed without the need for the Dart runtime. This is the compilation mode used for deploying production applications, as it offers better performance compared to the JIT compiler.

AOT compilation is used for optimizing performance and reducing startup times in production apps. Flutter framework uses AOT compilation for releasing Flutter apps for mobile platforms such as iOS and Android
mobile platforms.