Dart 2.1 Is Smaller And Faster
Written by Kay Ewbank   
Friday, 30 November 2018

Google has updated Dart with a new version, 2.1, that has smaller code size, has faster tools, and offers faster type checks.

Dart was originally created as an alternative to JavaScript that would be supported directly by browsers rather than being compiled to JavaScript. This never caught on because other than Chrome,  browsers never added support, and even Chrome dropped support after a while. Instead, Dart was redeveloped as a better compiler.

dartlogo

When Dart was released earlier this year, the rewritten version was revealed to be strongly typed by default, class based, and treats functions as objects. Mike James described Dart 2 back when the beta was revealed as resulting from taking modern JavaScript - say ES2015 - and adding a true hierarchical type system to it, and with a chance of being used in the mobile app world.

Dart 2 also included a sound type system. In other words, you can't create expressions that evaluate to a value that doesn’t match the expression’s static type. Dart’s type system enforces this using a combination of static checking (compile-time errors) and runtime checks.

However, despite the sound checking, the new version includes support for int-to-double conversion to avoid errors caused when an expression expects a double but gets an integer.

The new version also has better support for mixins. These provide a way of reusing a class’s code in multiple class hierarchies, and Dart 2.1 introduces a new syntax for mixins, with a new mixin keyword that you can use to define classes that can only be used as mixins. They can also now extend other classes and can invoke methods in their superclass.

dartmixin

The performance improvements apply to specific groups of developers, in particular Flutter developers and Web developers. Flutter is Google’s mobile app SDK that can be used to create native interfaces on iOS and Android. It uses Dart as its language, and the updated version has been changed so that the checks added by the new type system no longer cause a large overhead. Web developers should also see an improvement as the code size and compile time for Dart code running on the web has been improved; the development team for Dart say they've seen good results, such as a 17% reduction in minified output size and 15% improvement in compilation time in some cases.

Other changes to the new version include support for protocol buffers. These are a language-neutral, platform-neutral way to serialize structured data. The mechanism is being widely adopted abd supported, and is used extensively inside Google. 

Another improvement is support for serving Dart code on knative. This is a platform based on Kubernetes that supports building, deploying, and managing serverless workloads. The Dart team says they know knative will probably be too low-level for most Dart app developers, but think it might become a critical building block to get better support for serving Dart code in the Google Cloud in situations such as  creating backends for Flutter apps.

The Dart SDK 2.1 is now available for download from the Dart homepage, while Flutter developers will find it included as part of the Flutter 1.0 release.

 

 

dartlogo

More Information

Dart

Flutter

Related Articles

Dart 2 Released With New Mobile Focus

Google's Dart Reborn As Cross Platform App Language

Dart Changes Course - No Longer To Be Native In Chrome

The Astonishing Rise Of Dart

Ecma Approves Dart

Dart 1.8 Adds Support for App Engine and enums

Dart + Chromium = Dartium

Angular Partners With TypeScript

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


The WinterJS Javascript Runtime Is Asking For Your Attention
11/04/2024

WinterJS is a brand new Javascript runtime by Wasmer which comes with the claim that it's the fastest of them all. Let's find out if that holds true.



Supersimple - Deep Insights From Data
02/04/2024

Announcing $2.2 Million in pre-seed funding, the Estonian startup Supersimple has launched an AI-native data analytics platform which combines a semantic data modeling layer with the ability to answer [ ... ]


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Friday, 30 November 2018 )