Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a snapshot in Dart or compilation (not Flutter)?

I'm reading about dart compile, and it has a few option: Executable, AOT snapshot, JIT snapshot and Kernel snapshot and JavaScript.

What is the difference between an executable and a snapshot? Is it purely the fact executables contain the Dart runtime/ VM, whereas a snapshot doesn't. Why is it called a snapshot?

enter image description here


2 highly related question (which I found after posting this question) are:

  • What is the difference between Dart's snapshots and Java bytecode?
  • What is the snapshot concept in dart?

This question is different to Dart: Snapshots vs AOT, since is asking the difference between a Snapshot and AOT, but actually AOT files are snapshots. It also primarily asked about the differences between Snapshot options (AOT, Kernel, JIT).

like image 510
Ben Butterworth Avatar asked Sep 20 '25 21:09

Ben Butterworth


1 Answers

An executable (created by dart compile exe) is a combination of an AOT snapshot, and the Dart runtime. The Dart runtime is needed to run any Dart code, as it performs critical tasks like managing memory (including garbage collection) and performing runtime type checks.

The three kinds of snapshots (AOT, kernel, and JIT) all contain just the compiled source code. They all need a runtime to be run (typically you just use dart run <snapshot>).

The snapshots should perhaps have been named differently. Would 'module' have been easier to understand?

like image 64
Michael Thomsen Avatar answered Sep 23 '25 11:09

Michael Thomsen