Dart Programming Language
Dart is a
general-purpose programming language
originally developed by Google and later approved as a standard by Ecma
(ECMA-408). It is used to build web, server and mobile applications, and for
Internet of Things (IoT) devices. It is open-source software under a BSD
license.
Dart is a class-based, single inheritance, object-oriented language with C-style syntax which compiles into JavaScript or native
code. It supports interfaces, mixins, abstract classes, reified generics, and optional typing.
History:
Dart was unveiled at the GOTO conference in Aarhus,
Denmark, October 10–12, 2011.The project was founded by Lars Bak and
Kasper Lund.
Standardization
Ecma International 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. Ecma
International approved the Dart language specification first edition in July
2014, at its 107th General Assembly, and a second edition in December 2014.
Usage:
There are three main ways to run Dart code:
Compiled as JavaScript
To run in mainstream web browsers, Dart relies on a source-to-source compiler to JavaScript.
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. When
running Dart code in a web browser the code is precompiled into JavaScript
using the dart2js compiler. Compiled as JavaScript, Dart code is compatible
with all major browsers with no need for browsers to adopt Dart. Through
optimizing the compiled JavaScript output to avoid expensive checks and
operations, code written in Dart can, in some cases, run faster than equivalent
code hand-written using JavaScript idioms.
In the Dartium Browser
The Dart software development kit (SDK) ships with a version of the Chromium web browser modified to include a Dart virtual machine (VM). This browser can run Dart code
directly without compiling to JavaScript. It is intended as a development tool
for applications written in this language, rather than as a general purpose web
browser. There were originally plans to include Dart support directly in Chrome, but these were cancelled.
Stand-alone
The Dart SDK also
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 Dart SDK are written mostly in Dart, the stand-alone Dart VM is
a critical part of the SDK. These tools include the dart2js compiler, and a package manager suite called pub. Dart ships with a
complete standard library allowing users to write fully working
system apps, such as custom web servers.
Runtime Modes
Dart programs run in one of two modes. In checked mode, which is not the
default mode and must be turned on, dynamic type assertions are enabled. These
type assertions can turn on if static types are provided in the code, and can
catch some errors when types do not match. For example, if a method is annotated
to return a String, but instead returns an integer, the dynamic type assertion
will catch this and throw an exception. Running in checked mode is recommended for development and
testing.
Dart
programs run by default in production
mode, which runs with all dynamic type assertions turned off. This is the
default mode because it is the fastest way to run a Dart program.
Snapshots
Snapshots are a core part of
the Dart VM. Snapshots are files which store objects and other runtime data.
Script snapshots
Dart
programs can be compiled into snapshot files. These files contain all of the
program code and dependencies preparsed and ready to execute. This allows fast
startups.
Full snapshots
The
Dart core libraries can be compiled into a snapshot file which allows fast
loading of the libraries. Most standard distributions of the main Dart VM have
a prebuilt snapshot for the core libraries which is loaded at runtime.
Object snapshots
Dart is
a very asynchronous language. With this, it uses isolates for concurrency.
Since these are workers which pass messages, it needs a way to serialize a message. This is done using a
snapshot, which is generated from a given object, and then this is transferred
to another isolate for deserializing.
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.
For more information, please visit : www.triharisolutions.com