Master any programming language fast

The Dart Programming Language

Share
Like SyntaxCorect.com on Facebook
Be the first to rate this article

Google tries it again with Dart giving to the language a second chance and placing it as a competitive way to develop Android and iOS native mobile applications

Introduction

Dart is a computer programing language first appeared on the scene 13 years ago (on October 10, 2011). It is a multi-paradigm, (optionally) statically, strongly typed, object-oriented (class-based), structured, imperative, generic, reflective programming language with automatic memory management whose main purpose was originally to bring to the JavaScript development world a type-safe and structured programming language to better handle the development of large applications for the browser potentially proposing itself in the long term as a replacement for JavaScript.

Dart was designed and developed by Lars Bak and Kasper Lund at Google with the initial intent of the company to deploy a Dart VM inside it's market leader browser Chrome in order to gain optimal execution speed for Dart developed applications adding in fact a new programming language in the browser arena.

Despite getting standardized by Ecma (ECMA-408) and being released under a very permissive free software license (BSD like license), Dart did not gain wide acceptance. Indeed the language yielded harsh criticism to Google by other browser vendors and standard organizations who accused the company of using it's market leadership position to impose a proprietary technology.

In the end Google gave up the inclusion of the Dart VM in it's consumer browser Chrome and added to Dart language the feature to be transpiled to JavaScript which is still today the only way Dart applications can run in the browser.

Today Dart offers three execution possibilities for applications developed with the language:

  1. Run in the standalone Dart VM available for Windows, Mac OS X and Linux systems
  2. Transpiled to JavaScript and run in the browser or Node.js
  3. Compiled to native ARM machine code and run in mobile platforms both with Android or iOS operating systems

First glance at the code

Example: The classic "Hello world" program written in Dart:

Main features of Dart

Technical features

Optionally statically, strongly typed

While in its version 2 type annotation is mandatory in Dart, the language offered this as an optional feature in the past. In Dart everything is an object and variables are references to objects. Special support is provided by the language for the following built-in data types:

Table: Dart 2 built-in data types

Name Description
int numeric integer values
double numeric 64-bit (double-precision) floating-point numbers (IEEE 754 standard)
String Dart strings are sequences of UTF-16 code units
bool boolean (true/false)
List array
Map objects that associate keys and values.
Runes these are the UTF-32 code points of a string
Symbol represent operators or identifiers declared in a Dart program
Function in Dart even functions are objects

Object-oriented

Dart is an object-oriented language with classes and mixin-based inheritance. Every object is an instance of a class, and all classes descend from Object. Mixin-based inheritance means that although every class (except for Object) has exactly one superclass (multiple inheritance it not allowed), a class body can be reused in multiple class hierarchies. Interfaces are not present in the language reverting Dart to the C++ way of using abstract classes to implement interfaces.

Memory management

Memory management in Dart is automatic and is delegated to the underlying JavaScript execution environment when the applications are run in the browser and to the Dart VM garbage collector when run stand alone.

Concurrent

Dart is a single-thread programming language, still it has isolates to handle concurrency programming.

Dart libraries/ecosystem

Dart has not enjoyed wide adoption so far. While it is possibile to use JavaScript libraries, even imported using TypeScript definition files, for applications developed to be transpiled and run in JavaScript, there isn't a very big repository of Dart-spceific libraries, apart from those written for the language itself. The exception is for the project Flutter with which Google is providing a complete platform for mobile developemnt using the Dart language. With Flutter Dart is compiled to native ARM processors machine code and a cross-platform framework for Android and iOS devices is provided which also offers GUI elements implemented with the theese days widely adopted principles of Google Material design.

Other features

Free and open source

Dart is free and open source software (BSD like license).

Notable softwares/platforms/products written in Dart

Google uses internally Dart for many critical web apps often together with AngularDart. The next generation of Google AdWords is built in Dart. Google Fiber’s latest web app is built in it. So is Google’s internal CRM.

Best books for learning Dart

For beginners

Dart for Absolute Beginners

No background in programming required!

Dart is a new, innovative language developed by Google which is poised to take the web by storm. For client side web app development, Dart has many advantages over JavaScript. These include... (continue on Amazon)

For experienced programmers

The Dart Programming Language

The most authoritative description of Dart

Gilad Bracha is a software engineer at Google where he works on Dart. In this book he covers both language semantics and the rationale for key features, helping you understand not just what Dart does, but... (continue on Amazon)

Conclusion

Google tried to hit it big with Dart. It was already a while, for many, that JavaScript was not enough anymore for browser software development and Google finally provided a solution: an elegant, optionally statically typed language that can really increase programmers productivity and safety of code solving all the problems JavaScript gives for large applications development. Yet Dart got neither consent nor adoption. Why? Because it was just another language that eventually could even replace JavaScript, but without solving what was the real problem most vendors started to suffer: browsers gave no freedom about what programming languages one could use to develop in-browser applications. This was the real problem, not the lack of this or that language, but the lack of freedom to choose which language. Dart didn't solve that problem and that's why it didn't gain adoption. Years later WebAssembly, finally here in its first version, emerged to be the real solution. Now it's finally possible for vendors to build languages and language tools as they like, for what language they like, freeing the browser from the very very long lasting dictatorship of JavaScript. So what about Dart now? Well, now it's time for Dart to demonstrate its values and compete with other languages on equal terms.