BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Dart 2.6 Goes Native on Linux, Windows, and MacOS

Dart 2.6 Goes Native on Linux, Windows, and MacOS

Leia em Português

This item in japanese

Bookmarks

The latest version of Google's 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 that 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 was available only on iOS and Android. Thanks for dart2native, Dart can now target a wide range of platforms, from mobile to the web, and from the desktop to embedded devices.

According to Dart and Flutter program manager Michael Thomsen, an ideal scenario to leverage dart2native is serverless computing, where the 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.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT