📜 ⬆️ ⬇️

Dart Developer Summit 2016: Top Dart News


October 26-27, Munich hosted the Dart Developer Summit. It has been held by Google for the second year in a row and it invariably gathers all developers who are not indifferent to the young language.


As you may know , the Wrike team is actively using the new Angular 2 (Dart) framework in its Dart project.


Currently, Wrike has 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 mostly 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 learn firsthand about news about the development of the platform, as well as communicate with developers language personally.


In this article I will talk about the most important and interesting, in our opinion, announcements and events that occurred at this conference.



Angular 2



This summer, the Angular Dart team decided to separate its code base from the Angular TypeScript version for a number of reasons, including the ability to write more optimal and idiomatic dart code, and also because of the redundancy of some parts of the framework that were available out of the box in standard Dart library (for example, 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, which took place during the Dart Summit, did not come as a surprise to us, but the fact that the AngularDart team kept its promise regarding the release dates was pleasant for us.


(The following is a translation of a short interview with the developers of AngularDart 2.0 from the recent blog post “AngularDart: The best Angular for you?” in the official Dart blog) :


Can you name the most important reason why people should try the new AngularDart 2.0?


Improved performance. And, as we said recently at the Dart Summit, the goal of AngularDart is to provide developers with three main things: Productivity, Productivity and Stability.




Undoubtedly, you have presented impressive performance improvements in both output size and speed. What exactly has allowed you to achieve such results in such a short period?


Reducing the size was achieved by combining easily achievable techniques, such as whitespace compression, concentrating on the generation of ideomatic Dart code (note of the translator: for example, all this was removed from the code), and refactoring to remove dynamic calls and layers of abstraction, as far as was possible. To increase performance in runtime, we relied on a strict type system and abandoned “dirty checking” in favor of the new model for working with changes ComponentState


AngularDart 2.0 was released not long ago. I’m wondering if it’s 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. We wrote thousands of tests to make sure that all subsequent performance improvements will not break anything.


Great! So, where should 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 start 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 out the latest information about AngulaDart .


→ Link to original article


Strong mode


Relatively much attention has been paid to the issue of strong typing in Dart. Although Dart itself is not a fully statically typed language, Dart has full 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 especially “meticulously” analyzes such errors.


Google has already translated its products to use Strong Mode. This is done for several reasons. First of all, it allows developers to refactor easier, to write more supported code. However, an equally important reason for using Strong Mode is that code tools can rely on the 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.


In more detail about what Strong Mode is and why it is needed, you can read in this document or look in the report from the Dart Summit:



DDC


Another part that complements the Dart development infrastructure is the Dart Dev Compiler or DDC, which was also discussed at the summit. As its name implies, this is a compiler used for development mode.


Currently, development on Dart has certain inconveniences due to the fact that the virtual machine, which allows you to quickly update the code for subsequent work with it in the browser, is only available in the Dartium browser. In the case when debugging is done in any other browser, including Chrome, the dart2js compiler is used. It compiles the entire code (and not just the modified one) each time changes are made in the code. With a relatively large code base, this approach may not be convenient enough.


When developing with DDC, the approach changes significantly. First, Google plans to abandon further support for Dartium in favor of developing on DDC, which means that the code being developed will henceforth be launched 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 the integration with DevTools in the browser.


Another important advantage is that 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, and not replaces it, and soon all compilers (dart2js, DDC, vm) will have the same code base .



Js interop


One of the problems for any new language is the interaction with the old code. In the world of the web, more than a billion lines of code are written on js, which for the most part will hardly ever be rewritten to Dart. Therefore, the Dartlang team made great efforts to improve interaction with the js world.


Previously, a simple call "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 can not check the types, you have to rely only on "js intuition."


In the new edition, the solution of 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, earlier to interact 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, since all types in the 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.


In more detail about the syntax and the very essence of the new approach, you can read here , or watch the video from the conference:



Existing restrictions : do not mix the old (import 'dart: js') and new (import "package: js / js.dart") style.


The team also did a great job to automate the generation of wrappers around the js code .


Flutter


In addition, a new framework for mobile development on Dart - Flutter was demonstrated at the conference. Although the framework itself is still in the alpha version, the presentation was quite impressive.




Here are a couple of links where you can read about this framework in more detail.



Dart meet-up


We in Wrike spend a lot of time spreading knowledge and developments on Dart both within our own team and with those developers who want to use this language in their projects and do not know where to start. For this, we have a Russian-language slack channel , and on November 30 in St. Petersburg we will organize a Dart-Metap . Product managers and language developers from Google will speak on it, a representative of JetBrains will talk about the features of IntelliJ IDEA for Dart developers, and my colleagues from Wrike will share their experience of a smooth transition to Dart development from other programming languages ​​(C #, JavaScript).


Additional links:



')

Source: https://habr.com/ru/post/315768/


All Articles