The latest version of Google programming language Dart, numbered 2.6
, extends support for native, ahead-of-time (AOT) compilation with the addition of
, which enables the creation of command-line programs on Linux, Windows, and MacOS.
generates self-contained binaries, meaning they do not require the Dart SDK to run. Another key feature of
is it supports the whole set of Dart core libraries
which are available on the rest of Dart-targeted platforms.
is also compatible with
, the C-interoperability layer introduced in Dart 2.5 to interface with C=compatible system functions available on a native platform.
AOT compilation was already supported in Dart through Flutter, but exclusively on iOS and Android. Thanks for
, Dart can now target a wide range of platforms, frommobile to theWeb, and from the desktop toembedded devices.
According to Dart and Flutter program manager Michael Thomsen, an ideal scenario to leverage
is serverless computing, where key is minimizing latency when starting the execution of a remote function.
By compiling your service’s code ahead-of-time to native code, you can avoid this latency and begin running right away.
Going native means startup times are in order of milliseconds, which provides a great improvement over just-in-time (JIT) compilation. Another advantage of using
is the reduction of program footprint.
Dart developer Paul Mundt recently documented his experiences with using the dart2native compiler; he was able to reduce the size of his Docker image by 91% from 220MB using JIT-compiled code down to just 20MB by using native code!
In addition to
, Dart 2.6 includes a new language feature, extension methods
, which makes it possible to extend a class by adding additional methods to it in a different scope than its original creation context.
You can get Dart 2.6, which includes
. Updating Dart through Flutter, though, will not install full