Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 61 ยท Getting Started

What Is Dart?

Find out what Dart is, who made it, where it runs (Flutter, servers, command-line tools, the web), how JIT and AOT compilation work, and how this tutorial runs its examples.

Dart is a general-purpose programming language created at Google. It is statically typed, garbage collected and object-oriented, and its syntax will feel familiar if you have written Java, C#, JavaScript or TypeScript. Most people meet Dart because they want to build apps with Flutter, but the language is useful on its own: you can write command-line tools, web servers, scripts and libraries with it.

This first lesson answers the questions every newcomer has. Where did Dart come from? What can you build with it? Why does it have two different ways of running code? And how will this tutorial teach a language that your browser cannot run directly? You will not need to install anything to follow along.

A short history

Dart was announced by Google in 2011. The first goal was ambitious: give web developers a more structured alternative to JavaScript, with a virtual machine inside the browser. That plan never took off, and for a few years Dart was a niche language.

The turning point came with two decisions. In 2018, Dart 2 introduced a fully sound type system and moved the language toward being a great fit for user interfaces. Around the same time Google chose Dart as the language of Flutter, a toolkit for building apps for phones, the web and desktops from a single codebase. Flutter's success made Dart one of the fastest-growing languages of its time.

Two more milestones shape the language you will learn here:

  • Sound null safety arrived in Dart 2.12 (2021). A variable can only hold null if its type says so, which removes a whole family of crashes.
  • Dart 3 (2023) made null safety mandatory and added records, patterns and class modifiers such as sealed. This tutorial teaches Dart 3 and later.

Dart keeps evolving. Syntax shown in this tutorial is current for Dart 3, and lessons mention the version when a feature is recent. If you read older articles, treat code that uses new, List<int>() or non-null-safe variables as outdated.

Where Dart runs

One language, several places to run it:

  • Mobile and desktop apps. Flutter compiles Dart to native machine code for Android, iOS, Windows, macOS and Linux.
  • The web. Dart can be compiled to JavaScript or to WebAssembly, so the same code can run in a browser.
  • Servers. Dart programs run on the server with the Dart VM or as native executables. Packages such as shelf help you build HTTP services.
  • Command-line tools and scripts. You can compile a tool to a single executable with no Dart installation required on the target machine.
flowchart LR
    A["Your Dart code"] --> B["Dart VM<br/>(JIT)"]
    A --> C["Native machine code<br/>(AOT)"]
    A --> D["JavaScript"]
    A --> E["WebAssembly"]
    B --> F["Development: hot reload,<br/>fast edit-run cycle"]
    C --> G["Release builds: fast startup,<br/>fast execution"]
    D --> H["Browsers"]
    E --> H

One source language, several compilation targets, chosen by what you are doing.

JIT and AOT in plain words

Most languages choose one way to run code. Dart deliberately offers two, because developers need different things at different times.

JIT (just-in-time) compilation happens while the program runs. The Dart VM reads your code, compiles it on the fly and can swap in new code without restarting. This is what makes Flutter's famous hot reload possible: you change a line, save, and the running app updates in a fraction of a second while keeping its state.

AOT (ahead-of-time) compilation happens before the program ever runs. The compiler turns your code into machine code once, and the result starts quickly and runs predictably. Release builds of Flutter apps and compiled command-line tools use AOT.

You rarely have to think about which one is active. When you run dart run, you get the VM. When you run dart compile exe, you get a native executable. The language itself is the same in both.

What makes Dart pleasant

A few design choices come up again and again:

  • Types without noise. Dart is statically typed, but type inference means you usually do not have to write the type yourself.
  • Null safety built in. The compiler tells you where a value might be missing, before your users find out.
  • Everything is an object. Numbers, functions and even null are objects with methods.
  • Asynchronous code is a first-class feature. async, await, Future and Stream are part of the language.
  • One formatter, one style. dart format produces a single standard layout, so projects look alike.

How this tutorial runs examples

Your browser can run HTML, CSS and JavaScript, and this site can also run Python, SQL and several other languages. The Dart SDK is not installed on the site's code runner, so real Dart code in this tutorial is read-only. You will see it in code blocks like this one:

DART
void main() {
  var language = 'Dart';
  print('Hello from $language!');
}

To let you experiment anyway, many lessons pair the Dart code with a runnable stand-in written in TypeScript. TypeScript is close enough to Dart in spirit (static types, classes, async/await) that the same idea can be shown live. Stand-ins are always labelled, and they are never presented as real Dart output. When the exact text that Dart prints matters, the lesson shows it in a separate output block.

Here is the first stand-in. It mimics the shape of a Dart program: a main function that is called to start everything.

TypeScript A Dart-shaped program in TypeScript (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

When you want to run real Dart yourself, DartPad in your browser is the quickest route, and the next lesson shows how to install the SDK for local work.

Static types, with a safety net

The headline feature is the type system. In Dart the compiler knows the type of every variable and expression. Mixing them up is an error you see in your editor, not a crash that your users see. Here is the idea as a stand-in; TypeScript is told to be strict, so it refuses the bad line just as Dart would refuse its equivalent.

TypeScript Types are checked before the program runs (fails on purpose)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

TEXT
main.ts(2,7): error TS2322: Type 'string' is not assignable to type 'number'.

In Dart, the matching mistake produces an error along the lines of "A value of type 'String' can't be assigned to a variable of type 'int'." The program never starts, which is exactly what you want.

Your learning path

This tutorial moves from small to large. You will start with variables, numbers and strings, then control flow and functions. Collections and generics come next, followed by Dart's full object model: classes, mixins, enums and extension methods. After that you will handle errors, use libraries, write asynchronous code with futures and streams, and finish with real-world topics, five projects and practice sets.

You do not need to know Flutter to follow along. Everything here is plain Dart, which is also the best foundation for learning Flutter later.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which statement about Dart is correct?

    Dart is statically typed and has several run and compile targets, including the VM, native machine code, JavaScript and WebAssembly. Flutter is only one of the places it is used.
  2. 2. Which compilation mode makes hot reload possible during development?

    JIT compilation happens while the program runs, so the VM can swap in changed code without restarting. AOT compiles everything ahead of time for release builds.
  3. 3. What does sound null safety guarantee?

    Under null safety, a type such as String cannot hold null, while String? can. The compiler checks this, which prevents a large class of runtime errors.
  4. 4. Why are Dart examples in this tutorial read-only, with TypeScript stand-ins to run?

    Real Dart code is shown in read-only blocks because the runner does not include Dart. Stand-ins in TypeScript let you experiment with the same ideas live.

Summary

  • Dart is a statically typed, garbage-collected, object-oriented language from Google, used for Flutter apps, servers, command-line tools and the web.
  • It offers JIT compilation for fast development (hot reload) and AOT compilation for fast, predictable release builds, plus JavaScript and WebAssembly output.
  • Dart 2 introduced a sound type system; Dart 2.12 added null safety; Dart 3 added records, patterns and class modifiers.
  • Real Dart code in this tutorial is read-only; runnable TypeScript stand-ins illustrate the same ideas.

Next, set up your own tools in Installing the Dart SDK and Tooling.