Dart (programming language)

Darts is a web programming language that is mainly developed by the company Google. The language was designed with the goal of establishing a new, open and modern alternative to JavaScript as the main scripting language used in web browsers. It should Darts overcome some fundamental problems of JavaScript, which could not be solved by an evolution of JavaScript, the developer of Dart 's view. Dart is supposed to have a higher execution speed, better usability for large projects and better security features. Regarded positively aspects of JavaScript are to be retained.

The development of darts began in 2010 in a small team led by Lars Bak, Gilad Bracha and Kasper Lund compressor in Aarhus. Dart was first introduced at the GOTO conference on October 10, 2011 in Aarhus.

Runtime environment

Dart programs can also be executed on the server in the browser, however. For browsers without their own Dart VM Dart2js the Trans compiler after Dartcode JavaScript is provided translated. Since the dart version of the M4 typewritten JavaScript code in Delta Blue benchmark is as fast as the V8 JavaScript engine executed, hand- optimized JavaScript code. Right in the DartVM executed Dart code is significantly faster than comparable JavaScript code. It is notable that the Dart -to- JavaScript compiler used for this is itself written in Dart, and the JavaScript output any valid Dartcode translated into optimized JavaScript. An example of this compiler is found try.dartlang.org on the side, so that the offline works in all modern Browseren.

Work is underway to Dartium, a Chromium version, the Dart natively supported with the DartVM. There is still no known date, to support the Chrome or another browser Dart natively.

Darts applications are supplied with its own mime type, namely "application / vnd.dart ".

The Dart SDK currently focuses on client-side development. Server-side development, for example, with libraries like dart: io support.

The "js library " allows the direct use of JavaScript code in Dart.

Development Goals

The development of Darts is guided by the following objectives:

  • Development of a structured but also flexible programming language for the Web.
  • Development of an easy to learn, because based on familiar syntax for programmers and techniques programming language.
  • Ensuring that all language constructs allow high performance and a fast startup
  • Darts should be especially suitable for devices that communicate with the web, such as phones, tablets, laptops and servers.
  • Support tools that help Darts runs on all major web browsers.

Since the end of 2013, a standardization procedure for the language specification at Ecma International is running.

Typing

Darts is typed optional. This means that Dart runtime has two modes:

  • In production mode, the compiler automatically searches for the best variant of each and ignores both typing instructions and typing errors. This mode is optimized for efficient program execution.
  • In the Checked - mode type recommendations are observed, and typing errors exceptions are striking. In addition, a check for assertions follows. The elaborate code analysis makes this mode is slower than the production mode.

The advantages are in the typing annotations are in better readability for humans and in much better support for the programmer by the Integrated Development Environments or editors, such as code completion, navigation and early fault detection. Programmers who want to use any typing, may waive without disadvantages for the production mode. Only the JavaScript output is sometimes not as well optimized as would be possible with typing instructions.

Examples

Embed / / math library for the square root function import ' dart: math ' as math;   / / Define a class class Point {    Point ( this.x num, num this.y ); / / Define a constructor on a syntactic feature    DistanceTo (Point other) {/ / methods      method calls ;      num dx = x - other.x;      num dy = y - other.y;      return math.sqrt (dx * dx dy * dy);    }    num x, y; / / Member variables    static int method calls = 0; / / Static variable }   / / Define a subclass that inherits from the "Point " class Colorpoint extends Point {    Color Point ( x, y, color): super (x, y) {      this.x = x;      this.y = y;      this.color = color;    }    var color; }   main () {    Point p = new Point ( 2, 3);    Point q = new Color Point ( 3, 4, ' red ');    print (' distance from p to q = $ { p.distanceTo (q ) } ');    print (' method calls = $ { Point.methodCalls } '); }   / / Output: distance from p to q = 1.41421356237; Method calls = 1 literature

  • Kathy Walrath, Seth Ladd: Dart: Up and Running O'Reilly, 2012, ISBN 978-1-4493-3089-7
  • Martin Piskernig, Programming with darts, 2014
217918
de