Dart is a programming language, which was originally developed by Google and then was given the ECMA standard. It is used for building web, server and mobile applications.

It is object-oriented language that is based on classes. It uses syntax of C style, which can be optionally transcompiled to JavaScript. It supports interface, mixins, abstract classes or e. g. static typing.

Different options of usage

The are three basic options, how to execute Dart’s code.

Compiled to JavaScript

For executing in the common web browsers, Dart counts on the source-to-source compilation to JavaScript. Dart was originally developed to be simple to write in and to be suitable for modern development of apps and usage of highly efficient implementations.

During execution of Dart’s code in web browser, there’s pre-compilation to JavaScript with the help of dat2js compiler. The compiled Dart’s code is compatible with all the major web browsers, so there’s no need to edit the web browsers. Thanks to the optimization of compiled JavaScript output for a purpose of leaving out the unnecessary controls and operations, Dart’s code can run faster than equivalent code that is written manually directly in JavaScript.

Stand-Alone

Dart SDK contains stand-alone Dart VM, which allows Dart to execute command lines in environment. Regarding to the tools being often written in Dart, this usage is a critical part of SDK. These tools contain dart2js compiler and the package manager of the pub. Dart contains complete standard library, which allows users to write fully functional app systems, as are e. g. customized web servers.

Pre-compiled

Dart’s code can be pre-compiled to source code. Application standing for the usage of Flutter, SDK for mobile apps developed in Dart, are uploaded into application stores in this form.

Native mobile applications

Google implemented Flutter for native development of mobile apps as for Android as for iOS. Flutter is SDK for the mobile apps’ creation, which is complemented by Framework, widgets and tools, which give developers the option to build and deploy mobile app. Flutter works with Firebase and other SDK for mobile apps’ creation and it is an open-source.

Snapshots

Snapshots are a part of Dart VM’s core. They are files, which store objects and other data regarding to the executing.

Scripts’ snapshots

Dart programs can be compiled into the snapshot files. These files contain the whole programming code and dependencies, which are pre-parsed and ready for executing. Thanks to that the maximally fast executing is possible.

Full snapshots

Dart’s core libraries can be compiled to snapshot file, which enables fast loading of libraries. Most of the standard distributions of main Dart VM has pre-set snapshots for the main libraries, which are used during executing.

Object snapshots

Dart is very asynchronous language. It can use isolates for parallel executing. Regarding to the isolates sending messages, it is needed to find a way, how to serialize the message. It is solved with the help of snapshots, which are generalized from the object and then are passed over to another isolate for deserialization.

Advantages of using Dart

  • It is possible to compile it to JavaScript. It is without any other editing compatible with random web browser.
  • Code optimization. Compilation with the usage of dart2js ensures code reduction and can reach a very good efficiency.
  • Useful functions. Using mixins, implicit interface or one-line functions can be very useful.
  • Speed. Virtual machine is very fast.
  • Robust libraries. Dart contains robust core libraries, which are direct part of SDK.

Disadvantages of using Dart

  • Stability. Dart is less stable than e. g. Java.
  • Packages. Dart contains less packages than e. g. Node.js.