Top 1,000 Features Creators Events Podcasts Extensions Blog Explorer CSV Download

Dart

< >

Dart is an open source programming language created in 2011 by Lars Bak.

#39on PLDB 13Years Old 738kRepos

Try now: Riju ยท TIO

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 permissive free software license (modified BSD license). Read more on Wikipedia...


Example from Compiler Explorer:
// Type your code here, or load an example. int square(int num) { return num * num; } int main(List<String> args) { return square(int.fromEnvironment("input")); }
Example from Riju:
void main() { print('Hello, world!'); }
Example from hello-world:
main() { print('Hello World'); }
// Hello world in Dart main() { print('Hello world!'); }
Example from Linguist:
import 'dart:math' as math; class Point { num x, y; Point(this.x, this.y); num distanceTo(Point other) { var dx = x - other.x; var dy = y - other.y; return math.sqrt(dx * dx + dy * dy); } } void main() { var p = new Point(2, 3); var q = new Point(3, 4); print('distance from p to q = ${p.distanceTo(q)}'); }
Example from Wikipedia:
// Import the math library to get access to the sqrt function. import 'dart:math' as math; // Create a class for Point. class Point { // Final variables cannot be changed once they are assigned. // Create two instance variables. final num x, y; // A constructor, with syntactic sugar for setting instance variables. Point(this.x, this.y); // A named constructor with an initializer list. Point.origin() : x = 0, y = 0; // A method. num distanceTo(Point other) { var dx = x - other.x; var dy = y - other.y; return math.sqrt(dx * dx + dy * dy); } // Example of Operator Overloading Point operator +(Point other) => new Point(x + other.x, y + other.y); } // All Dart programs start with main(). void main() { // Instantiate point objects. var p1 = new Point(10, 10); var p2 = new Point.origin(); var distance = p1.distanceTo(p2); print(distance); }
abstract as assert async await break case catch class const continue covariant default deferred do dynamic else enum export extends external factory false final finally for get if implements import in is library new null operator part rethrow return set static super switch sync this throw true try typedef var void while with yield

Language features

Feature Supported Token Example
Hexadecimals โœ“
// 0[xX][0-9a-fA-F]+
Conditionals โœ“
Async Await โœ“
Inheritance โœ“
Switch Statements โœ“
Exceptions โœ“
Constants โœ“
Classes โœ“
While Loops โœ“
Booleans โœ“ true false
Strings โœ“ '
'Hello world'
Regular Expression Syntax Sugar โœ“
Print() Debugging โœ“ print
Line Comments โœ“ //
// A comment
Operator Overloading โœ“
File Imports โœ“
import 'file-system.dart';
import 'dart:math' as math;
MultiLine Comments โœ“ /* */
/* A comment
*/
Comments โœ“
// Hi
/* Assume address is not null. */
Case Insensitive Identifiers X
Semantic Indentation X

View source

- Build the next great programming language ยท About ยท Resources ยท Acknowledgements ยท Part of the World Wide Scroll