Dart Developer Summit 2016: breaking news from the world of Dart

On October 26-27, the Dart Developer Summit was held in Munich. It has been held by Google for the second year in a row and invariably gathers all developers who are not indifferent to the young language.
As you may know , the Wrike team actively uses Dart in their project in conjunction with the new Angular 2 (Dart) framework.
Currently, Wrike employs more than 45 front-end developers writing Dart, and the number of lines of code has already exceeded several hundred thousand lines. And although the conference was designed mainly for those who either started using Dart and Angular 2 not so long ago, or while only considering Dart as a possible option, it was important for us to get first-hand news about the development of the platform, as well as communicate with developers language in person.
In this article I will talk about the most important and interesting, in our opinion, announcements and events that took place at this conference.
Angular 2
This summer, the Angular Dart team decided to separate their code base from the TypeScript version of Angular for a number of reasons, including the possibility of writing a more optimal and idiomatic dart code, as well as due to the redundancy of some parts of the framework that were available “out of the box” in the standard Dart library (e.g. modules). For this reason, the official release of the Dart version of this framework took place a month later than the TypeScript version.
As a result, the official release of Angular 2 Dart during Dart Summit, although it did not come as a surprise to us, but the fact that the AngularDart team kept their promise regarding the release dates was pleasant for us.
(The following is a translation of a short interview with the AngularDart 2.0 developers from the recent “AngularDart: The best Angular for you?” blog post on the official Dart blog) :
Can you name the most important reason people should try the new AngularDart 2.0?
Improved performance. And, as we said recently at Dart Summit, the goal of AngularDart is to provide developers with three main things: Productivity, Productivity, and Stability.
- AngularDart is a great framework for building web applications, and our company has teams that have doubled their productivity thanks to Dart + Angular.
- With the latest release, the code size has been reduced by 40%, the framework has become 10% faster.
- In addition, since Google has several key (interpreter: AdWords, AdSense implied) teams whose products depend on this framework, we are working hard to ensure stability when making the above improvements.

