- Usage and tools
- Native execution
- Web execution
- Q. Is Dart single-threaded on the web?
This page collects some of the top questions from the community.
Q. Is there a specification for Dart?#
Yes. EMCA-408 covers the Dart Programming Language Specification.
Five versions have been published. The latest in-progress version covers to Dart 2.13-dev.
|Covers to version
|January 24, 2024
|April 9, 2021
|August 19, 2015
|April 15, 2015
|November 21, 2014
|March 27, 2014
To learn more about the specification, review the Dart language specification page.
Q. How are you taking input on changes to Dart?#
The team listens to feedback, reads issues, and reviews patches from contributors. A contributor with a good track record can be granted write permission to the repository. Google engineers also work in the public repository, making visible changes. The project has received many external patches and welcomes distributed committers.
Q. Isn't Dart a lot like Java?#
Dart has some similarities with Java. To review brief examples with familiar syntax, reviewed the code samples in the Introduction to Dart.
Q. How does Dart relate to Go?#
Google started the Dart and Go language projects. These independent projects have different goals. As a result, they make different choices. The languages have very different natures, but team members learn from each others' work.
Q. Why isn't Dart more like Haskell / Smalltalk / Python / Scala / other language?#
Various reasons that depend on the comparison language.
- Languages that compile to native code
- Dart prioritizes efficient compliation to machine code. Therefore, it shares some aspects with other compiled languages.
- Languages that are considered "more dynamic" than Dart
- Dart chooses to trade off some of this arbitrary runtime modification to achieve better performance and more productive tools.
Q. Why isn't Dart syntax more exciting?#
Some nice syntactic features exist, like the
this. constructor args and
=> for one-line functions. Dart chooses familiarity over excitement.
Q. Does Dart have reflection capabilities?#
- Servers and command-line scripts
- Yes, Dart supports reflection from the mirrors API.
- Web or Flutter apps
- No, Dart doesn't support write to web or Flutter apps.
Q. Can Dart add tuples, partial evaluation, ...?#
Future releases might include a feature you want. Some features don't fit the nature of the language. Some don't play well with other features. Simplicity is the most important gift to give to future programmers.
If an issue exists, add your thumbs up.
If an issue doesn't exist, request a new issue.
Make a thoughtful argument for your feature. Add evidence to your argument. Include sample code with and without your feature or a sizeable codebase.
To learn more, consult the language evolution process.
Don't be surprised if the Dart language team turns down your request. Removing a language feature inflicts more pain than adding one. The Dart language team adds the most obvious features first, and revisits the next tier later.
The community will request more features than any single language can meet without making a total hash of it. The Dart language team does appreciate suggestions and evidence. This appreciation should become apparent through careful design choices and fair communication about them.
Q. Does Dart use static typing?#
Yes, Dart uses static typing. To learn more, consult Dart's type system.
Combining static and runtime checks, Dart has a sound type system. This guarantees that an expression of one type cannot produce a value of another type.
if you need the flexibility of a dynamic typing, you can annotate any variable with
dynamic type is static, but can contain any type at runtime. That removes many benefits of a type-safe language from that variable.
Q. Why are generics covariant?#
Covariant generics fit a common intuition that programmers have, and very often this intuition is correct, such as in the common "read-only" use of a generic. Although this intuition isn't always correct, Dart is erring on the side of convenience by having covariant generics.
The only other reasonable default variance would be invariance. While having only invariant generics would definitely prevent more errors, it would also prevent a lot of valid programs or require conversion every time you have a list of "apples", and someone just wants "fruits".
We are familiar with a variety of ways that languages try to mark or infer variance. We feel that variance inference systems add too much complexity for their benefit in Dart.
Again, we're trying to be pragmatic, and we think the outcome is reasonable.
Usage and tools#
Q. Does Dart support JSON?#
Q. Can Dart run on the server?#
Yes. To learn more, consult Dart on the Server.
Q. How do I use third party code, or share code?#
Q. Do I need to use a particular editor or IDE to write Dart code?#
No. You can try out Dart code with DartPad, and then use your favorite editor or IDE for development. Some full-featured IDEs such as IntelliJ IDEA, WebStorm, and Visual Studio Code have Dart plugins. Open source Dart plugins also exist for a number of editors. For more information, see the Dart tools.
Q. Can I build an Android app with Dart?#
Yes! You can build an Android app using the Flutter framework and the Dart language. Any Flutter app you write will also work on iOS, the web, and desktop platforms.
Q. What are some real-world production deployments of Dart?#
Google Ads, AdSense, AdMob, and the Google Assistant use Dart. A significant portion of Google's revenue flows through these apps. Inside or outside of Google, every Flutter app uses Dart.
Q. Is Dart single-threaded?#
No. On native targets, Dart's isolate API can start multiple execution threads when needed. The Dart VM uses multiple CPU cores to run those threads at the same time.
Dart's concurrency architecture abstracts the complex, error-prone code of typical shared-memory threading. This might explain the misconception that Dart is single-threaded.
Concurrency works differently in Dart web apps. To learn more, consult Is Dart single-threaded on the web?
Q. Can I compile Dart code to native code?#
Yes. When compiling apps that target devices like desktops or mobile, Dart Native includes both a Dart VM with a just-in-time (JIT) compiler and an ahead-of-time (AOT) compiler to produce native code.
The Flutter framework uses Dart's native compilation capability to produce fast native apps.
Q. Can I compile a Dart program for running in a terminal?#
Yes. Dart programs can be compiled to native code for running in a macOS Terminal, Windows command prompt, or a Linux shell.
Consult the dart compile documentation.
Q. Which is faster: AOT- or JIT-compiled code?#
It depends. How Dart compiles code produces apps with different performance characteristics.
AOT-compiled code starts fast with consistent runtime performance, with no latency during early runs.
JIT-compiled code starts slower, but reaches peak performance after it runs long enough to apply runtime optimizations.
The production web compiler supports the last two major releases of the following browsers:
- Google Chrome
- Microsoft Edge
- Apple Safari
Q. Is Dart single-threaded on the web?#
Somewhat. Dart web apps can't use isolates. To achieve code concurrency, web apps use web workers. Web workers lack the ease and efficiency of isolates, and have different capabilities and restrictions. To learn more, consult Concurrency on the web.
dart:io library. It provides access to operating system files and directories with APIs not available to the browser.
Both ways use the
webdev command. The
Float32List becoming a
Uint64List. Compiling Dart code with either of those lists results in a runtime exception.