DART

What is DART?? Same question arises until i see here.

Know about DART..

Dart is an open-source Web programming language developed by Google.The goal of Dart is “ultimately to replace JavaScript as the lingua franca(In simple words,language independent) of web development on the open web platform”.Dart is a class-based, single inheritance, object-oriented language with C-style syntax. It supports interfaces, abstract classes, reified generics, and optional typing.

The project was founded by Lars Bak and Kasper Lund.

Usage
There are three primary ways to run Dart code:

Compiled as JavaScript
When running Dart code in a web browser, the primary intended mechanism is to pre-compile the Dart code into JavaScript using the dart2js compiler. Compiled as JavaScript, Dart code is compatible with all major browsers with no specific browser adoption of Dart being required. Through optimization of 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 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 compilation to JavaScript. It is intended as a development tool for Dart applications, rather than as a general purpose web browser. When embedding Dart code into web apps, the current recommended procedure is to load a bootstrap JavaScript file, “dart.js”, which will detect the presence or absence of the Dart VM and load the corresponding Dart or compiled JavaScript code, respectively, therefore guaranteeing browser compatibility with or without the custom Dart VM.
Stand-Alone
The Dart SDK also ships with a stand-alone Dart VM, allowing dart code to run in a command-line environment. As the language tools included in the Dart SDK are written primarily in Dart, the stand-alone Dart VM is a critical part of the SDK. These tools include not only the dart2js compiler, but also a package management suite called pub. Dart ships with a complete standard library allowing users to write fully functional system apps, such as custom web servers.

Browser adoption

A special version of Chromium (the open-source browser at the core of Google Chrome) comes with the Dart virtual machine, allowing it to run Dart programs. As of May 2013, Microsoft Internet Explorer, Mozilla Firefox, Opera Software’s Opera browser, and Apple Safari have no plan to embed a separate Dart VM.

Dart source code can be compiled to JavaScript, allowing applications written in Dart to run in all modern web browsers. In the M1 version, released in October 2012, the generated JavaScript reached about 78% of the performance of hand-written JavaScript while native Dart code ran about 21% faster than similar code in V8.

Example

A Hello World example:

void main() {
  print('Hello World!');
}

A function to calculate the nth Fibonacci number:

int fib(int n) => (n > 1) ? (fib(n - 1) + fib(n - 2)) : 1;
 
void main() {
  print('fib(20) = ${fib(20)}');
}

A simple class:

// 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);
}

How to start and where to start?

https://angulardart.org/

https://www.dartlang.org/ ( you can native dart editor from here)

Sources:http://en.wikipedia.org/wiki/Dart_(programming_language)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s