Dart and its usability

Googles' Dart

Dart is Google's replacement for JavaScript. Behind it, Googles’ the general intention is to provide the same tools that JavaScript does, but as power tools. Dart has a lot of Object-Oriented features that the typical JavaScript programmer will be unfamiliar. It is used to build web, server and mobile applications, and for the Internet of Things (IoT) devices. It is open-source software under a permissive free software license (modified BSD license). It supports interfaces, mixins, abstract classes, reified generics, and optional typing.

Dart was founded by Lars Bak and Kasper Lund. It was unveiled at the GOTO conference in Aarhus, Denmark, October 10 - 12, 2011. At the initial stage it revealed as Dash, and later it renamed as Dart. Ecma International approved the Dart language specification first edition in July 2014, at its 107th General Assembly, and the second edition in December 2014. And its latest version 2.0.0-dev.60 (beta) was released on June 4, 2018; 8 days ago.

The goals for Dart are - Performance, Developer Usability and Tooling.

Performance – Dart is designed with performance characteristics in mind, so that it is possible to create VMs that do not have the performance problems that all EcmaScript VMs must have.

Developer Usability – Dart is designed to keep the dynamic, easy-to-get-started, no-compile nature of Javascript that has made the web platform the clear winner for hobbyist developers.

Ability to be Tooled – Dart is designed to be more easily tooled (e.g. with optional types) for large-scale projects that require code-comprehension features such as refactoring and finding all sites. Dart, however, does not require tooling to be effective - small-scale developers may still be satisfied with a text editor.

Features of Dart

Fast

Dart provides optimizing ahead-of-time compilation to get predictably high performance and fast startup across mobile devices and the web.

Productive

Dart’s syntax is clear and concise, it's tooling simple yet powerful. Sound typing helps you to identify subtle errors early. Dart has battle-hardened core libraries and an ecosystem of thousands of packages.

Portable

Dart compiles to ARM and x86 code so that Dart mobile apps can run natively on iOS, Android, and beyond. For web apps, Dart transpired to JavaScript.

Reactive

Dart is well-suited to reactive programming, with support for managing short-lived objects - such as UI widgets - through Dart’s fast object allocation and generational garbage collector. Dart supports asynchronous programming through language features and APIs that use Future and Stream objects.

Approachable

Dart is familiar to many existing developers, thanks to its unsurprising object orientation and syntax. If you already know C++, C#, or Java, you can be productive with Dart in just a few days.

Let’s take a look on the usability of Dart -

  • To run in mainstream web browsers, Dart relies on a source-to-source compiler to JavaScript. According to the project site, Dart was designed to be easy to write development tools for, well-suited to modern app development, and capable of high-performance implementations.

  • When running Dart code in a web browser the code is precompiled into JavaScript using the dart2js compiler.

  • The language maintains the dynamic nature of JavaScript, which has made it such a popular scripting language for the web. However, it’s easily tooled, with optional types, allowing refactoring and IDE code-comprehension (which gives Intellisense etc.) - vital features for enterprise application development.

  • Dart is designed to run on a VM (Virtual Machine) within the browser, just as JavaScript does. It can also be run within a browser that does not have a Dart VM by compiling it to JavaScript. It's essential to the success of the language, allowing it to be used across any browser, regardless of whether the manufacturer chooses to support the Dart VM.

  • Using the Dart language, you can quickly write prototypes that evolve rapidly, and you also have access to advanced tools, reliable libraries, and good software engineering techniques.

  • Dart is AOT (Ahead Of Time) compiled to fast, predictable, native code, which allows almost all of Flutter to be written in Dart. This not only makes Flutter fast, virtually everything (including all the widgets) can be customized.

  • Dart can also be JIT (Just In Time) compiled for exceptionally fast development cycles and game-changing workflow.

  • Dart makes it easier to create smooth animations and transitions that run at 60fps. Dart can do object allocation and garbage collection without locks. And like JavaScript, Dart avoids preemptive scheduling and shared memory (and thus locks).

  • Strong typing to catch bugs earlier, boost quality, and improve applications built by large teams.

  • Defining the UI as code so the need for context switching between a UI markup language and the programming language is reduced.

  • Dart allows Flutter to avoid the need for a separate declarative layout language like JSX or XML, or separate visual interface builders because Dart’s declarative, programmatic layout is easy to read and visualize. And with all the layout in one language and in one place, it makes easy to provide advanced tooling that makes the layout a snap.

  • Developers have found that Dart is particularly easy to learn because it has features that are familiar to users of both static and dynamic languages.

  • Dart is one of very few languages (and perhaps the only “mainstream” language) that is well suited to be compiled both AOT and JIT. Supporting both kinds of compilation provides significant advantages to Dart.

  • Dart, like JavaScript, is single-threaded, which means it does not allow preemption at all. Instead, threads explicitly yield (using async/await, Futures, or Streams). This gives the developer more control over execution. Single threading helps the developer ensure that critical functions (including animations and transitions) are executed to completion, without preemption. This is often a big advantage not just for user interfaces, but for other client-server code.

  • Dart uses an advanced generational garbage collection and allocation scheme, which is particularly fast for allocating many short-lived objects. Dart can allocate an object with a single pointer bump (no lock required). This results in a smooth scrolling and animation, without jank.

  • Dart creates terse and easy to understand layout, while the “crazy fast” hot reload lets you see the results instantly. And that includes the non-static parts of your layout.

  • Dart also supports both loose and strong typing, making it much easier to use when moving from a different language. The strong typing to be very welcome and overall found Dart to be a great balance between the ease of use of JavaScript and the more structured nature of C#.

  • It's a very capable language on the client and the server. It can be used for everything from creating web pages and web-based games (with pure DOM or WebGL/Canvas). It can also be used to create text-based games on the CLI (command line interface). I’ve also used it in the past to write a MUD (basically a multiplayer text game that you telnet into).

  • Dart can be compiled to native code for ARM and x86 platforms. Google has used the language to build applications for iOS, Android, and the web.

 

You can also check its advantages over JavaScript.

 

The discussion of Dart has hopefully sparked your interest in this new language that may or may not take the web by storm. Share your opinions about Dart in the comments. Thank you!

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!