Language 9 of 10 · Topic 0.1

Dart Program Structure, Sound Null Safety & JIT/AOT Compilers

1Concept

Dart programs begin at void main(). Dart uses Sound Null Safety: types are non-nullable by default (String cannot be null; String? can). Dart compiles with JIT (Hot Reload in Dev) and AOT (Machine code in Release).

2Architecture Diagram

Development ──► JIT Compiler (Sub-Second Hot Reload)
Production  ──► AOT Compiler (ARM/x64 Native Fast Machine Code)

3Code Example

Stage 0 Language Foundations
void main() {
  print('=== Dart 3 Sound Null Safety Runtime ===');
  String nonNullable = 'Flutter Engine';
  String? nullableValue = null;

  print('Non-nullable: $nonNullable');
  print('Nullable: ${nullableValue ?? "Default Fallback"}');
}

4Expected Output

=== Dart 3 Sound Null Safety Runtime ===
Non-nullable: Flutter Engine
Nullable: Default Fallback

5Key Takeaways

  • Sound null safety guarantees non-nullable variables NEVER contain null at runtime.
  • AOT compilation provides 60/120 FPS UI performance with zero startup lag.
  • String interpolation uses $var and ${expression}.