Darts (programming language)

from Wikipedia, the free encyclopedia
Darts
Dart-logo-wordmark.svg
Basic data
Paradigms : object oriented programing
Publishing year: 2013 (preliminary version 2011)
Designer: Lars Bak , Google LLC
Developer: Lars Bak , Gilad Bracha , Kasper Verdich Lund , The Dart Team
Current  version 2.9.2   (August 26, 2020)
Typing : Optional typing , dynamic typing
Standardizations: ECMA-408, 1.11 Language Specification (August 19, 2015)
Influenced by: C # , Erlang , JavaScript , Scala , Smalltalk , Strongtalk
License : Modified BSD license
dart.dev

Dart is an ECMA- standardized programming language that is mainly developed by the Google company . The language was designed as a general, multi-purpose programming language that is particularly intended to be a modern alternative to JavaScript for use in web browsers. Dart is supposed to overcome some fundamental problems of JavaScript which, in the opinion of the developers of Dart, could not be resolved by further developing JavaScript.

history

The development of darts began in 2010 in a small team around Lars Bak , Gilad Bracha and Kasper Verdich Lund in Aarhus . Darts was first presented at the GOTO conference on October 10, 2011 in Aarhus.

The first stable version 1.0 was published on November 14, 2013. On June 25, 2014, the General Assembly of the ECMA decided to standardize the language specification with document “ECMA-408”.

Runtime environment

Dart programs can be run in the browser, but also on the server. The transcompiler Dart2js is intended for browsers, which translates dart code into JavaScript. The "js Library" enables the direct use of JavaScript code in Dart. Since Dart version M4, the machine-written JavaScript code in the DeltaBlue benchmark has been just as fast as the hand-optimized JavaScript code executed by the V8 JavaScript engine. Dart code executed directly in the DartVM is significantly faster than comparable JavaScript code. What is remarkable is that the dart-to-JavaScript compiler used for this is itself written in dart, and the JavaScript output translates any valid dart code into optimized JavaScript. An example of this compiler can be found on the try.dartlang.org page, which also works offline in all modern browsers.

Dart applications are delivered with their own mimetype, namely "application / vnd.dart".

The Dart SDK currently focuses on client-side development. Server-side development is supported, for example, with libraries such as dart: io.

A dart VM in the browser is not intended in Chrome or in any other browser. An independent dart VM is being further developed for mobile apps , server-side programs and as a tool to support programmers. The focus of further development is placed on the highest possible productivity for programmers.

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 a programming language that is easy to learn because it is based on syntax and techniques that are familiar to programmers.
  • Ensuring that all language constructs enable high performance and a quick program start
  • Darts should especially be suitable for devices that communicate with the web, such as phones, tablets, laptops and servers.
  • Support from tools that enable Dart to run on all common web browsers.

Dart platforms

Dart's flexible compilation technology gives developers the ability to compile dart code in a variety of ways, depending on the intended use.

Darts native

Dart Native uses both JIT (just-in-time compilation) and AOT (ahead-of-time compilation) to develop machine code for target devices such as smartphones, desktops or servers and make it available on them.

Darts web

With Dart Web a separate compiler can be used during development (dartdevc) and for the final website (dart2js). As the name suggests, Dart Web is intended for the development of web applications.

Typing

Dart is optionally typed . This means that Dart knows two runtime modes:

  • In production mode , the compiler independently looks for the best variant and ignores both typing instructions and typing errors. This mode is optimized for the most efficient program execution possible.
  • In checked mode , the type instructions are strictly observed and exceptions are thrown in the event of typing errors . There is also a check for assertions . The complex code analysis makes this mode slower than the production mode .

The advantages of typing annotations are better readability for people and the significantly better support for the programmer through integrated development environments or editors such as code completion, navigation and early error detection. Programmers who do not want to use any typing can do without it without disadvantages for the production mode. Only the JavaScript output is sometimes not as easy to optimize as it would be possible with typing instructions.

Tools

Darts come with a range of tools. The basis is the Dart SDK . This contains the standalone VM DartVM and a dart according to JavaScript transcompiler called dart2js . The command line tools dartanalyzer and dartfmt are included for source code analysis and source code formatting . From version 1.2 of the SDK, docgen is a software documentation tool . Dart applications are based on packages and represent themselves packages as soon as at least one program library is used. The Pub package management system is included to manage the Dart applications .

