Dart

On this page 8

Dart is a general-purpose, statically typed programming language created at Google and optimized for building client applications, most prominently user interfaces with the Flutter framework. Among programming languages, it stands out for one toolchain that offers fast development cycles with hot reload and ahead-of-time compilation to native machine code for release builds.

Dart uses a familiar C-style syntax, class-based object orientation and sound null safety, so developers who know Java, C#, Kotlin or TypeScript usually read it within days. The language is published as the ECMA-408 standard, although its practical evolution is driven by the open-source Dart SDK.

How Dart compiles and runs code

Dart code runs through several compilation strategies chosen by the target platform and the stage of development. During development, the Dart VM uses just-in-time (JIT) compilation, which enables stateful hot reload: changed source code is injected into a running application in roughly a second without losing the current screen state.

For production, the toolchain performs ahead-of-time (AOT) compilation to ARM or x64 machine code. AOT output starts quickly, has predictable performance and needs no interpreter on the device, which is why mobile app stores accept Flutter applications without restriction. For the web, Dart compiles to optimized JavaScript or to WebAssembly using the WasmGC proposal.

The following table summarizes the main compilation targets and their typical use.

TargetTool or modeTypical useKey property
JIT on the Dart VMdart runDevelopment, scriptingHot reload, rich debugging
AOT native codedart compile exeMobile, desktop, serversFast startup, no runtime compiler
JavaScriptdart compile jsWeb browsersTree shaking, minification
WebAssemblydart compile wasmModern browsersRequires WasmGC support
Kernel snapshotdart compile kernelTool distributionPlatform-neutral intermediate form
Dart compilation targets

Type system and core language features

Dart has a sound static type system, meaning that a variable declared as int can never hold a string at run time. Since Dart 3, null safety is mandatory: a type such as String excludes null, while String? explicitly allows it. The compiler uses this guarantee for flow analysis and for removing unnecessary null checks in compiled code.

Type inference keeps code concise, since var and final infer the type from the initializer. Generics are reified, so type arguments remain available at run time, unlike the erased generics of Java. Dart 3 also added records, pattern matching and sealed classes, which support exhaustive switch expressions over closed type hierarchies.

The table below lists the features that most shape everyday Dart code.

FeatureWhat it providesExample syntax
Sound null safetyCompile-time protection from null errorsString? name;
MixinsReuse of behavior across class hierarchiesclass A with Logger
Extension methodsNew methods on existing typesextension on String
RecordsLightweight anonymous tuples(int, String) pair
PatternsDestructuring and exhaustive matchingswitch (shape) { ... }
Class modifiersControl over extension and implementationsealed, final, base
Core Dart language features

Concurrency with isolates and async code

Dart handles concurrency with isolates instead of shared-memory threads. Each isolate has its own heap and a single-threaded event loop, and isolates communicate only by passing messages through ports. This design eliminates data races and most locking problems by construction.

Within one isolate, asynchronous work uses Future, Stream and the async and await keywords. Waiting for a network response therefore does not block the user interface, but CPU-heavy work such as parsing a large JSON file still blocks the event loop unless it moves to a background isolate, for example with Isolate.run.

Dart competes most directly with Kotlin, Swift, TypeScript and JavaScript for client application work. Its distinguishing feature is one codebase for several platforms, whereas Kotlin and Swift are primarily tied to Android and Apple ecosystems.

LanguageTypingMain runtime targetsTypical strength
DartStatic, sound, null-safeNative code, JavaScript, WasmCross-platform UI with Flutter
KotlinStatic, null-safeJVM, Android, native, JavaScriptAndroid and server development
SwiftStatic, null-safeNative code for Apple platformsiOS and macOS applications
TypeScriptStatic but unsoundJavaScriptLarge web codebases
JavaScriptDynamicBrowsers, Node.jsUniversal web reach
Dart compared with neighboring languages

A frequent misconception is that Dart is only a Flutter language. It also runs command-line tools and server applications on the Dart VM, although its server ecosystem is far smaller than those of Go, Java or Node.js.

When to choose Dart and its limitations

Dart is the right choice when a team wants one user interface codebase for iOS, Android, web and desktop. It is a weaker choice when a project depends on a large existing ecosystem in another language or needs deep platform-specific integration on a single operating system.

SituationRecommendationReason
Cross-platform mobile appDart with FlutterShared UI and logic, native AOT performance
Single-platform iOS appUsually SwiftDirect access to newest Apple APIs
SEO-heavy content websiteUsually HTML and JavaScriptFlutter web renders to a canvas
Command-line toolingDart is viableSingle native executable output
Data science workUsually PythonFar richer library ecosystem
Decision guide for adopting Dart
  • Package ecosystem size: pub.dev is strong for Flutter but thinner for server, scientific and enterprise libraries.
  • Native interop overhead: platform features require plugins, platform channels or dart:ffi bindings.
  • Binary size: AOT applications bundle the runtime and framework, adding several megabytes.
  • Isolate cost: spawning isolates and copying messages is heavier than sharing memory between threads.

Origins and evolution of the language

Google announced Dart in 2011 as a structured alternative for web development, and Dart 1.0 shipped in 2013 with an optional type system. Browser vendors never adopted a native Dart VM, so the language found its lasting role when Flutter selected Dart for its fast reload cycle and AOT output.

Dart 2 (2018) made the type system sound, Dart 2.12 (2021) introduced sound null safety, and Dart 3 (2023) made null safety mandatory while adding records, patterns and class modifiers. Each major step improved reliability and compiler optimization at the price of migration work for older code.

In everyday language

Dart is a language for writing apps, made by Google. Its main appeal is that a team can write an app once and run it on phones, computers and the web. While programmers work, Dart lets them see changes almost instantly. When the app is finished, Dart turns it into fast code that each device understands directly.

Think of it as writing one recipe that every kitchen can cook from, with a strict checker that catches missing ingredients before cooking starts. That checking is a big part of why Dart apps tend to crash less from simple mistakes.

Seen in the real world

A regional bank with a small mobile team needs a new customer app for both iOS and Android. Instead of hiring two separate teams for Swift and Kotlin, it writes the app in Dart with Flutter. Developers use hot reload to adjust screens during design reviews, and sound null safety catches missing account fields at compile time rather than in production.

For release, the code is compiled ahead of time to ARM machine code for both stores. Balance calculations that parse large transaction histories run in a background isolate, so scrolling stays smooth. The bank ships one codebase to two platforms and keeps feature parity between them with roughly the staff a single native team would need.