
Today, Google has officially unveiled a new
structured web programming language Dart , which will allow you to create fast and high-performance web applications. For all its simplicity for writing small scripts, using Dart, you can create complex modular web applications, use libraries, debuggers, code editors, and other tools.
The official site presents a
technical overview of the language (
translated into Russian from
azproduction ),
specifications (PDF), a
list of libraries .
As
explained in the company's internal correspondence, Dart is positioned as a replacement / alternative to Javascript suffering from "fundamental" flaws that cannot be fixed by evolutionary development.
Key benefits of dart- Classes and interfaces that provide a simple and understandable mechanism for well-defined APIs. These constructs also provide encapsulation and reuse of methods and data.
- Additional types (optional types), through which you can move from the most simple applications to complex modular systems, as well as use debuggers for type checking.
- Library support.
- Toolkit . It is planned to create many additional programs to help the developer.
Dart is still in early development. The creator of the language is the famous programmer Lars Bak (Lars Bak), who is assisted by a group of developers in the Danish office. Additional tools are provided by the Bruce Johnson team in Atlanta, and the Web Inspector support for Dart and Harmony is handled by Pavel Feldman (Pavel Feldman) with developers from St. Petersburg.
')
Examples
Definition of interface, class and subclass.
interface Shape { num perimeter(); } class Rectangle implements Shape { final num height, width; Rectangle(num this.height, num this.width);
Here's how the same Point class can be entered in simple code, with parameters
x and
y , without additional types.
class Point { var x, y; Point(this.x, this.y); scale(factor) => new Point(x*factor, y*factor); distance() => Math.sqrt(x*x + y*y); } main() { var a = new Point(2,3).scale(10); print(a.distance()); }
And the same code with the use of the additional type
num , which is necessary with the increasing complexity of the web application.
class Point { num x, y; Point(num this.x, num this.y); Point scale(num factor) => new Point(x*factor, y*factor); num distance() => Math.sqrt(x*x + y*y); } void main() { Point a = new Point(2,3).scale(10); print(a.distance()); }
Dart can be used in different ways:
- JavaScript streaming supported by some modern browsers (Chrome, Safari 5+, Firefox 4+);
- Execution of the code directly in the virtual machine on the server side;
- Use the built-in Dartboard editor to write, edit and execute simple scripts in a browser window.
Recall that the Dart is designed with three main objectives in mind:
- Performance. Dart virtual machines will not have the performance problems that all EcmaScript machines have.
- Ease of development. The dynamic, easy-to-learn, compilation-free nature of Javascript will be preserved, making the web platform the absolute leader among amateur programmers.
- Support for code editors and additional tools. Dart is designed to make it easier to use additional tools for large, serious projects that require support, including functions such as refactoring and searching for places to call functions. At the same time, Dart will not necessarily require the use of a code editor for efficient programming, so an ordinary developer may well be satisfied with the work in a text editor.
Dart should also provide maximum security where this task does not conflict with the three main ones.
It is assumed that Dart support will be built into all browsers as the main native client language (instead of Javascript), it will be used on front-end servers, as well as in cross-compilers.
In parallel with the “revolutionary” version, which is Dart, Google will also promote another solution to the problem - the Harmony project, within which it will correct those disadvantages of Javacript that are possible.