The IDE Dart Editor was developed almost parallel to the programming language . This program is based on Eclipse , but has been significantly streamlined compared to this.

As of version 1.4, the Observatory analysis tool is also provided for viewing the processes within the DartVM.

Examples

Hello Wikipedia

main() {
    // Ausgabe der Textzeile "Hallo, Wikipedia!"
    print('Hallo, Wikipedia!');
}

object oriented programing

// Mathematik-Bibliothek für die Wurzel-Funktion einbinden
import 'dart:math' as math;

// eine Klasse definieren
class Point {
    // einen Konstruktor über eine syntaktische Besonderheit definieren
    Point(num this.x, num this.y);

    // eine Methode
    double distanceTo(Point other) {
        methodCalls++;
        num dx = x - other.x;
        num dy = y - other.y;
        return math.sqrt(dx * dx + dy * dy);
    }

    // Member-Variablen
    num x, y;

    // statische Variable
    static int methodCalls = 0;
}

// eine Unterklasse definieren, die von "Point" erbt
class ColorPoint extends Point {
    ColorPoint(x, y, this.color): super(x, y);
    var color;
}

main() {
    Point p = Point(2, 3);
    Point q = ColorPoint(3, 4, 'rot');
    print('Abstand von p nach q = ${p.distanceTo(q)}');
    print('Methoden-Aufrufe = ${Point.methodCalls}');
}

// Ausgabe: Abstand von p nach q = 1.41421356237; Methoden-Aufrufe = 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

Web links

swell

  1. Release 2.9.2 . August 26, 2020 (accessed August 27, 2020).
  2. Standard ECMA-408 - Dart Programming Language Specification 4th Edition
  3. Google shoots Dart at JavaScript. It's really not a JavaScript killer, insists author. October 10, 2011, accessed October 15, 2011 .
  4. a b ECMA Latest News June 25, 2014 ( Memento from July 1, 2014 in the Internet Archive )
  5. Frederic Lardinois in techcrunch.com on June 29, 2014: Google's Dart Programming Language Is Coming To The Server
  6. Stephen Shankland: Google debuts Dart, a JavaScript alternative. CNET, October 10, 2011, accessed on October 15, 2011 (English): "" It's not going to replace JavaScript ""
  7. Christian Grobmeier: 10 points in which darts outperform JavaScript. January 13, 2012, accessed May 18, 2016 .
  8. ^ Gilad Bracha, Lars Bak: Opening Keynote: Dart, a new programming language for structured web programming. goto Aarhus 2011 International Software Developer Conference, October 10, 2011, accessed on October 15, 2011 .
  9. golem.de on November 14, 2013: Google's Dart 1.0 released
  10. Using JavaScript from Dart: The js Library. September 2012, accessed December 28, 2012 .
  11. Dart Performance ( Memento of the original from January 3, 2017 in the Internet Archive ) Info: The archive link was inserted automatically and has not yet been checked. Please check the original and archive link according to the instructions and then remove this notice. @1@ 2Template: Webachiv / IABot / www.dartlang.org
  12. a b dart2js: The Dart-to-JavaScript Compiler
  13. TRY DART!
  14. dart2js: The Dart-to-JavaScript Compiler
  15. ^ IANA: IANA Dart Media Type. December 14, 2011, archived from the original on October 1, 2014 ; accessed on July 14, 2019 .
  16. Command-Line Apps
  17. Lars Bak, Kasper Lund: Dart for the Entire Web March 25, 2015
  18. ^ Dart An Introduction. October 19, 2011, accessed October 15, 2011 .
  19. Dart Platforms (English). Archived from the original on July 26, 2019 ; accessed on August 7, 2019 .
  20. Optional Types in Dart by Gilad Bracha, October 2011 (updated September 2012)
  21. dart: The Standalone VM
  22. ^ Pub Package and Asset Manager
  23. Dart Editor
  24. Google's JavaScript Challenger: Deep Insights into Application Code with Dart 1.4