⬆️ ⬇️

Announcement Dart 2.0: Optimized for customer development

Today we are announcing Dart 2 , a reload of the language that more fully reflects our vision of Dart as a uniquely optimized language for client development on the Web and mobile platforms.



Dash - the official language mascot

Dash - the official language mascot



With Dart 2, we significantly strengthened and simplified the type system, cleared the syntax, and rewrote most of the tools from scratch to make mobile and web development more enjoyable and productive. Dart 2 also takes into account lessons learned from early language users, including Flutter , AdWords and AdSense , as well as thousands of improvements, large and small, made in response to customer feedback.



Basic Dart Principles



Before we talk about innovations in Dart 2, it is worth understanding why we believe that Dart meets all the needs of the developers of client code.

')

In addition to the properties required for a modern general-purpose language, the language for client development should be:





Dart is used to create mission-critical, high-quality applications on the Web, iOS, and Android in Google and other companies, and is great for mobile and web development:





Dart 2: Improved Customer Support



In Dart 2, we have taken a few things to make Dart an excellent language for writing client code. In particular, we added several new features, including strong typing and improving how the user interface is defined through code.



Strong typing



The teams behind AdWords and AdSense, using Dart, created one of Google’s largest and most advanced advertising management web applications; these services generate a significant portion of Google’s revenue. Working closely with these teams, we decided to strengthen the Dart type system. This will help Dart-programmers catch errors in the development process, better scale applications created by large teams, and improve the overall quality of the code.



Of course, this is nothing unique. The Web ecosystem also tends to add types to JavaScript. For example, TypeScript and Flow extend JavaScript with annotations and type inference to improve code analysis capabilities.



In the small example below, Dart 2 reveals an implicit error and, as a result, helps to improve the overall quality of the code.



void main() { List<int> prices = ['99', '27', '10000', '20000000']; //       prices.sort(); print('  : ${prices[0]}!'); } 


What does this code do? You can expect it to print "27". But without the Dart 2 type system, he typed “10,000”, because this is the very first element in the list of lines, lexicographically ordered. However, with Dart 2, this code will generate a typing error.



User interface through code



When creating a user interface, the need to switch between a separate markup language and the programming language you use in an application often causes irritation. We aim to reduce the need for context switching. Dart 2 introduces the optional new and const . This functionality is very valuable in itself, and also opens up other possibilities . For example, thanks to the optional new and const, we can make the definition of a widget more clean and simple.



 //  Dart 2 Widget build(BuildContext context) { return new Container( height: 56.0, padding: const EdgeInsets.symmetric(horizontal: 8.0), decoration: new BoxDecoration(color: Colors.blue[500]), child: new Row( ... ), ); } //  Dart 2 Widget build(BuildContext context) => Container( height: 56.0, padding: EdgeInsets.symmetric(horizontal: 8.0), decoration: BoxDecoration(color: Colors.blue[500]), child: Row( ... ), ); 


Using Dart on the client side



Mobile platforms



One of the most important uses for Dart is Flutter , Google’s new mobile platform for creating user interfaces for iOS and Android. The official app for the extremely popular Hamilton: The Musical show - an example of how Flutter helps developers create apps in record time. Flutter uses a reactive programming style and controls the user interface pixel by pixel. For Flutter, Dart is ideally suited, in terms of ease of learning, reactive programming, high development speed and a high performance execution system with a fast garbage collector.



Web



Dart perfectly proved itself as a platform for critical web applications. It has web libraries such as dart: html , as well as a full web environment based on dart . Teams using Dart for the Web were thrilled with the improved development speed. As Manish Gupta, vice president of development for Google AdWords, says:

The AdWords interface is large and complex, and it is crucial to Google’s revenue .

We chose Dart because of the excellent combination of productivity and predictability, ease of learning, type system and support in the Web and mobile devices .

Our engineers are two to three times more productive than before, and we are glad that we switched to Dart.

What's next



With Flutter and Dart, developers finally got the opportunity to write quality applications for Android, iOS and the Web without any compromises, using a common code base. As a result, team members can smoothly move between platforms and help each other, for example, check the code. Teams like AdWords Express and AppTree reuse from 50% to 70% of their code on mobile devices and the Web.



Dart is an open source project that supports the open standard ECMA . We welcome contributions to both the core Dart project and the growing ecosystem of packages for Dart.



You can try Dart 2 in Flutter and Dart SDK directly from the command line. For Dart SDK, download Dart 2 from the dev channel and run your code with the flag --preview-dart-2 . We also invite you to join our gitter community.



Thanks to the improvements announced today, Dart 2 is a productive, clean and proven language that solves the problems of developing modern applications. He is already loved by some of the most demanding developers on the planet, and we hope that you will like it too.



Translator's note : join the Dart community in Telegram or Slack .

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



All Articles