Dart 2.6 Goes Native on Linux, Windows, and MacOS

The latest version of Google programming language Dart, numbered 2.6 , extends support for native, ahead-of-time (AOT) compilation with the addition of dart2native , which enables the creation of command-line programs on Linux, Windows, and MacOS.

Importantly, dart2native generates self-contained binaries, meaning they do not require the Dart SDK to run. Another key feature of dart2native is it supports the whole set of Dart core libraries which are available on the rest of Dart-targeted platforms. dart2native is also compatible with dart:ffi , 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 dart2native , 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 dart2native 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 dart2native 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 dart2native , 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 dart2native , from https://dart.dev/get-dart . Updating Dart through Flutter, though, will not install full dart2native support.

我来评几句
登录后评论

已发表评论数()

相关站点

+订阅
热门文章