Skip to main content

Dart

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/dart

In short

Dart is a statically typed, garbage-collected language from Google that compiles to native code and JavaScript, best known as the language of Flutter apps.

What is Dart?

Dart is a general-purpose, object-oriented programming language developed by Google and first released in 2011. It was originally pitched as an alternative to JavaScript in the browser, but today it is best known as the language behind Flutter, an open-source toolkit for building mobile, web, desktop and embedded apps from a single codebase. Dart 3, released in 2023, made sound null safety mandatory and added records and pattern matching.

Dart is statically typed with type inference, and its null safety is sound, meaning a variable of type String can never hold null; only String? can. The language has two compilation modes. During development, a just-in-time compiler enables hot reload, which updates a running app almost instantly without losing its state, and for release builds an ahead-of-time compiler produces fast native machine code, or JavaScript and WebAssembly for the web. Asynchronous code uses Future, Stream and async/await, and concurrency uses isolates, which work like threads that don't share memory.

Dart is used mainly for cross-platform user interfaces with Flutter, along with command-line tools and some server-side code. Its C-style syntax, classes and curly braces feel familiar to anyone who knows Java, C# or JavaScript, so it is usually quick to pick up.

Dart is often compared with TypeScript, since both add static types to a JavaScript-like style of programming. TypeScript is a typed layer on top of JavaScript and always compiles to JavaScript, while Dart is an independent language with its own runtime and libraries that can compile to native code as well as to JavaScript. Dart's types are also enforced while the program runs, whereas TypeScript's types are erased after compilation.

Key takeaways

  • Dart is an object-oriented, statically typed language with sound null safety.
  • It compiles ahead of time to native code, and to JavaScript or WebAssembly for the web.
  • JIT compilation during development enables fast hot reload.
  • It is best known as the language of the Flutter UI toolkit.
  • Isolates provide concurrency without shared memory.

Example

Null safety and async/await in Dartdart
class User {
  final String name;
  final String? email; // the ? means this may be null
  User(this.name, [this.email]);
}

Future<void> main() async {
  final users = [User('Ada', 'ada@example.com'), User('Grace')];
  for (final user in users) {
    await Future.delayed(const Duration(milliseconds: 100));
    print('${user.name}: ${user.email ?? "no email"}');
  }
}

Readers ask

Is Dart only used for Flutter?

Flutter is by far its biggest use, but Dart also runs command-line tools, server applications and web apps compiled to JavaScript or WebAssembly.

Is Dart similar to JavaScript?

The syntax looks familiar to JavaScript developers, but Dart is statically typed with sound null safety and has its own runtime and standard library. It can compile to JavaScript, but it is a separate language.

Is Dart compiled or interpreted?

Dart is compiled in both stages. It uses a just-in-time compiler during development to support hot reload, and ahead-of-time compilation to native machine code or JavaScript for production builds.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings