Introduction
Dart is a statically typed, garbage-collected language created by Google that compiles to native ARM and x64 code, JavaScript, and WebAssembly. It is the primary language for Flutter and increasingly used for server-side, CLI tools, and full-stack web applications.
What Dart Does
- Compiles ahead-of-time to native machine code for fast startup and low memory on mobile and desktop
- Compiles to optimized JavaScript and WebAssembly for web deployment
- Provides a JIT compiler for fast development cycles with hot reload in debug mode
- Offers sound null safety that eliminates null reference exceptions at compile time
- Includes an async/await model with streams and isolates for concurrent programming
Architecture Overview
Dart runs on the Dart VM in development mode with JIT compilation for sub-second hot reload. For production, the AOT compiler generates native binaries (ARM, x64) or JavaScript/Wasm output. The type system enforces sound null safety, meaning the compiler guarantees that non-nullable variables never hold null at runtime. Concurrency uses isolates, which are independent memory heaps that communicate through message passing, avoiding shared-state bugs. The dart:io library provides server-side I/O, while dart:html and package:web target browser environments.
Self-Hosting & Configuration
- Install the Dart SDK standalone or as part of the Flutter SDK
- Manage dependencies with
pubspec.yamland thedart pubpackage manager - Configure analysis options in
analysis_options.yamlfor linter rules and strictness levels - Use
dart compile exefor native executables ordart compile jsfor web deployment - Set up server applications with shelf or dart_frog frameworks and deploy as native binaries
Key Features
- Sound null safety prevents null reference errors by distinguishing nullable and non-nullable types at the language level
- Hot reload via JIT compilation enables instant UI updates during development without losing app state
- Single codebase compiles to native mobile (iOS/Android via Flutter), web (JS/Wasm), desktop, and server
- Rich standard library with async primitives, collections, JSON handling, HTTP client, and file I/O
- Strong tooling with built-in formatter (dart format), analyzer, test runner, and documentation generator
Comparison with Similar Tools
- TypeScript — targets JavaScript only; Dart compiles to native code, JS, and Wasm with sound type safety
- Kotlin — JVM-based with Kotlin Multiplatform for cross-platform; Dart compiles natively and is the foundation of Flutter
- Swift — Apple-only ecosystem; Dart is cross-platform with first-class support for iOS, Android, web, and desktop
- Go — excels at server-side concurrency with goroutines; Dart adds client-side strengths with Flutter and hot reload
- JavaScript — ubiquitous but loosely typed; Dart offers sound null safety, AOT compilation, and better tooling for large codebases
FAQ
Q: Is Dart only useful with Flutter? A: No. Dart is used for server-side apps (with shelf, dart_frog), CLI tools, and standalone web apps. Flutter is the most popular use case, but Dart stands on its own.
Q: How does Dart's performance compare to native languages? A: AOT-compiled Dart approaches C-level performance for many workloads. On mobile, Flutter/Dart apps run at 60-120 fps with native compilation.
Q: What is sound null safety? A: Sound null safety means the type system guarantees that a non-nullable variable can never be null at runtime. The compiler enforces this statically, eliminating an entire class of runtime errors.
Q: How large is the Dart package ecosystem? A: The pub.dev registry hosts over 50,000 packages covering HTTP clients, database drivers, state management, serialization, and more.