History
Dart was unveiled at the GOTO conference indart2native
. This extended native compilation to the Linux, macOS, and Windows desktop platforms. Earlier developers could create new tools using only Android or iOS devices. With this extension, developers could deploy a program into self-contained executables. The Dart SDK doesn't need to be installed to run these self-contained executables. The Flutter toolkit integrates Dart, so it can compile on small services like backend support.
Dart 3.0 was released in May 2023 with changes to the type system to require sound null safety. This release included new features like records, patterns, and class modifiers.
Dart can compile to WebAssembly since version 3.4.
Specification
Dart released the 5th edition of its language specification on April 9, 2021. This covers all syntax through Dart 2.10. A draft of the 6th edition includes all syntax through 2.13Deploying apps
The Dart software development kit (SDK) ships with a standalone Dart runtime. This allows Dart code to run in aDeploying to the web
Dart 3 can deploy apps to the web as either JavaScript or WebAssembly apps. Dart supports compiling to WebAssembly .JavaScript
: To run in mainstreamdartc
. It was deprecated in Dart 2.0.
:The second Dart-to-JavaScript compiler was frog. Written in Dart, it was introduced in 2013 and deprecated in 2020. This should not be confused with Dart Frog, an open-source Dart framework for building backend systems from Very Good Ventures.
:The third Dart-to-JavaScript compiler is dart2js
. Introduced in Dart 2.0, the Dart-based dart2js
evolved from earlier compilers. It intended to implement the full Dart language specification and semantics. Developers use this compiler for production builds. It compiles to minified JavaScript.
:The fourth Dart-to-JavaScript compiler is dartdevc
. Developers could use this compiler for development builds. It compiles to human-readable JavaScript. On March 28, 2013, the Dart team posted an update on their blog addressing Dart code compiled to JavaScript with the dart2js
compiler, stating that it now runs faster than handwritten JavaScript on Chrome's V8 JavaScript engine for the DeltaBlue benchmark.
:Prior to Dart 2.18, both dart2js
and dartdevc
could be called from the command line. Dart 2.18 folded these functions into the Dart SDK. This removed the direct command line wrappers but kept the two compilers. The webdev serve
command calls the dartdevc
compiler. The webdev build
command calls the dart2js
compiler.
:The Dart SDK compiles to JavaScript in two ways.
:To debug code, run webdev serve
to compile a larger JavaScript file with human-readable code. Dart-generated JavaScript can be debugged using Chrome only.
webdev build
to compile a minified JavaScript file.
WebAssembly
:With the Dart 3.22 release, Google announced support for compiling Dart code to WebAssembly. Full support for Wasm requires adoption of the WasmGC feature into the Wasm standard. Chrome 119 supports WasmGC. Firefox 120 and later could support WasmGC, but a current bug is blocking compatibility.Deploying to native platforms
Dart can compile to native machine code for macOS, Windows, and Linux as command line tools. Dart can compile apps with user interfaces to the web, iOS, Android, macOS, Windows, and Linux using the Flutter framework.Self-contained executable
:Self-contained executables include native machine code compiled from the specified Dart code file, its dependencies, and a small Dart runtime. The runtime handles type checking and garbage collection. The compiler produces output specific to the architecture on which the developer compiled it. This file can be distributed as any other native executable.Ahead-of-time module
:When compiled ahead of time, Dart code produces performant and platform-specific modules. It includes all dependent libraries and packages the app needs. This increases its compilation time. The compiler outputs an app specific to the architecture on which it was compiled.Just-in-time module
:When compiled just in time, Dart code produces performant modules that compile fast. This module needs the Dart VM included with the SDK to run. The compiler loads all parsed classes and compiled code into memory the first time the app runs. This speeds up any subsequent run of the app. The compiler outputs an app specific to the architecture on which it was compiled.Dart kernel module
:When compiled as a kernel module, Dart code produces a machine-independent format called the Dart Intermediate Representation (Dart IR). The Dart IR bytecode format can work on any architecture that has a Dart VM. This makes this format very portable and quick to compile, but less performant than other compilation outputs.Concurrency
To achieve concurrency, Dart uses isolated, independent workers that do not share memory, but use message passing, similarly to Erlang processes (also see actor model). Every Dart program uses at least one isolate, which is the main isolate. Since Dart 2, the Dart web platform no longer supports isolates, and suggests developers use Web Workers instead.Null safety
Starting with Dart 2.12, Dart introduced sound null safety. This serves as a guarantee that variables cannot return a null value unless it has explicit permission. Null safety prevents the developer from introducing null-pointer exceptions, a common, but difficult to debug, error. With Dart 3.0, all code must follow sound null safety.Data storage
Snapshot files, a core part of the Dart VM, store objects and other runtime data. ;Script snapshots :Dart programs can be compiled into snapshot files containing all of the program code and dependencies preparsed and ready to execute, allowing fast startups. ;Full snapshots :The Dart core libraries can be compiled into a snapshot file that allows fast loading of the libraries. Most standard distributions of the main Dart VM have a prebuilt snapshot for the core libraries that is loaded at runtime. ;Object snapshots :Dart uses snapshots to '' serialize'' messages that it passes between isolates. As a very asynchronous language, Dart uses isolates for concurrency. An object generates a snapshot, transfers it to another isolate, then the isolate deserializes it.Editors
On November 18, 2011, Google released ''Dart Editor'', an open-source program based on Eclipse components, for macOS, Windows, andChrome Dev Editor
In 2013, the Chromium team began work on an open source, Chrome App-based development environment with a reusable library of GUI widgets, codenamed Spark. The project was later renamed as Chrome Dev Editor. Built in Dart, it contained Spark which is powered by Polymer. In June 2015, Google transferred the CDE project to GitHub as a free software project and ceased active investment in CDE. The Chrome Dev Editor project was archived on April 24, 2021.DartPad
To provide an easier way to start using Dart, the Dart team createDevelopment tools
The Dart DevTools, written in Dart, include debugging and performance tools.Flutter
Google introduced Flutter for native app development. Built using Dart, C, C++ and Skia, Flutter is an open-source, multi-platform app UI framework. Prior to Flutter 2.0, developers could only target Android, iOS and the web. Flutter 2.0 released support for macOS, Linux, and Windows as a beta feature. Flutter 2.10 released with production support for Windows and Flutter 3 released production support for all desktop platforms. It provides a framework, widgets, and tools. This framework gives developers a way to build and deploy mobile, desktop, and web apps. Flutter works with Firebase and supports extending the framework through add-ons called packages. These can be found on their package repository, pub.dev. JetBrains also supports a Flutter plugin.Example
A Hello, World! example:Influences from other languages
Dart belongs to the ALGOL language family. Its members include C, Java, C#, JavaScript, and others. The method cascade syntax was adopted from Smalltalk. This syntax provides a shortcut for invoking several methods one after another on the same object. Dart's mixins were influenced by Strongtalk and Ruby. Dart makes use of isolates as a concurrency and security unit when structuring applications. The Isolate concept builds upon the Actor model implemented in Erlang. In 2004, Gilad Bracha (who was a member of the Dart team) and David Ungar first proposed Mirror API for performing controlled and secure reflection in a paper. The concept was first implemented in Self.See also
* Google Web Toolkit * TypeScript, a strongly-typed programming language that transpiles to JavaScript * Flutter, an open-source UI software development kit for cross-platform applicationsReferences
Bibliography
* * *External links
*