Paradigm | Multi-paradigm: functional, imperative, object-oriented, reflective [1] |
---|---|
Designed by | Lars Bak, Kasper Lund |
Developer | |
First appeared | October 10, 2011 [2] |
Stable release | |
Typing discipline | 1.x: Optional 2.x: Inferred [4] (static, strong) |
Platform | Cross-platform |
OS | Cross-platform |
License | BSD |
Filename extensions | .dart |
Website | dart |
Major implementations | |
Dart VM, dart2native, dart2js, DDC, Flutter | |
Influenced by | |
C, C++, C#, Erlang, Java, JavaScript, Ruby, Smalltalk, Strongtalk, [5] TypeScript [6] |
Dart is a programming language designed by Lars Bak and Kasper Lund and developed by Google. [7] It can be used to develop web and mobile apps as well as server and desktop applications.
Dart is an object-oriented, class-based, garbage-collected language with C-style syntax. [8] It can compile to machine code, JavaScript, or WebAssembly. It supports interfaces, mixins, abstract classes, reified generics and type inference. [4]
Dart was unveiled at the GOTO conference in Aarhus, Denmark, October 10–12, 2011. [9] Lars Bak and Kasper Lund founded the project. [10] Dart 1.0 was released on November 14, 2013. [11]
Dart had a mixed reception at first. Some criticized the Dart initiative for fragmenting the web because of plans to include a Dart VM in Chrome. Those plans were dropped in 2015 with the Dart 1.9 release. Focus changed to compiling Dart code to JavaScript. [12]
Dart 2.0 was released in August 2018 with language changes including a type system. [13]
Dart 2.6 introduced a new extension, dart2native
. This extended native compilation to the Linux, macOS, and Windows desktop platforms. [14] 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. [15] The Flutter toolkit integrates Dart, so it can compile on small services like backend support. [16] [17]
Dart 3.0 was released in May 2023 [18] with changes to the type system to require sound null safety. This release included new features like records, patterns, [19] and class modifiers. [20]
Dart can compile to WebAssembly since version 3.4. [21]
Dart released the 5th edition of its language specification on April 9, 2021. [22] This covers all syntax through Dart 2.10. A draft of the 6th edition includes all syntax through 2.13. [23] Accepted proposals for the specification and drafts of potential features can be found in the Dart language repository on GitHub. [24]
ECMA International formed technical committee, TC52, [25] to standardize Dart. ECMA approved the first edition of the Dart language specification as ECMA-408 [26] in July 2014 at its 107th General Assembly. [27] Subsequent editions were approved in December 2014, [28] June 2015, and December 2015. [26]
The Dart software development kit (SDK) ships with a standalone Dart runtime. This allows Dart code to run in a command-line interface environment. The SDK includes tools to compile and package Dart apps. [29] Dart ships with a complete standard library allowing users to write fully working system apps like custom web servers. [30]
Developers can deploy Dart apps in six ways:
Deployment type | Target platform | Platform- specific | Requires Dart VM | Compile speed | Execution speed |
---|---|---|---|---|---|
JavaScript | Browser | No | No | Slow | Fast |
WebAssembly [21] [31] | Browser | No | No | Slow | Fast |
Self-contained executable | macOS, Windows, Linux | Yes | No | Slow | Fast |
Ahead-of-time module | macOS, Windows, Linux | Yes | No | Slow | Fast |
Just-in-time module | macOS, Windows, Linux | Yes | Yes | Fast | Slow |
Portable module | macOS, Windows, Linux | No | Yes | Fast | Slow |
Dart 3 can deploy apps to the web as either JavaScript or WebAssembly apps. Dart supports compiling to WebAssembly as of May 2024 [update] .
dartc
. It was deprecated in Dart 2.0.dart2js
. Introduced in Dart 2.0, [35] 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.dartdevc
. [36] 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, [37] stating that it now runs faster than handwritten JavaScript on Chrome's V8 JavaScript engine for the DeltaBlue benchmark. [38] 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.webdev serve
to compile a larger JavaScript file with human-readable code. Dart-generated JavaScript can be debugged using Chrome only.$cd<dart_app_directory> $webdevserve[--debug][-o<target.js>]
webdev build
to compile a minified JavaScript file.$cd<dart_app_directory> $webdevbuild[-o<target.js>]
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.
$dartcompileexe<source.dart>-o<target_app> Generated:<target_app> $./<target_app>
$dartcompileaot-snapshot<source.dart> Generated<target_app.aot> $dartaotruntime<target_app.aot>
$dartcompilejit-snapshot<source.dart> Compiling<source.dart>tojit-snapshotfile<target_app.jit> Helloworld! $dartrun<target_app.jit> Helloworld!
$dartcompilekernel<source.dart> Compiling<source.dart>tokernelfile<target_app>.dill. $dartrun<target_app>.dill
To achieve concurrency, Dart uses isolated, independent workers that do not share memory, but use message passing, [45] 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. [46]
Starting with Dart 2.12, Dart introduced sound null safety. [47] 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.
Snapshot files, a core part of the Dart VM, store objects and other runtime data. [45]
On November 18, 2011, Google released Dart Editor, an open-source program based on Eclipse components, for macOS, Windows, and Linux-based operating systems. [49] The editor supports syntax highlighting, code completion, JavaScript compiling, running web and server Dart applications, and debugging.
On August 13, 2012, Google announced the release of an Eclipse plugin for Dart development. [50]
On April 18, 2015, Google retired the Dart Editor in favor of the JetBrains integrated development environment (IDE). [51] Android Studio, IntelliJ IDEA, PyCharm, PhpStorm and WebStorm support a Dart plugin. [52] This plugin supports many features such as syntax highlighting, code completion, analysis, refactoring, debugging, and more. Other editors include plugins for Dart [53] including Sublime Text, [54] Atom, [55] Emacs, [56] Vim [57] and Visual Studio Code. [58]
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. [59] The project was later renamed as Chrome Dev Editor. [60] Built in Dart, it contained Spark which is powered by Polymer. [61]
In June 2015, Google transferred the CDE project to GitHub as a free software project and ceased active investment in CDE. [62] The Chrome Dev Editor project was archived on April 24, 2021. [63]
To provide an easier way to start using Dart, the Dart team created DartPad at the start of 2015. This online editor allows developers to 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. [64]
The Dart DevTools, written in Dart, [65] include debugging and performance tools.
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. [66] Flutter 2.10 released with production support for Windows [67] and Flutter 3 released production support for all desktop platforms. [68] It provides a framework, widgets, and tools. This framework gives developers a way to build and deploy mobile, desktop, and web apps. [69] Flutter works with Firebase [70] and supports extending the framework through add-ons called packages. These can be found on their package repository, pub.dev. [71] JetBrains also supports a Flutter plugin. [72]
A Hello, World! example:
voidmain(){print('Hello, World!');}
voidmain(){for(vari=1;i<=10;i++){print(i);}}
A function to calculate the nth Fibonacci number:
voidmain(){vari=20;print('fibonacci($i) = ${fibonacci(i)}');}/// Computes the nth Fibonacci number.intfibonacci(intn){returnn<2?n:(fibonacci(n-1)+fibonacci(n-2));}
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'asmath;// Create a class for Point.classPoint{// Final variables cannot be changed once they are assigned.// Declare two instance variables.finalnumx,y;// A constructor, with syntactic sugar for setting instance variables.// The constructor has two mandatory parameters.Point(this.x,this.y);// A named constructor with an initializer list.Point.origin():x=0,y=0;// A method.numdistanceTo(Pointother){vardx=x-other.x;vardy=y-other.y;returnmath.sqrt(dx*dx+dy*dy);}// Example of a "getter".// Acts the same as a final variable, but is computed on each access.numgetmagnitude=>math.sqrt(x*x+y*y);// Example of operator overloadingPointoperator+(Pointother)=>Point(x+other.x,y+other.y);// When instantiating a class such as Point in Dart 2+, new is // an optional word}// All Dart programs start with main().voidmain(){// Instantiate point objects.varp1=Point(10,10);print(p1.magnitude);varp2=Point.origin();vardistance=p1.distanceTo(p2);print(distance);}
Dart belongs to the ALGOL language family. [74] [ failed verification ] Its members include C, Java, C#, JavaScript, and others.
The method cascade syntax was adopted from Smalltalk. [75] This syntax provides a shortcut for invoking several methods one after another on the same object.
Dart's mixins were influenced by Strongtalk [ citation needed ] [76] [77] and Ruby.
Dart makes use of isolates as a concurrency and security unit when structuring applications. [78] The Isolate concept builds upon the Actor model implemented in Erlang. [79]
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. [80] The concept was first implemented in Self.
In computing, cross-platform software is computer software that is designed to work in several computing platforms. Some cross-platform software requires a separate build for each platform, but some can be directly run on any platform without special preparation, being written in an interpreted language or compiled to portable bytecode for which the interpreters or run-time packages are common or standard components of all supported platforms.
Netscape Plugin Application Programming Interface (NPAPI) is a deprecated application programming interface (API) for web browser plugins, initially developed for Netscape Navigator 2.0 in 1995 and subsequently adopted by other browsers.
Microsoft Windows SDK, and its predecessors Platform SDK, and .NET Framework SDK, are software development kits (SDKs) from Microsoft that contain documentation, header files, libraries, samples and tools required to develop applications for Microsoft Windows and .NET Framework. Platform SDK specializes in developing applications for Windows 2000, XP and Windows Server 2003. .NET Framework SDK is dedicated to developing applications for .NET Framework 1.1 and .NET Framework 2.0. Windows SDK is the successor of the two and supports developing applications for Windows XP and later, as well as .NET Framework 3.0 and later.
Google Web Toolkit, 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 Apache License 2.0.
Google Developers is Google's site for software development tools and platforms, application programming interfaces (APIs), and technical resources. The site contains documentation on using Google developer tools and APIs—including discussion groups and blogs for developers using Google's developer products.
A browser toolbar is a toolbar that resides within a browser's window. All major web browsers provide support to browser toolbar development as a way to extend the browser's GUI and functionality. Browser toolbars are considered to be a particular kind of browser extensions that present a toolbar. Browser toolbars are specific to each browser, which means that a toolbar working on a browser does not work on another one. All browser toolbars must be installed in the corresponding browser before they can be used and require updates when new versions are released.
V8 is a JavaScript and WebAssembly engine developed by Google for its Chrome browser. V8 is free and open-source software that is part of the Chromium project and also used separately in non-browser contexts, notably the Node.js runtime system.
The Android SDK is a software development kit for the Android software ecosystem that includes a comprehensive set of development tools. These include a debugger, libraries, a handset emulator based on QEMU, documentation, sample code, and tutorials. The SDK is part of the official Android Studio IDE but its various tools and resources can be used independently.
Google Native Client (NaCl) is a discontinued sandboxing technology for running either a subset of Intel x86, ARM, or MIPS native code, or a portable executable, in a sandbox. It allows safely running native code from a web browser, independent of the user operating system, allowing web apps to run at near-native speeds, which aligns with Google's plans for ChromeOS. It may also be used for securing browser plugins, and parts of other applications or full applications such as ZeroVM.
Apache Cordova is a mobile application development framework created by Nitobi. Adobe Systems purchased Nitobi in 2011, rebranded it as PhoneGap, and later released an open-source version of the software called Apache Cordova. Apache Cordova enables software programmers to build hybrid web applications for mobile devices using CSS3, HTML5, and JavaScript, instead of relying on platform-specific APIs like those in Android, iOS, or Windows Phone. It enables the wrapping up of CSS, HTML, and JavaScript code depending on the platform of the device. It extends the features of HTML and JavaScript to work with the device. The resulting applications are hybrid, meaning that they are neither truly native mobile application nor purely Web-based. They are not native because all layout rendering is done via Web views instead of the platform's native UI framework. They are not Web apps because they are packaged as apps for distribution and have access to native device APIs. Mixing native and hybrid code snippets has been possible since version 1.9.
Titanium SDK is an open-source framework that allows the creation of native mobile applications on platforms iOS and Android from a single JavaScript codebase. It is presently developed by non-profit software foundation TiDev, Inc.
RemObjects Software is an American software company founded in 2002 by Alessandro Federici and Marc Hoffman. It develops and offers tools and libraries for software developers on a variety of development platforms, including Embarcadero Delphi, Microsoft .NET, Mono, and Apple's Xcode.
asm.js is a subset of JavaScript designed to allow computer software written in languages such as C to be run as web applications while maintaining performance characteristics considerably better than standard JavaScript, which is the typical language used for such applications.
Codename One is an open-source cross-platform framework aiming to provide write once, run anywhere code for various mobile and desktop operating systems. It was created by the co-founders of the Lightweight User Interface Toolkit (LWUIT) project, Chen Fishbein and Shai Almog, and was first announced on January 13, 2012.
JEB is a disassembler and decompiler software for Android applications and native machine code. It decompiles Dalvik bytecode to Java source code, and x86, ARM, MIPS, RISC-V machine code to C source code. The assembly and source outputs are interactive and can be refactored. Users can also write their own scripts and plugins to extend JEB functionality.
GraalVM is a Java Development Kit (JDK) written in Java. The open-source distribution of GraalVM is based on OpenJDK, and the enterprise distribution is based on Oracle JDK. As well as just-in-time (JIT) compilation, GraalVM can compile a Java application ahead of time. This allows for faster initialization, greater runtime performance, and decreased resource consumption, but the resulting executable can only run on the platform it was compiled for.
WebAssembly (Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating communication between such programs and their host environment.
Flutter is an open-source UI software development kit created by Google. It can be used to develop cross platform applications from a single codebase for the web, Fuchsia, Android, iOS, Linux, macOS, and Windows. First described in 2015, Flutter was released in May 2017. Flutter is used internally by Google in apps such as Google Pay and Google Earth as well as other software developers including ByteDance and Alibaba.
ArkTS is a high-level general-purpose, multi-paradigm, compiled, declarative, static type programming language developed by Huawei which is a extension superset of open-source TypeScript, in turn a superset of JavaScript formerly used in July 2022 HarmonyOS 3.0 version, alongside its evolved precursor, extended TypeScript (eTS) built for HarmonyOS development as a shift towards declarative programming. ArkTS compiles to machine code via its ahead-of-time compilation Ark Compiler. ArkTS was first released in September 30, 2021 on OpenHarmony, and the ArkTS toolchain has shipped in DevEco Studio since version 3.1, released in 2022. Since, OpenHarmony 4.0 release on October 26, 2023, ArkTS APIs has been added to the open source community to contribute.
{{citation}}
: CS1 maint: location missing publisher (link)