Theory
The committee's second phone
FestConnect Mobile works: on Android. Then the fest secretary arrives with her iPhone, and your Java + XML app means nothing to it. Building the SAME app twice, in 2 languages, for 2 stores, is how small teams die.
This is the ridge the subject now crosses: Units 3 to 5 rebuild the app in Flutter, one codebase for both phones. But Flutter speaks one language, and it is not Java. Meet Dart: 2 units of your future, starting with why it exists.
Theory
Dart, formally
Dart is Google's open-source, client-optimised language (2011): designed for building fast user interfaces on any screen.
Its identity card:
- object-oriented: everything is an object, numbers and even functions included
- C-style syntax: braces, semicolons: a Java reader is 80% at home on sight
- statically typed with inference: declare
int seats = 350;or letvardeduce it: either way the type is fixed and checked - null safety: modern Dart makes may-be-null part of the type system
- the language of Flutter
Practical
First Dart: main, var, and interpolation
void main() { // execution starts here, like Java
var fest = 'TechnoUtsav'; // var INFERS String, then fixes it
int seats = 350;
int booked = 310;
// String interpolation: $variable inside the string
print('$fest: ${seats - booked} seats left');
// Output: TechnoUtsav: 40 seats left
}
Theory
The double life: JIT and AOT
Dart's defining engineering trick is compiling 2 different ways for 2 different moments:
- While developing: JIT (just-in-time). Code compiles incrementally as it runs, so a saved change appears in the running app in under a second: Flutter's celebrated hot reload
- When shipping: AOT (ahead-of-time). The release build compiles fully to native ARM machine code: no interpreter at the party, full phone speed
Java gave you javac-then-JVM; Dart says: interpretive agility in the lab, native muscle in the store. A third compiler, dart2js, targets browsers (next lesson).
Theory
Installation: two doors
- Standalone Dart SDK: from dart.dev, for pure Dart work: command-line programs, servers
- Bundled with Flutter (the usual route for this subject): installing the Flutter SDK (Unit 3) brings Dart along automatically: one download, both tools
Either way, verification is one command in a terminal:
dart --version
And for today, even installation is optional: DartPad runs Dart in the browser, zero setup: the whole next lesson.
Quiz
Why does this subject switch from Java to Dart at all?
- Dart programs run faster than Java on Android
- Flutter, the one-codebase-for-Android-and-iOS toolkit of Units 3 to 5, is built around Dart
- Google has deprecated Java for all Android development
- Dart is easier, having no types to declare
Show the answer
Flutter, the one-codebase-for-Android-and-iOS toolkit of Units 3 to 5, is built around Dart
The switch is strategic, not stylistic: Flutter is the destination (one app, both phones: the secretary's iPhone problem), and Flutter's language is Dart, chosen for the JIT/AOT double life that makes hot reload AND native releases possible. Option A overclaims: both are fast; speed is not the motive. Option C is false: Java/Kotlin Android development is alive and well: Flutter is an alternative, not a replacement. Option D is doubly wrong: Dart IS typed: var infers a type, it does not abandon one.
Think first
Why not one compiler like Java?
Java uses one pipeline (javac to bytecode to JVM) for both development and release. Dart maintains TWO (JIT and AOT). Reason out what each moment of an app's life demands, and why one pipeline struggles to serve both, then tap.
Show the answer
Development wants fast iteration: change, see, change: JIT compiles just what is needed, live, enabling hot reload; but JIT machinery must ship inside the running app and warms up over time. Release wants raw speed and small size: AOT pre-compiles everything to native ARM: instant startup, no compiler on the phone: but rebuilding fully per change would make development crawl. One pipeline optimises one moment; Dart's 2 pipelines each serve their own. Exam line: JIT for hot-reload development, AOT to native code for release.
Watch out
First-contact confusions
var is not "no type": var seats = 350 makes seats an int forever; assigning 'full' later is a compile error. The truly untyped opt-out is dynamic, used sparingly.
Dart is not "Java for iOS": it is its own language; the syntax similarity is a welcome mat, not an identity.
print interpolation beats concatenation: '$fest: $seats' is the Dart idiom; writing fest + ": " + seats.toString() marks you as a tourist.
Theory
Read Dart with Java eyes, note the accents
Your BCA403 investment transfers almost whole: main(), braces, semicolons, if/for/while, classes. Keep a small accent list as you go: single quotes are idiomatic for strings, $interpolation replaces concatenation, var infers, and print() needs no System.out. Next lesson you write and run Dart with ZERO installation: DartPad in the browser, plus the compiler that turns Dart into JavaScript.
Summary
Key takeaways
- Dart: Google's client-optimised, object-oriented language with C-style syntax and null safety.
- Statically typed with inference: var deduces the type once and fixes it; dynamic is the rare opt-out.
- Dual compilation: JIT while developing (hot reload), AOT to native ARM for release.
- dart2js additionally compiles Dart to JavaScript for browsers.
- Dart is Flutter's language: one codebase for Android and iOS: the reason for the switch.
- Install standalone from dart.dev or bundled with Flutter; verify with dart --version.
- Memory hook: JIT in the lab, AOT in the store, one language on every phone.