Paul Krill
Editor at Large

Dart 2.6 brings native compilation to the desktop

news
Nov 20, 20192 mins

A new extension to the Dart compiler set allows you to create self-contained executables for Linux, MacOS, and Windows

10 targeted training bullseye
Credit: Getty Images

As part of the recent rollout of Dart 2.6, the Google engineers behind the language introduced dart2native, an extension to the Dart compiler set that extends native compilation to the Linux, MacOS, and Windows desktop platforms.

This extension offers the ability to compile Dart programs to self-contained executables. These executables contain ahead-of-time compiled machine code. Because dart2native extends native compilation support to traditional desktop OSes running Linux, MacOS, and Windows, it allows native applications to be built in Dart for these platforms. 

Compiled with Dart’s AOT compiler, executables can run on machines without the Dart SDK installed. They also start running in a matter of milliseconds. Previously, native compilation to machine code was limited to the iOS and Android mobile platforms. Users had asked for AOT compilation for desktop OSes.

The dart2native extension enables building and deploying of apps for the command line. These apps use libraries such as dart.io for IO; package:httpcode for networking, and package:args for parsing arguments. The extension also is compatible with dart:ffi, a mechanism for C language interoperability that was launched in preview in Dart 2.5. A new version is offered in Dart 2.6.

The dart2native compiler also can be used for small services such as a back-end supporting a front-end app using the Flutter toolkit. But dart2native does have some initial limitations, such as no cross-compilation support. The compiler supports creating machine code only for the OS it is running on, so would need to be run three times to create executables for MacOS, Linux, and Windows. Executables produced also cannot be signed.

Also featured in Dart 2.6 is a preview of static extension methods, a language feature that could solve an issue with introducing new functionality to existing types.

Where to download Dart 2.6 and dart2native

You can get Dart 2.6 and the dart2native compiler by downloading the Dart SDK. Instructions for installing the SDK can be found at dart.dev.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author