Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: docs/newsletter/20170804.md

Issue 2995543002: Newsletter 2017-08-04. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Dart Language and Library Newsletter
2 2017-08-04
3 @floitschG
4
5 Welcome to the Dart Language and Library Newsletter.
6
7 ## Under Active Development
8 This section provides updates to the areas we are actively working on. Many of t hese sections have a more detailed explanation in a previous newsletter.
9
10 ### Better Organization
11 Goal: collect and organize the documents (proposals, ...) the Dart language team produces.
12
13 We are storing all interesting proposals in `docs/language/informal` (in the [Da rt repository](http://github.com/dart-lang/sdk)).
14
15 For example, there is a proposal for asserts in initializer lists [assert_init]. This feature allows to write basic assertions in the initializer list. The main use-case is for `const` constructors, which are not allowed to have bodies.
16
17 For example:
18 ``` dart
19 class A {
20 final int y;
21 const A(int x) : assert(x < 10), y = x + 1;
22 }
23 ```
24
25 I will cover some of the proposals in future newsletters. Feel free to send me r equests for specific proposals in that directory.
26
27 [assert_init]: https://github.com/dart-lang/sdk/blob/master/docs/language/inform al/assert-in-initializer-list.md
28
29 ### Void as a Type
30 Goal: allow `void` as a type. In particular, make it possible to use it in gener ics, such as `Future<void>`.
31
32 Erik (@eernstg) wrote a first proposal for an informal spec, and we are actively discussing his proposal now. I'm in the process of writing an easily digestible document on this feature (hopefully for the next newsletter), but you can also read Erik's (more formal) proposal here:
33 https://gist.github.com/eernstg/7d79ef7f3e56daf5ce1b7e57684b18c6
34
35 We hope to add this proposal to our documentation directory, soon.
36
37 ### Updates to the Core Libraries
38 Goal: clean up the core libraries. Deprecate rarely used classes/methods and add missing functionality.
39
40 Small progress: we wrote CLs (but haven't submitted them yet) for deprecating `S playTreeMap`, `SplayTreeSet` and `DoubleLinkedList`. These classes (and their te sts) are migrated to `package:collection`. The core SDK has been updated to not use any of these classes anymore.
41
42 While we haven't finalized the list of core library changes, here are a few more likely candidates:
43 * add `map` to `Map`: `Iterable<T> map<T>(T Function(K, V) f)`. This function ma kes it possible to iterate over all key-value pairs (similar to `Map.forEach`) a nd build a new iterable out of them.
44 * add `followedBy` to `Iterable`: `Iterable<T> followedBy(Iterable<T> other)`. W ith this method, it is finally possible to concatenate two iterables. This makes the unintuitive `[iterable1, iterable2].expand((x) => x)` pattern obsolete: `it erable1.followedBy(iterable2)`.
45 * add `+` to `List`: concatenates two lists: `List<T> operator +(List<T> other)` . Contrary to `followedBy` (which is inherited from `Iterable`), using `+` to co ncatenate two lists produces a list that is eagerly constructed. Example: `[1, 2 ] + [3, 4] // -> [1, 2, 3, 4]`.
46
47 These changes are more breaking than the ones we mentioned last week. We don't k now yet how and when we want to land them to avoid the least amount of disruptio n.
48
49
50 ## Deferred Loading
51 The current spec does not allow types to be used across deferred library imports . This makes sense, when the deferred sources are not known. This means that use rs currently have to introduce interfaces for classes that could just be referen ced directly.
52
53 ``` dart
54 // lib1.dart
55 abstract class InterfaceA {
56 foo();
57 }
58 // lib2.dart
59 import 'lib1.dart';
60 class A implements InterfaceA {
61 foo() => 499;
62 }
63 // lib3.dart
64 import 'lib1.dart';
65 import 'lib2.dart' deferred as def;
66
67 main() {
68 InterfaceA a;
69 def.loadLibrary().then((_) => a = new def.A());
70 }
71 ```
72
73 Since dart2js and DDC actually know all the sources during compilation, this boi lerplate code feels painful. We are thus looking into alternatives.
74
75 We discussed one proposal that suggested to remove deferred loading from the lan guage entirely and leave it up to the compilers (DDC and dart2js primarily) to d eal with deferred loading. Instead of language syntax, the compilers would have used annotations and specially recognized functions to effectively have the same semantics as the current specification. They could then evolve from there to pr ovide a better experience.
76
77 Here is an example, of how this would look like:
78
79 ``` dart
80 import "package:deferred/deferred.dart" show deferred, loadLibrary;
81
82 @Deferred("lib1")
83 import "lib1.dart" as lib1;
84
85 void main() {
86 // loadLibrary is specially recognized by dart2js.
87 loadLibrary(const Deferred("lib1")).then((_) {
88 /* Assume lib1 has been loaded. */
89 print(new lib1.A());
90 });
91 }
92 ```
93
94 Since the language doesn't provide any guidance, DDC and dart2js could then impl ement their own restrictions (potentially using more annotations).
95
96 We have discarded this idea, because (among other reasons) the language front-en d is too much involved in deferred loading. For example, it needs to keep track which types are referenced through (deferred) prefixes. If the front-end needs t o be involved in such a high degree, then we should specify what exactly it need s to do.
97
98 Our plan is now to allow uses of deferred types even when the deferred libraries haven't been loaded yet. This means that sources of deferred libraries must be available during compilation of non-deferred functions:
99
100 ``` dart
101 /// lib1.dart
102 class A {}
103
104 /// lib2.dart
105 export "lib1.dart" show A;
106
107 /// main.dart
108 import "lib1.dart";
109 import "lib2.dart" deferred as def;
110
111 main() {
112 print(new A() is def.A); // Requires knowledge of `def.A`.
113 }
114 ```
115
116 While this change is clearly breaking (and we know of a few programs that create d the deferred libraries in the main library), in practice, deferred loading is mainly used as a deployment tool to cut down the size of the initial payload. At that time all sources are available.
117
118 The main tool that is affected by the new semantics is dart2js. We are tracking work on this feature in dart2js here: https://github.com/dart-lang/sdk/issues/29 903
119
120 Once dart2js has the resources to implement and experiment with the new semantic s we will provide updates.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698