@@ -7,23 +7,43 @@ description: You have questions about Dart, we have answers.
7
7
This page collects some of the top questions we've heard from the community
8
8
since Dart was open sourced.
9
9
10
-
11
10
## General
12
11
13
12
### Q. Is there a specification for Dart?
14
13
15
- Yes. Dart 1 has a formal specification owned by [ Ecma TC52] [ tc52 ] .
14
+ Yes. EMCA-408 covers the Dart Programming Language Specification.
15
+
16
+ Five versions have been published.
17
+ The latest in-progress version covers to Dart 2.13-dev.
18
+
19
+ | Edition | Published | Approved | Covers to version |
20
+ | ---------------| -------------------| ---------------| -------------------|
21
+ | [ 6th] [ 6th-ed ] | January 24, 2024 | | 2.13-dev |
22
+ | [ 5th] [ 5th-ed ] | April 9, 2021 | | 2.10 |
23
+ | [ 4th] [ 4th-ed ] | August 19, 2015 | December 2015 | 1.11 |
24
+ | [ 3rd] [ 3rd-ed ] | April 15, 2015 | June 2015 | 1.9 |
25
+ | [ 2nd] [ 2nd-ed ] | November 21, 2014 | December 2014 | 1.6 |
26
+ | [ 1st] [ 1st-ed ] | March 27, 2014 | June 2014 | 1.3 |
27
+
28
+ To learn more about the specification,
29
+ review the [ Dart language specification] ( /guides/language/spec ) page.
16
30
17
- Dart 2.x is currently being specified; the specification is available from the
18
- [ Dart language specification] ( /guides/language/spec ) page.
31
+ [ 1st-ed ] : https://ecma-international.org/wp-content/uploads/ECMA-408_1st_edition_june_2014.pdf
32
+ [ 2nd-ed ] : https://ecma-international.org/wp-content/uploads/ECMA-408_2nd_edition_december_2014.pdf
33
+ [ 3rd-ed ] : https://ecma-international.org/wp-content/uploads/ECMA-408_3rd_edition_june_2015.pdf
34
+ [ 4th-ed ] : https://ecma-international.org/wp-content/uploads/ECMA-408_4th_edition_december_2015.pdf
35
+ [ 5th-ed ] : https://dart.dev/guides/language/specifications/DartLangSpec-v2.10.pdf
36
+ [ 6th-ed ] : https://spec.dart.dev/DartLangSpecDraft.pdf
19
37
20
38
### Q. How are you taking input on changes to Dart?
21
39
22
- We listen to feedback and [ issues,] [ SDK issues ] and we review patches from contributors.
23
- A contributor with a good track record can become a committer to the repository.
24
- Google engineers will also be working in the public repository, making visible
25
- changes. The project is lucky to have received many external patches and has
26
- welcomed distributed committers.
40
+ The team listens to feedback, reads [ issues] [ SDK issues ] ,
41
+ and reviews patches from contributors.
42
+ A contributor with a good track record can be granted
43
+ write permission to the repository.
44
+ Google engineers also work in the public repository, making visible changes.
45
+ The project has received many external patches
46
+ and welcomes distributed committers.
27
47
28
48
---
29
49
@@ -32,70 +52,72 @@ welcomed distributed committers.
32
52
### Q. Isn't Dart a lot like Java?
33
53
34
54
Dart has some similarities with Java.
35
- Check out the code samples in the [ Introduction to Dart ] ( /language )
36
- for brief examples with familiar syntax .
55
+ To review brief examples with familiar syntax,
56
+ reviewed the code samples in the [ Introduction to Dart ] ( /language ) .
37
57
38
58
### Q. How does Dart relate to Go?
39
59
40
- Dart and Go are both language projects started at Google, but they
41
- are independent and have different goals. As a result,
42
- they make different choices, and the languages have very different
43
- natures, even while we all try to learn from each others' work.
60
+ Google started the Dart and Go language projects.
61
+ These independent projects have different goals.
62
+ As a result, they make different choices.
63
+ The languages have very different natures,
64
+ but team members learn from each others' work.
44
65
45
66
### Q. Why isn't Dart more like Haskell / Smalltalk / Python / Scala / other language?
46
67
47
- Various reasons, depending on the language being asked about .
68
+ Various reasons that depend on the comparison language .
48
69
49
- For languages that are quite different from JavaScript: it's important for Dart
50
- to compile to efficient JavaScript. Our experience in GWT is that if the source
51
- language is too different from JavaScript, it creates some cases where complex
52
- output code is needed to emulate the source language's behavior. This can cause
53
- performance to vary in ways that are not transparent to the programmer.
70
+ Languages differ from JavaScript
71
+ Dart must compile to efficient JavaScript.
72
+ Source languages that differ too much from JavaScript can generate complex
73
+ output code to emulate the source language's behavior.
74
+ This can cause performance to vary in non-obvious ways to the programmer.
54
75
55
- For languages that are compiled to native code: it's important that Dart
56
- compiles efficiently to machine code, and thus it shares a number of aspects
57
- with other compiled languages.
76
+ Languages that compile to native code
77
+ Dart prioritizes efficient compliation to machine code.
78
+ Therefore, it shares some aspects with other compiled languages.
58
79
59
- For languages that are "more dynamic" than Dart: Dart deliberately trades off
60
- some of this arbitrary runtime modification for the goal of better performance
61
- and more productive tools.
80
+ Languages that are considered "more dynamic" than Dart
81
+ Dart chooses to trade off some of this arbitrary runtime modification
82
+ to achieve better performance and more productive tools.
62
83
63
84
### Q. Why isn't Dart syntax more exciting?
64
85
65
- We did throw in some nice syntactic features such as ` this. ` constructor args
66
- and ` => ` for one-line functions, but we'd agree that Dart chooses
67
- familiarity over excitement. One team member's personal testimonial:
68
- "I wish it had a little more razzle dazzle but I can't deny that
69
- literally on my first day of writing Dart code, I was productive in it."
86
+ Some nice syntactic features exist, like the ` this. ` constructor args and ` => `
87
+ for one-line functions.
88
+ Dart chooses familiarity over excitement.
70
89
71
90
### Q. Does Dart have reflection capabilities?
72
91
73
- For servers and command-line scripts, we have reflection support from the
74
- [ mirrors API. ] ( {{site. dart-api}}/{{site.data.pkg-vers.SDK.channel}}/dart-mirrors )
75
- There is no support for mirrors when using Dart to write web or
76
- Flutter apps ( [ more info ] [ Flutter no mirrors ] ).
92
+ Servers and command-line scripts
93
+ Yes, Dart supports reflection from the [ mirrors API] [ dart-mirror ] .
94
+ Web or Flutter apps
95
+ No, Dart doesn't support write ( [ web or Flutter apps ] [ Flutter no mirrors ] ).
77
96
78
- ### Q. Can Dart add tuples, pattern matching, partial evaluation, optional semicolons, ...?
97
+ ### Q. Can Dart add tuples, pattern matching, ...?
79
98
80
- Future releases might be able to include ( some of) those features, although
81
- we can't include everything. Some features don't fit the basic nature of the
82
- language, and some don't play well with other features. Simplicity is the single
83
- most important gift we can give to future programmers.
99
+ Future releases might include some of those features.
100
+ Some features don't fit the nature of the language.
101
+ Some don't play well with other features.
102
+ Simplicity is the most important gift we can give to future programmers.
84
103
85
- Please look at the [ language funnel] [ language funnel ] and
86
- [ language issues list] [ language issues ] to see if your request is already there.
87
- If it is, let us know that you care and give it a thumbs up. Otherwise, go ahead
104
+ To check if your request has been filed,
105
+ review at the [ language funnel] [ language funnel ] and
106
+ [ language issues list] [ language issues ] .
107
+ If it is, give it a thumbs up.
108
+ Otherwise, go ahead
88
109
and add a new request issue (see the [ language evolution process] [ language process ]
89
- for details). Make a thoughtful argument for your feature. Sample code with and
110
+ for details).
111
+ Make a thoughtful argument for your feature. Sample code with and
90
112
without your feature is good evidence; a sizeable codebase that shows the need
91
113
is even better evidence.
92
114
93
115
Don't be surprised if the Dart language team says "no" by default.
94
116
It's far more painful to remove a language feature than to add it, so
95
117
Dart is likely to add the most obvious features first, and then revisit the next
96
- tier later. And there simply are more possible language features in the world
97
- that can fit into any single language without making a total hash of it. But
98
- we do very much appreciate suggestions and evidence. We hope you'll see our
118
+ tier later. And there simply are more possible language features in the world
119
+ that can fit into any single language without making a total hash of it. But
120
+ we do very much appreciate suggestions and evidence. We hope you'll see our
99
121
appreciation through careful design choices and fair communication about them.
100
122
101
123
---
@@ -104,12 +126,11 @@ appreciation through careful design choices and fair communication about them.
104
126
105
127
### Q. Is Dart a statically typed language?
106
128
107
- Yes, Dart 2 is statically typed. For more information,
108
- read about [ Dart's type system] [ ] .
129
+ Yes, Dart uses static typing. To learn more, review [ Dart's type system] [ ] .
109
130
110
- With its combination of static and runtime checks, Dart has a sound type system,
111
- which guarantees that an expression of one type cannot produce a value of another type.
112
- No surprises!
131
+ With its combination of static and runtime checks, Dart has a sound type system.
132
+ This guarantees that an expression of one type cannot produce a value
133
+ of another type.
113
134
114
135
Even with type-safe Dart, you can annotate any variable with ` dynamic ` if you need the flexibility of a dynamic language.
115
136
The ` dynamic ` type itself is static, but can contain any type at runtime.
@@ -139,37 +160,37 @@ Again, we're trying to be pragmatic, and we think the outcome is reasonable.
139
160
140
161
### Q. Does Dart support JSON?
141
162
142
- Yes. See the [ JSON] converters in the dart: convert library.
163
+ Yes. To learn more, review the [ JSON] converters in the dart: convert library.
143
164
144
165
### Q. Can Dart run on the server?
145
166
146
- Yes. See [ Dart on the Server] for details .
167
+ Yes. To learn more, review [ Dart on the Server] .
147
168
148
169
### Q. How do I use third party code, or share code?
149
170
150
- You can find many packages on the [ pub.dev site] [ pub ] a service for hosting
151
- packages of Dart code. Use the ` pub ` command to package your code and upload
152
- to the site.
171
+ Search for packages on the [ pub.dev site] [ pub ] ,
172
+ the package-hosting service for Dart and Flutter.
173
+ Use the [ ` pub ` command ] [ pub-cmd ] to package your code and upload to the site.
153
174
154
175
### Q. Do I need to use a particular editor or IDE to write Dart code?
155
176
156
- Nope . You can try out Dart code with [ DartPad,] [ DartPad ] and then use your favorite
177
+ No . You can try out Dart code with [ DartPad,] [ DartPad ] and then use your favorite
157
178
editor or IDE for development. Some full-featured IDEs such as IntelliJ IDEA,
158
179
WebStorm, and Visual Studio Code have Dart plugins. Open source Dart plugins
159
180
also exist for a number of editors. For more information, see the [ Dart tools] [ ] .
160
181
161
182
### Q. Can I build an Android app with Dart?
162
183
163
- Yes! You can build an Android app that also works on iOS from a single codebase
164
- using [ Flutter] [ Flutter ] , which is powered by the Dart platform.
184
+ Yes! You can build an Android app using the [ Flutter] [ Flutter ] framework
185
+ and the Dart language.
186
+ Any Flutter app you write will also work on iOS, the web, and desktop platforms.
165
187
166
188
### Q. What are some real-world production deployments of Dart?
167
189
168
- Google Ads, AdSense, AdMob, and the Google Assistant all use Dart.
190
+ Google Ads, AdSense, AdMob, and the Google Assistant use Dart.
169
191
A significant portion of Google's revenue flows through these apps.
170
192
Inside or outside of Google, [ every Flutter app] [ FlutterShowcase ] uses Dart.
171
193
172
-
173
194
[ dartisnotjava ] : http://programming.oreilly.com/2013/05/dart-is-not-the-language-you-think-it-is.html
174
195
[ pnacl ] : https://developer.chrome.com/native-client/overview
175
196
[ SDK issues ] : https://github.com/dart-lang/sdk/issues
@@ -243,7 +264,6 @@ long enough for runtime optimizations to be applied.
243
264
244
265
---
245
266
246
-
247
267
## Web: general
248
268
249
269
### Q. What browsers do you support as JavaScript compilation targets?
@@ -273,14 +293,14 @@ For setup details and a walkthrough, see [Debugging Dart Web Apps](/web/debuggin
273
293
You can use the low-level HTML API that core libraries define like ` dart:html ` , or you can choose from many [ web packages] ( /web/libraries#web-packages ) .
274
294
You can also use the [ Flutter framework] ( {{site.flutter}} ) , which has [ web support] ( {{site.flutter}}/web )
275
295
276
- ### Q. Will the Dart VM get into Chrome ?
296
+ ### Q. Will Chrome add the Dart VM?
277
297
278
298
[ No.] ( {{site.news}}/2015/03/dart-for-entire-web.html )
279
- Dart is designed to compile to JavaScript to run across the modern web.
299
+ Dart compiles to JavaScript to run across the modern web.
280
300
281
301
### Q. Is Dart single-threaded on the web?
282
302
283
- Dart is * mostly * single-threaded on the web,
303
+ Dart is _ mostly _ single-threaded on the web,
284
304
since web apps cannot use isolates.
285
305
To run code concurrently, web apps use [ web workers] [ ] instead.
286
306
Web workers lack the ease and efficiency of isolates,
@@ -296,20 +316,19 @@ To learn more, see
296
316
297
317
### Q. How does Dart code interoperate with JavaScript libraries?
298
318
299
- Although Dart and JavaScript are completely separate languages with
300
- separate VMs, they can interoperate. For more information, see
319
+ Dart and JavaScript exist as separate languages with separate VMs,
320
+ though they can interoperate. To learn more, review
301
321
[ JavaScript and TypeScript interop] ( /interop/js-interop ) .
302
322
303
- ### Q. I have a large JavaScript codebase. How can I migrate it to Dart?
323
+ ### Q. How can I migrate my JavaScript codebase to Dart?
304
324
305
- Try migrating one major feature at a time, and use the
306
- [ JavaScript interoperability library] [ package:js ]
307
- only when necessary.
325
+ Migrate one major feature at a time.
326
+ Use the [ JavaScript interoperability library] [ package:js ] when necessary.
308
327
309
328
### Q. How does Dart compare with using the Closure compiler on JavaScript?
310
329
311
- The idea of optional type annotations is similar.
312
- Dart's are nicer syntactically .
330
+ Optional type annotations work in a similar way .
331
+ Dart's syntax reads better .
313
332
314
333
Compare the following Closure compiler code:
315
334
@@ -341,18 +360,18 @@ String makeGreeting(String name) {
341
360
342
361
### Q. How does Dart compare with CoffeeScript?
343
362
344
- Both Dart and CoffeeScript are inspired by JavaScript, and both can be
345
- translated back to it. They make different choices, particularly in the flavor
346
- of their syntax. As a language we think it's fair to say that Dart differs
347
- semantically from JavaScript more than CoffeeScript does; that may result in a
348
- less line-for-line translation, but we believe Dart-generated JavaScript can
349
- have excellent size and speed.
363
+ JavaScript inspired both Dart and CoffeeScript and both translate to JavaScript.
364
+ They make different choices in the flavor of their syntax.
365
+ As a language,
366
+ Dart's semantics differ from JavaScript more than CoffeeScript's do.
367
+ This might result in a less line-for-line translation.
368
+ Dart-generated JavaScript can have excellent size and speed.
350
369
351
370
Dart introduces new semantics, while CoffeeScript retains the semantics
352
371
of JavaScript.
353
372
354
- If you like CoffeeScript for its more structured feel than raw JavaScript, you
355
- may like Dart's static type annotations.
373
+ If you like CoffeeScript for its more structured feel than raw JavaScript,
374
+ you may like Dart's static type annotations.
356
375
357
376
### Q. What does Google think of TypeScript?
358
377
@@ -383,7 +402,7 @@ a talk from Dart Developer Summit 2016.
383
402
384
403
### Q. Will any valid Dart code compile to JavaScript, or are there limitations?
385
404
386
- We intend for any valid Dart code to compile to JavaScript. Of course,
405
+ We intend for any valid Dart code to compile to JavaScript. Of course,
387
406
some libraries only run on the server or in Flutter.
388
407
For example, the ` dart:io ` library
389
408
provides access to operating system files and directories with APIs not
@@ -461,10 +480,12 @@ One exception exists: the production JavaScript compiler does not support
461
480
64-bit integers: ` Int64List ` or ` Uint64List ` . Compiling Dart code with
462
481
either of those lists results in a runtime exception.
463
482
464
-
465
483
[ ppwsize ] : https://work.j832.com/2012/11/excited-to-see-dart2js-minified-output.html
466
484
[ package:js ] : {{site.pub-pkg}}/js
467
485
[ dart compile ] : /tools/dart-compile
468
486
[ dart analyze ] : /tools/dart-analyze
469
487
[ typescript ] : {{site.news}}/2012/10/the-dart-team-welcomes-typescript.html
470
488
[ webdev ] : /tools/webdev
489
+
490
+ [ dart-mirror ] : {{site.dart-api}}/{{site.data.pkg-vers.SDK.channel}}/dart-mirrors
491
+ [ pub-cmd ] : https://dart.dev/tools/pub/cmd
0 commit comments