The Dart SDK provides multiple compilers tailored for different platforms and use cases. Understanding which compiler to use and when is essential for optimizing your application’s performance and deployment strategy.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dart-lang/sdk/llms.txt
Use this file to discover all available pages before exploring further.
Compilation Modes
Dart supports several compilation modes to balance development speed, runtime performance, and deployment requirements:Just-in-Time (JIT) Compilation
JIT compilation compiles Dart code to machine code at runtime. This mode is primarily used during development for fast iteration cycles with features like hot reload. Advantages:- Fast development cycles
- Hot reload support
- Optimizations based on runtime profiling
- Best peak performance through adaptive optimization
- Development and testing
- Dart VM in development mode
- Flutter development mode
Ahead-of-Time (AOT) Compilation
AOT compilation compiles Dart code to native machine code before execution. This produces standalone executables or platform-specific binaries. Advantages:- Fast startup time
- Predictable performance
- Smaller runtime footprint
- Suitable for platforms that prohibit JIT
- Production mobile apps (iOS, Android)
- Production desktop apps
- Server deployments requiring fast startup
Available Compilers
The Dart SDK includes several specialized compilers:dart2js
The Dart-to-JavaScript compiler produces optimized JavaScript for web deployment.- Target: JavaScript (ES5/ES6)
- Use case: Production web applications
- Features: Tree-shaking, minification, deferred loading
dart2wasm
The Dart-to-WebAssembly compiler generates WebAssembly modules for modern web browsers.- Target: WebAssembly (Wasm)
- Use case: High-performance web applications
- Features: Near-native performance, compact binaries
dartdevc
The Dart development compiler generates modular JavaScript with a focus on fast incremental compilation.- Target: JavaScript (ES6)
- Use case: Web development and debugging
- Features: Fast compilation, source maps, modular architecture
Native Compilers (AOT/JIT)
The Dart VM’s native compilers produce machine code for native platforms.- Target: x64, ARM, ARM64
- Use case: Native applications (mobile, desktop, server)
- Features: Adaptive optimization, snapshots
Choosing the Right Compiler
- Web Development
- Mobile Apps
- Desktop & Server
Development: Use dartdevc for fast incremental compilation and debugging.Production: Use dart2js for optimized JavaScript or dart2wasm for WebAssembly support in modern browsers.
Compiler Pipeline
All Dart compilers share a common front-end that handles:- Parsing - Converting Dart source to an Abstract Syntax Tree (AST)
- Type checking - Verifying type correctness
- Kernel generation - Producing Kernel AST (intermediate representation)
Performance Considerations
- Startup time: AOT < Wasm < JIT
- Peak performance: JIT ≈ AOT > Wasm > JavaScript
- Code size: Wasm < AOT < JavaScript (minified)
- Compilation speed: dartdevc > JIT > dart2wasm > AOT > dart2js