Dart is a programming language designed for client development, such as for the web and
mobile app
A mobile application or app is a computer program or software application designed to run on a mobile device such as a phone, tablet, or watch. Mobile applications often stand in contrast to desktop applications which are designed to run on ...
s. It is developed by
Google
Google LLC () is an American Multinational corporation, multinational technology company focusing on Search Engine, search engine technology, online advertising, cloud computing, software, computer software, quantum computing, e-commerce, ar ...
and can also be used to build server and desktop applications.
It is an
object-oriented
Object-oriented programming (OOP) is a programming paradigm based on the concept of " objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
,
class-based
Class-based programming, or more commonly class-orientation, is a style of object-oriented programming (OOP) in which inheritance occurs via defining '' classes'' of objects, instead of inheritance occurring via the objects alone (compare pr ...
,
garbage-collected language with
C-style
syntax. It can
compile
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily ...
to either
machine code
In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ver ...
or
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
, and supports
interfaces
Interface or interfacing may refer to:
Academic journals
* ''Interface'' (journal), by the Electrochemical Society
* ''Interface, Journal of Applied Linguistics'', now merged with ''ITL International Journal of Applied Linguistics''
* '' Inte ...
,
mixin
In object-oriented programming languages, a mixin (or mix-in) is a class that contains methods for use by other classes without having to be the parent class of those other classes. How those other classes gain access to the mixin's methods depen ...
s,
abstract class
In programming languages, an abstract type is a type in a nominative type system that cannot be instantiated directly; a type that is not abstract – which ''can'' be instantiated – is called a ''concrete type''. Every instance of an abstra ...
es,
reified generics
Generic or generics may refer to:
In business
* Generic term, a common name used for a range or class of similar things not protected by trademark
* Generic brand, a brand for a product that does not have an associated brand or trademark, other ...
and
type inference
Type inference refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some branches of computer science and linguistics. ...
.
History
Dart was unveiled at the GOTO conference in
Aarhus
Aarhus (, , ; officially spelled Århus from 1948 until 1 January 2011) is the second-largest city in Denmark and the seat of Aarhus Municipality. It is located on the eastern shore of Jutland in the Kattegat sea and approximately northwes ...
, Denmark, October 10–12, 2011. The project was founded by
Lars Bak
Lars Ytting Bak (born 16 January 1980) is a Danish former professional road bicycle racer, who rode professionally between 2002 and 2019 for the Fakta, , , , and squads. From 2022, Bak will act as team manager for UCI Women's WorldTeam .
Ba ...
and Kasper Lund. Dart 1.0 was released on November 14, 2013.
Dart initially had a mixed reception and the Dart initiative has been criticized by some for fragmenting the web, due to the original plans to include a Dart VM in Chrome. Those plans were dropped in 2015 with the 1.9 release of Dart to focus instead on compiling Dart to JavaScript.
Dart 2.0 was released in August 2018, with language changes including a type system.
Dart 2.6 introduced a new extension, dart2native, which extends 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 it also becomes possible to compose a program into self-contained executables. According to company representatives, it's no longer necessary to have the Dart SDK installed, as the self-contained executables can now start running in a few seconds. The new extension is also integrated with the
Flutter
Flutter may refer to:
Technology
* Aeroelastic flutter, a rapid self-feeding motion, potentially destructive, that is excited by aerodynamic forces in aircraft and bridges
* Flutter (American company), a gesture recognition technology company acqu ...
toolkit, making it possible to use the compiler on small services (for example, backend support).
;Standardization
Ecma International
Ecma International () is a nonprofit standards organization for information and communication systems. It acquired its current name in 1994, when the European Computer Manufacturers Association (ECMA) changed its name to reflect the organizatio ...
has formed technical committee TC52 to work on standardizing Dart, and inasmuch as Dart can be compiled to standard JavaScript, it works effectively in any modern browser. EI approved the first version of the Dart language specification in July 2014 at its 107th General Assembly, and a second edition in December 2014. The latest specification i
available here
Usage
Dart code can be run in four ways:
;Web : To run in mainstream
web browser
A web browser is application software for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's screen. Browsers are used on ...
s, Dart relies on a
source-to-source compiler
A source-to-source translator, source-to-source compiler (S2S compiler), transcompiler, or transpiler is a type of translator that takes the source code of a program written in a programming language as its input and produces an equivalent sou ...
to
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
. According to the project site, Dart was "designed to be easy to write development tools for, well-suited to modern app development, and capable of high-performance implementations." In a web browser, the code is precompiled into JavaScript using the dart2js compiler, making it compatible with all major browsers with no need for browsers to adopt it. By optimizing the compiled JavaScript output to avoid expensive checks and operations, code written in Dart can, in some cases, run faster than equivalent code handwritten in JavaScript idioms.
;Stand-alone:The Dart
software development kit
A software development kit (SDK) is a collection of software development tools in one installable package. They facilitate the creation of applications by having a compiler, debugger and sometimes a software framework. They are normally specific ...
(SDK) ships with a stand-alone Dart VM, allowing Dart code to run in a
command-line interface environment. As the language tools included in the SDK are written mostly in Dart, the Dart VM is a critical part of it. These tools include the ''dart2js'' compiler and a
package manager
A package manager or package-management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer in a consistent manner.
A package manager deals w ...
called ''pub''. Dart ships with a complete
standard library allowing users to write fully working system apps, such as custom web servers.
;Ahead-of-time compiled:Dart code can be
AOT-compiled into machine code (native instruction sets). Apps built with
Flutter
Flutter may refer to:
Technology
* Aeroelastic flutter, a rapid self-feeding motion, potentially destructive, that is excited by aerodynamic forces in aircraft and bridges
* Flutter (American company), a gesture recognition technology company acqu ...
, a mobile app SDK built with Dart, are deployed to app stores as AOT-compiled Dart code.
;Native:Dart 2.6 includes the ''dart2native'' compiler to compile to self-contained, native executable code. Before Dart 2.6, this feature exposed this capability only on
iOS
iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone; the term also include ...
and
Android mobile devices via
Flutter
Flutter may refer to:
Technology
* Aeroelastic flutter, a rapid self-feeding motion, potentially destructive, that is excited by aerodynamic forces in aircraft and bridges
* Flutter (American company), a gesture recognition technology company acqu ...
.
Isolates
To achieve concurrency, Dart uses isolates, independent workers that do not share memory, but use
message passing
In computer science, message passing is a technique for invoking behavior (i.e., running a program) on a computer. The invoking program sends a message to a process (which may be an actor or object) and relies on that process and its supporti ...
,
similarly to
Erlang processes (also see
actor model
The actor model in computer science is a mathematical model of concurrent computation that treats ''actor'' as the universal primitive of concurrent computation. In response to a message it receives, an actor can: make local decisions, create mor ...
). 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
A web worker, as defined by the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG), is a JavaScript script executed from an HTML page that runs in the background, independently of scripts that may ...
instead.
Snapshots
Snapshots, a core part of the Dart VM, are files that 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 is a very
asynchronous
Asynchrony is the state of not being in synchronization.
Asynchrony or asynchronous may refer to:
Electronics and computing
* Asynchrony (computer programming), the occurrence of events independent of the main program flow, and ways to deal wit ...
language, using isolates for
concurrency
Concurrent means happening at the same time. Concurrency, concurrent, or concurrence may refer to:
Law
* Concurrence, in jurisprudence, the need to prove both ''actus reus'' and ''mens rea''
* Concurring opinion (also called a "concurrence"), a ...
. Since these are workers that pass messages, it needs a way to ''
serialize
In computing, serialization (or serialisation) is the process of translating a data structure or object state into a format that can be stored (e.g. files in secondary storage devices, data buffers in primary storage devices) or transmitted (e ...
'' messages. This is done using a
snapshot
Snapshot, snapshots or snap shot may refer to:
* Snapshot (photography), a photograph taken without preparation
Computing
* Snapshot (computer storage), the state of a system at a particular point in time
* Snapshot (file format) or SNP, a file ...
, which is generated from a given object, then transferred to another isolate for deserializing.
Native mobile apps
Google has introduced
Flutter
Flutter may refer to:
Technology
* Aeroelastic flutter, a rapid self-feeding motion, potentially destructive, that is excited by aerodynamic forces in aircraft and bridges
* Flutter (American company), a gesture recognition technology company acqu ...
for native mobile app development on
Android,
iOS
iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone; the term also include ...
and
Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ...
. Flutter is a mobile app SDK, complete with framework, widgets, and tools, that gives developers a way to build and deploy mobile apps, written in Dart. Flutter works with
Firebase
Firebase is a set of hosting services for any type of application (Android, iOS, Javascript, Node.js, Java, Unity, PHP, C++ ...). It offers NoSQL and real-time hosting of databases, content, social authentication (Google, Facebook, Twitter an ...
and other databases like sqflite provided by flutter at pub.dev and other mobile app SDKs, and is open source.
Compiling to JavaScript
The Dart SDK contains two Dart-to-JavaScript compilers. During development
dartdevcsupports quick refresh cycles. For the final version of an app
dart2jsproduces deployable JavaScript.
The first compiler to generate JavaScript from Dart code was dartc, but it was deprecated. The second Dart-to-JavaScript compiler was Frog. It was written in Dart, but never implemented the full semantics of the language. The third Dart-to-JavaScript compiler was dart2js. An evolution of earlier compilers, dart2js is written in Dart and intended to implement the full Dart language specification and semantics.
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.
Editors
On November 18, 2011, Google released Dart Editor, an open-source program based on
Eclipse
An eclipse is an astronomical event that occurs when an astronomical object or spacecraft is temporarily obscured, by passing into the shadow of another body or by having another body pass between it and the viewer. This alignment of three ce ...
components, for
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
,
Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ...
, and
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
-based
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s. The editor supports
syntax highlighting
Syntax highlighting is a feature of text editors that are used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms. ...
,
code completion
Autocomplete, or word completion, is a feature in which an application predicts the rest of a word a user is typing. In Android and iOS smartphones, this is called predictive text. In graphical user interfaces, users can typically press the tab ...
, JavaScript compiling, running web and server Dart applications, and
debugging
In computer programming and software development, debugging is the process of finding and resolving ''bugs'' (defects or problems that prevent correct operation) within computer programs, software, or systems.
Debugging tactics can involve in ...
.
On August 13, 2012, Google announced the release of an Eclipse plugin for Dart development.
On April 18, 2015, Google announced that the Dart Editor would be retired in favor of the
JetBrains
JetBrains s.r.o. (formerly IntelliJ Software s.r.o.) is a Czech software development company which makes tools for software developers and project managers. , the company has offices in Prague; Munich; Berlin; Boston, Massachusetts; Amsterdam ...
integrated development environment
An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools a ...
(IDE), which is now the recommended IDE for the language. The Dart plugin is available for
IntelliJ IDEA
IntelliJ IDEA is an integrated development environment (IDE) written in Java for developing computer software written in Java, Kotlin, Groovy, and other JVM-based languages. It is developed by JetBrains (formerly known as IntelliJ) and is a ...
,
PyCharm
PyCharm is an integrated development environment (IDE) used for programming in Python. It provides code analysis, a graphical debugger, an integrated unit tester, integration with version control systems, and supports web development with Dja ...
,
PhpStorm
JetBrains s.r.o. (formerly IntelliJ Software s.r.o.) is a Czech software development company which makes tools for software developers and project managers. , the company has offices in Prague; Munich; Berlin; Boston, Massachusetts; Amsterdam; ...
and
WebStorm
JetBrains s.r.o. (formerly IntelliJ Software s.r.o.) is a Czech software development company which makes tools for software developers and project managers. , the company has offices in Prague; Munich; Berlin; Boston, Massachusetts; Amsterdam; ...
. This plugin supports many features such as syntax highlighting, code completion, analysis, refactoring, debugging, and more. Other plugins are available for editors like
Sublime Text
Sublime Text is a shareware text and source code editor available for Windows, macOS, and Linux. It natively supports many programming languages and markup languages. Users can customize it with themes and expand its functionality with ...
,
Atom
Every atom is composed of a nucleus and one or more electrons bound to the nucleus. The nucleus is made of one or more protons and a number of neutrons. Only the most common variety of hydrogen has no neutrons.
Every solid, liquid, gas ...
,
Emacs
Emacs , originally named EMACS (an acronym for "Editor MACroS"), is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, ...
,
Vim
Vim means enthusiasm and vigor. It may also refer to:
* Vim (cleaning product)
* Vim Comedy Company, a movie studio
* Vim Records
* Vimentin, a protein
* "Vim", a song by Machine Head on the album ''Through the Ashes of Empires''
* Vim (text ed ...
and
Visual Studio Code
Visual Studio Code, also commonly referred to as VS Code, is a source-code editor made by Microsoft with the Electron Framework, for Windows, Linux and macOS. Features include support for debugging, syntax highlighting, intelligent code compl ...
.
Chrome Dev Editor
In 2013, the Chromium team began work on an open source,
Chrome App
A Google Chrome App, or commonly just Chrome App, was a certain type of (non-standardized) web application that ran on the Google Chrome
Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for ...
-based development environment with a reusable library of
GUI widget
A graphical widget (also graphical control element or control) in a graphical user interface is an element of interaction, such as a button or a scroll bar. Controls are software components that a computer user interacts with through di ...
s, codenamed Spark. The project was later renamed as Chrome Dev Editor. It was built in Dart, and 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. As of April 2019 Chrome Dev Editor is no longer in active development.
DartPad
The Dart team created DartPad at the start of 2015, to provide an easier way to start using Dart. It is a fully online editor from which users can experiment with Dart
application programming interfaces (APIs), and run Dart code. It provides syntax highlighting, code analysis, code completion, documentation, and HTML and CSS editing.
SIMD
In 2013, John McCutchan announced that he had created a performant interface to single instruction, multiple data (
SIMD
Single instruction, multiple data (SIMD) is a type of parallel processing in Flynn's taxonomy. SIMD can be internal (part of the hardware design) and it can be directly accessible through an instruction set architecture (ISA), but it should ...
) instruction sets for Dart.
The interface consists of two types:
* Float32×4, 4× single precision floating point values
* Uint32×4, 4× 32-bit unsigned integer values
Instances of these types are immutable and in optimized code are mapped directly to SIMD registers. Operations expressed in Dart typically are compiled into one instruction with no overhead. This is similar to C and
C++ intrinsics. Benchmarks for 4×4
matrix multiplication
In mathematics, particularly in linear algebra, matrix multiplication is a binary operation that produces a matrix from two matrices. For matrix multiplication, the number of columns in the first matrix must be equal to the number of rows in the ...
,
3D vertex transformation
In linear algebra, linear transformations can be represented by matrix (mathematics), matrices. If T is a linear transformation mapping \mathbb^n to \mathbb^m and \mathbf x is a column vector with n entries, then
T( \mathbf x ) = A \mathbf x
for s ...
, and
Mandelbrot set
The Mandelbrot set () is the set of complex numbers c for which the function f_c(z)=z^2+c does not diverge to infinity when iterated from z=0, i.e., for which the sequence f_c(0), f_c(f_c(0)), etc., remains bounded in absolute value.
This ...
visualization show near 400% speedup compared to scalar code written in Dart.
Example
A
Hello, World! example:
void main()
A function to calculate the nth
Fibonacci number
In mathematics, the Fibonacci numbers, commonly denoted , form a integer sequence, sequence, the Fibonacci sequence, in which each number is the sum of the two preceding ones. The sequence commonly starts from 0 and 1, although some authors start ...
:
int fib(int n) => (n > 2) ? (fib(n - 1) + fib(n - 2)) : 1;
// A Fibonacci function implementation with a conditional operator in Dart
// This code is read as:
// given an integer n,
// if n > 2, return fib(n - 1) + fib(n - 2);
// otherwise, return the integer 1 as result
void main()
A simple class:
// Import the math library to get access to the sqrt function.
// Imported with `math` as name, so accesses need to use `math.` as prefix.
import 'dart:math' as math;
// Create a class for Point.
class Point
// All Dart programs start with main().
void main()
Influences from other languages
Dart is a descendant of the
ALGOL
ALGOL (; short for "Algorithmic Language") is a family of imperative computer programming languages originally developed in 1958. ALGOL heavily influenced many other languages and was the standard method for algorithm description used by th ...
language family, alongside C, Java, C#, JavaScript, and others.
The
method cascade syntax, which provides a syntactic shortcut for invoking several methods one after another on the same object, is adopted from Smalltalk.
Dart's
mixin
In object-oriented programming languages, a mixin (or mix-in) is a class that contains methods for use by other classes without having to be the parent class of those other classes. How those other classes gain access to the mixin's methods depen ...
s were influenced by
Strongtalk
Strongtalk is a Smalltalk environment with optional static typing support. Strongtalk can make some compile time checks, and offer ''stronger'' type safety guarantees; this is the source of its name. It is non-commercial, though it was original ...
and
Ruby
A ruby is a pinkish red to blood-red colored gemstone, a variety of the mineral corundum (aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapp ...
.
Dart makes use of isolates as a concurrency and security unit when structuring applications. The Isolate concept builds upon the
Actor model
The actor model in computer science is a mathematical model of concurrent computation that treats ''actor'' as the universal primitive of concurrent computation. In response to a message it receives, an actor can: make local decisions, create mor ...
, which is most famously implemented in Erlang.
The Mirror API for performing controlled and secure
reflection was first proposed in a paper
by
Gilad Bracha
Gilad Bracha is a software engineer at F5 Networks, and formerly at Google, where he was on the Dart programming language team. He is creator of the Newspeak language, and co-author of the second and third editions of the Java Language Specificati ...
(who was a member of the Dart team) and
David Ungar
David Michael Ungar, an American computer scientist, co-created the Self programming language with Randall Smith. The SELF development environment's animated user experience was described in the paper ''Animation: From Cartoons to the User Int ...
and originally implemented in
Self
The self is an individual as the object of that individual’s own reflective consciousness. Since the ''self'' is a reference by a subject to the same subject, this reference is necessarily subjective. The sense of having a self—or ''selfhood ...
.
See also
*
Google Web Toolkit
Google Web Toolkit (GWT ), or GWT Web Toolkit, is an open-source set of tools that allows web developers to create and maintain JavaScript front-end applications in Java. It is licensed under the Apache License 2.0.
GWT emphasizes reusable ...
*
TypeScript
TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language. It is designed for the development of large appl ...
, a strongly-typed programming language that
transpiles to JavaScript
References
Bibliography
*
*
*
External links
*
DartPad
{{Authority control
2011 software
Articles with example code
C programming language family
Concurrent programming languages
Dynamically typed programming languages
Free software projects
Google software
JavaScript programming language family
Object-oriented programming languages
Programming languages created in 2011
Scripting languages
Software using the BSD license
Source-to-source compilers
Web programming