What’s new in Google’s Dart 2.2 language

Dart 2.2 improves performance of ahead-of-time (AOT) compiled native code and extends literals to support sets

What’s new in Google’s Dart language
15299 (CC0)

Google’s Dart language, once positioned as a potential replacement for JavaScript in the browser, was rebooted for client-side web and mobile development with the release of Dart 2 in August 2018. Dart 2.2 is now available..

Dart 2 features a strengthened type system, a cleaned-up syntax, and a rebuilt developer tool chain. Dart has a succinct syntax and can run on a VM with a just-in-time compiler, with the compiler enabling stateful, hot reload during mobile development.

Developers also gain from fast development cycles where code can be edited, compiled, and replaced in apps running on a device. Compiling code ahead of time provides fast startup, Google said.

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.

Where to download Dart 2

You can download the production version of Dart 2 from dartlang.org.

New version: What’s new in Dart 2.2

Released in February 2019, Dart 2.2. improves performance of ahead-of-time (AOT) compiled native code, by reducing the overhead of static calls. Optimized code now can call the destination directly using a PC-relative call. Previously, several lookups to an object pool had to be made to determine a destination address. The optimizations are especially useful when code has a lot of constructor and static method calls, such as Flutter UI code that creates widgets.

Other new features in Dart 2.2 include:

  • Literals have been extended to support sets, providing for a convenient new syntax. Sets are unordered collections of values where each value can only occur just once and developers can check whether a value is in a set. Previously, literal syntax only supported lists and maps.
  • The language specification has been updated.

Previous version: What’s new in Dart 2.1

November 2018’s Dart 2.1 update features smaller code size, better usability for type errors, faster type checks, and capabilities to improve productivity when building user experiences. Code size and compile time have been enhanced for web deployments. The Dart project team focused on the output size of Dartjs, the Dart-to-JavaScript compiler. They report a 17 percent reduction in minified output size and a 15 percent improvement in compilation time in a sample experiment.

Support for int-to-double conversion, meanwhile, means Dart 2.1 can infer where an integer needs to be silently evaluated as a double value. Google’s Michael Thomsen, product manager for Dart and the Flutter mobile toolkit, said that Flutter developers are often tripped up by analysis errors when an API expects a double, but the developers specify an int. The new conversion capability clears up the confusion.

Other new features in Dart 2.1 include:

  • Compile-time type checks, which were incomplete in Dart 2.0, have been completed in the 2.1 release. The previous incompleteness could have caused usability issues, in which bad source code could have compiled without producing errors.
  • The cost of type checks has been reduced for AOT-compiled code and code running in the VM with JIT compilation. This should help improve performance for Flutter developers.
  • A new syntax for mixins is introduced, with a mixin keyword for defining classes that can only be used as mixins. Also, mixins can now extend other classes besides Object and invoke methods in their superclass.

Thomsen also offered a glimpse of what Dart users may see in 2019:

  • More performance improvements, including better support for multicore processors and further reduction of code size to improve download and startup times.
  • Refinements to constant expressions and support for a new Set literal.
  • Further optimizations to assist with building UIs, such as conditionals in widget lists, expanding collections of objects into other objects, and removing the need to terminate statements with semicolons.

Previous version: What’s new in Dart 2.0

Released in August 2018, Dart 2.0 offers a language, framework, and components intended to reduce boilerplate while letting developers concentrate on business logic. Also part of the platform are tools to identify errors early and deliver small, quick runtime code. Dart Version 2 focuses on three areas:

  • Strengthening and tightening the language.
  • Building support for web and mobile frameworks.
  • Extending tools and components that support Google’s usage of the language to the outside world.

New features in Dart 2.0 include:

  • Strong typing to catch bugs earlier, boost quality, and improve applications built by large teams. The type system in Dart 2 catches more errors earlier in the development cycle.
  • Type inference is provided for fields, methods, local variables, and most generic type arguments.
  • The core SDK has libraries for access to modern browser APIs.
  • The AngularDart 5 web framework, inspired by the Angular framework itself, is included.
  • The Dart SDK, which has a package manager that works with the Dart package site. It also features a static analyzer, a linter, and tools for web documentation and code formatting.
  • Access to 100 new classes, including date, time, and Google Material components.
  • Support for Microsoft’s Visual Studio Code editor, through the Dart Code Extension.
  • The DartPad scratchpad application has been updated for Dart 2.
  • Defining the UI as code so the need for context switching between a UI markup language and the programming language is reduced.
  • The language has web-specific libraries such as dart:html and a full web framework.

Copyright © 2019 IDG Communications, Inc.