Dart 2.15 programming language and Flutter 2.8 framework available

Google has published a release of the Dart 2.15 programming language, which continues the development of a radically redesigned Dart 2 branch, which differs from the original version of the Dart language by using strong static typing (types can be automatically inferred, so specifying types is not required, but dynamic typing is no longer used and was calculated initially the type is assigned to the variable and then strict type checking is applied).

Dart language features:

  • A familiar and easy-to-learn syntax that is natural for JavaScript, C, and Java programmers.
  • Providing fast startup and high performance for all modern web browsers and various types of environments, from portable devices to powerful servers.
  • The ability to define classes and interfaces to enable encapsulation and reuse existing methods and data.
  • Specifying types makes it easier to debug and detect errors, makes the code clearer and more readable, and makes it easier for third-party developers to refine and analyze it.
  • Among the supported types: various types of hashes, arrays and lists, queues, numeric and string types, date and time types, regular expressions (RegExp). It is possible to create your own types.
  • To organize parallel execution, it is proposed to use classes with the isolate attribute, the code of which is executed completely in an isolated space in a separate memory area, interacting with the main process by sending messages.
  • Support for the use of libraries that simplify the support and debugging of large web projects. Third-party implementations of functions can be included as shared libraries. Applications can be broken down into parts and the development of each part can be assigned to a separate team of programmers.
  • A set of ready-made tools to support development in the Dart language, including the implementation of dynamic development tools and debugging with code correction on the fly ("edit-and-continue").
  • An SDK, a pub package manager, a dart_analyzer static code analyzer, a set of libraries, a DartPad IDE, and Dart-enabled plugins for IntelliJ IDEA, WebStorm, Emacs, Sublime Text 2, and Vim are provided to simplify Dart development.
  • Additional packages with libraries and utilities are distributed through the pub repository, which has about 22 packages.

Key changes in the release of Dart 2.15:

  • Means are provided for fast parallel execution of tasks with isolation of handlers. On multi-core systems, the Dart runtime runs application code on one CPU core by default, and uses other cores to perform system tasks such as asynchronous I/O, writing to files, or making network calls. For applications that need to execute their handlers in parallel, for example, to draw animations in the interface, it is possible to run separate blocks of code (isolate), isolated from each other and executed on other CPU cores simultaneously with the main application thread. To protect against errors that occur when code that works with the same data set is simultaneously executed in different isolate blocks, the sharing of mutable objects is prohibited, and a message-passing model is used for interaction between handlers.

    Dart 2.15 introduces a new concept - isolate groups, which allows you to share various internal data structures in isolate blocks that are part of the same group, which can significantly reduce the overhead when interacting with processors in a group. For example, running an additional isolate block in an existing group is 100 times faster and requires 10-100 times less memory than running a separate isolate block, by eliminating the need to initialize program data structures.

    Although isolate blocks in a group still do not allow shared access to mutable objects, groups use shared heap memory, which can significantly speed up the transfer of objects from one block to another without the need for resource-intensive copy operations. The new version also allows you to pass the result of the handler when calling Isolate.exit() to pass data to the parent isolate block without copy operations. In addition, the message passing mechanism has been optimized - small and medium messages are now processed approximately 8 times faster. Some types of functions, closures, and stack traces are included among the objects that can be passed between isolate blocks using the SendPort.send() call.

  • In the tools for creating pointers to individual functions in other objects (tear-off), the restrictions on creating such pointers in the code of constructors have been removed, which can be useful when building interfaces based on the Flutter library. For example, to create a Column widget that includes multiple Text widgets, you can call ".map()" and pass pointers to the Text.new constructor of the Text object: class FruitWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Column( children: ['Apple', 'Orange'].map(Text.new).toList()); } }
  • The possibilities connected with use of pointers on functions are expanded. Added the ability to use generic methods and function pointers to create a non-generic method and pointer: T id (T value) => value; var intId = id ; // allowed in version 2.15 instead of "int Function(int) intId = id;" const fo = id; // function pointer id. const c1 = fo ;
  • Support for enums has been improved in the dart:core library, for example, now you can output a string value from each enum value using the ".name" method, select values ​​by name, or match value pairs: enum MyEnum { one, two, three } void main() { print(MyEnum.one.name); // "one" will be printed. print(MyEnum.values.byName('two') == MyEnum.two); // "true" will be printed. final map = MyEnum.values.asNameMap(); print(map['three'] == MyEnum.three); // "true". }
  • A pointer compression technique has been implemented that allows a more compact pointer representation in 64-bit environments, if a 32-bit address space is sufficient for addressing (using no more than 4 GB of memory). Tests have shown that this optimization makes it possible to reduce the heap size by approximately 10%. In the Flutter SDK, the new mode is already enabled for Android by default, and is scheduled to be enabled for iOS in a future release.
  • The Dart SDK includes debugging and performance analysis tools (DevTools), which were previously provided in a separate package.
  • Added tools to the "dart pub" command and the pub.dev package repositories to track the inadvertent publication of sensitive information, such as leaving credentials inside the package for continuous integration systems and cloud environments. If such leaks are detected, the execution of the "dart pub publish" command will be aborted with an error message. In the event that a false positive has occurred, the ability to bypass the check through the white list is provided.
  • Added the ability to revoke an already published version of a package to the pub.dev repository, for example, in case of dangerous bugs or vulnerabilities. Previously, for such fixes, it was practiced to publish a correction version after it, but in some situations it is necessary to cancel the existing release and urgently stop its further distribution (for example, if the fix is ​​not yet ready or if by mistake a full release was published instead of a test version). After the revocation, the package is no longer defined in the "pub get" and "pub upgrade" commands, and on systems that have already installed it, a special warning is issued the next time "pub get" is performed.
  • Added protection against a vulnerability (CVE-2021-22567) caused by the use of unicode characters in the code that changes the display order.
  • Addressed a vulnerability (CVE-2021-22568) that could allow impersonation of another pub.dev user when publishing packages to a third-party server that accepts pub.dev oauth2 access tokens. For example, the vulnerability could be used to attack internal and corporate package servers. Developers who only host packages on pub.dev are not affected.

At the same time, a significant release of the Flutter 2.8 user interface framework is presented, which is considered as an alternative to React Native and allows you to release applications for iOS, Android, Windows, macOS and Linux platforms based on a single codebase, as well as create applications to run in browsers. On the basis of Flutter, the user shell of the Fuchsia microkernel operating system developed by Google is built. It is noted that over the past six months, the number of applications on Flutter 2 in the Google Play Store has increased from 200 thousand to 375 thousand, i.e. almost twice.

The bulk of the Flutter code is implemented in Dart, and the runtime engine for running applications is written in C++. When developing applications, in addition to Flutter's native Dart language, you can use the Dart Foreign Function interface to call C/C++ code. High runtime performance is achieved by compiling applications to native code for target platforms. At the same time, the program does not need to be recompiled after each change - Dart provides a hot reload mode that allows you to make changes to a running application and immediately evaluate the result.

Of the changes in the new release of Flutter, optimization of startup speed and memory consumption on mobile devices is noted. Simplified connection of applications to backend services such as Firebase and Google Cloud. Stabilized tools for integration with Google Ads. Significantly improved support for cameras and web plugins. New tools have been proposed to simplify development, for example, a widget for authentication using Firebase has been added. Updated the Flame engine for developing 2D games using Flutter.

Source: opennet.ru

Add a comment