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

V8 Javascript Engine

V8 JavaScript Engine

V8 is Google’s open source JavaScript engine.

V8 is written in C++ and is used in Google Chrome, the open source browser from Google.

V8 implements ECMAScript as specified in ECMA-262, 5th edition, and runs on Windows (XP or newer), Mac OS X (10.5 or newer), and Linux systems that use IA-32, x64, or ARM processors.

V8 can run standalone, or can be embedded into any C++ application.

The V8 JavaScript Engine is an open source JavaScript engine developed by Google for the Google Chrome web browser.

V8 compiles JavaScript to native machine code (IA-32, x86-64, ARM, or MIPS ISAs) before executing it, instead of more traditional techniques such as interpreting bytecode or compiling the whole program to machine code and executing it from a filesystem. The compiled code is additionally optimized (and re-optimized) dynamically at runtime, based on heuristics of the code’s execution profile.

V8 is intended to be used both in a browser (notably in Chrome and Chromium browsers) and as a standalone high-performance engine that can be integrated into independent projects, for example server-side JavaScript in Node.js, or client side JavaScript in .NET/Mono using V8.NET.

For more: https://code.google.com/p/v8/

ng-class in angularjs

The ngClass directive allows you to dynamically set CSS classes on an HTML element by databinding an expression that represents all classes to be added.

Say Example, If text box is touched/invalid/error you can highlight with different colors like..

touched – green

invalid – orange

error – green

Similarly you can have your own scenarios of using this beautiful ng-class.

Example with clear scenario:

https://docs.angularjs.org/api/ng/directive/ngClass

http://scotch.io/tutorials/javascript/the-many-ways-to-use-ngclass