Undoubtedly, you have presented impressive performance improvements in terms of both output size and speed. What exactly allowed you to achieve such results in such a short period?
The size reduction was achieved through a combination of easily achievable techniques, such as whitespace compression, focusing on generating ideal Dart code (note translator: for example, all of this were thrown out of the code), and refactoring to remove dynamic calls and layers of abstraction, as far as it is was possible. To increase productivity in runtime, we relied on a strict type system and abandoned “dirty checking” in favor of a new model for working with changes. ComponentState
AngularDart 2.0 was released not so long ago. I am wondering if it is stable enough to start using it today? You said that it has already been used in production for several months. How can this be?
Yes. We have key products ( AdWords, for example ) that have been using AngularDart 2 for several months now. We have written thousands of tests to make sure that all subsequent performance improvements do not break anything.
Wow! So where do I start if I want to try or learn more about AngularDart 2?
You can watch the video from our presentation at the 2016 Dart Summit. We also have tutorials that can help you get started using AngularDart, and even one with the new AngularDart components that Ted talked about at the summit . And of course, angulardart.org , where you can find the latest information on AngulaDart .
→ Link to the original article
Strong mode
Relatively much attention was paid to the issue of strong typing in Dart. Although Dart itself is not a fully statically typed language, Dart has full-fledged type support, as well as a static analyzer that allows you to check typing errors as well. One of the analyzer modes is Strong Mode, which particularly “meticulously” analyzes such errors.
Google has already switched its products to using Strong Mode. This is done for several reasons. First of all, it makes it easier for developers to refactor and write more supported code. However, an equally important reason for using Strong Mode is that code tools can rely on a type system. So, for example, the new compiler for developing the Dart Dev Compiler (DDC), which will be discussed below, relies on a type system to generate more human-readable js code.
You can read more about what Strong Mode is and why you need it in this document or see the report with Dart Summit:
Ddc
Another part that complements the development infrastructure at Dart is the Dart Dev Compiler or DDC, which was also discussed at the summit. As its name implies, it is a compiler used for development mode.
Currently, development on Dart has certain inconveniences associated with the fact that the virtual machine, which allows you to quickly update the code for subsequent work with it in the browser, is only in the Dartium browser. In the case when debugging is carried out in any other browser, including Chrome, the dart2js compiler is used. It compiles all of the code (and not just the modified one) every time changes are made to the code. With a relatively large code base, this approach may not be convenient enough.
When developing with DDC, the approach changes significantly. Firstly, Google plans to abandon further support of Dartium in favor of development on DDC, which means that from now on the developed code will run in the same environment as the production code, i.e. in any modern browsers. Secondly, thanks to strong mode, DDC can trust the type system and generate ES6 code, which visually practically does not differ from the original Dart code, which greatly simplifies debugging. In addition, it simplifies integration with DevTools in the browser.
Another important plus is that the DDC recompiles only the changed part of the code, and not the entire code base. Moreover, to further accelerate development, integration with modular frameworks such as Webpack can be performed , for example, to provide hot reload.
It is worth noting that DDC complements dart2js, but does not replace it, and soon all compilers (dart2js, DDC, vm) will have one code base .
Js interop
One of the challenges for any new language is interacting with old code. In the web world, more than a billion lines of code are written in js, most of which are unlikely to ever be rewritten in Dart. Therefore, the Dartlang team made great efforts to improve interaction with the js world.
Previously, a simple call to “JSON.stringify (a)” in Dart looked like this:
import 'dart:js' as js;
var a = { 'value' : 1 };
var str = js.context["JSON"].callMethod("stringify", [a]);With this approach, you do not have the ability to check types, you have to rely only on "js intuition".
In the new edition, the solution to this problem looks much simpler:
import "package:js/js.dart";
@JS("JSON.stringify")
external String stringify(obj);
var a = { 'value' : 1 };
var str = stringify(a);Moreover, before interacting with js it was necessary to create an object of type Map:
var jsObj = new JsObject.jsify({'value':1});
jsMethod(jsObj);Of course, in this situation, we could not rely on any type checking, because all types in Map (both keys and values) were dynamic.
In the new edition, everything looks more transparent:
@JS()
@anonymous
class Options {
external int get value;
external factory Options({bool value});
}
var jsObj = new Options(value: 1);
jsMethod(jsObj);So we get full control over what fields the object has and what type they are.
You can read more about the syntax and the very essence of the new approach here , or watch the video from the conference:
Existing restrictions : you cannot mix the old (import 'dart: js') and new (import "package: js / js.dart") styles.
The team also did a great job to automate the generation of wrappers around js code .
Flutter
Помимо этого, на конференции был продемонстрирован новый фреймворк для мобильной разработки на Dart — Flutter. Хотя сам фреймворк пока что еще находится в alpha версии, презентация была довольно впечатляющая.
Вот еще пара ссылок, где вы можете прочитать про этот фреймворк более подробно.
Dart meet-up
Мы в Wrike много времени уделяем распространению знаний и наработок по Dart как внутри собственной команды, так и с теми разработчиками, которые хотят использовать этот язык в своих проектах и не знают, с чего начать. Для этого у нас есть русскоязычный slack канал, а 30 ноября в Питере мы организуем Dart-митап. На нем выступят продакт-менеджеры и разработчики языка из компании Google, представитель компании JetBrains расскажет об особенностях IntelliJ IDEA для Dart разработчиков, а мои коллеги из Wrike поделятся опытом безболезненного перехода в разработку на Dart с других языков программирования (C#, JavaScript).
Дополнительные ссылки:
- Конечно же, на конференции были и другие интересные доклады. Полный плейлист находится здесь.
- Another success story for moving to AngularDart from the AdSense team
- Dart in 2017 and beyond