DART overview, concept, features and installation

Dart એ Google ની client-optimised language છે જેની double life છે: તમે build કરો ત્યારે instant hot reload માટે JIT-compiled, અને તમે ship કરો ત્યારે native code માટે AOT-compiled: કારણ કે Flutter એ તેને chose કર્યું.

10 min read · 10 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

committee નો second phone

FestConnect Mobile work કરે છે: Android પર. પછી fest secretary તેના iPhone સાથે arrive થાય છે, અને તમારું Java + XML app તેને કંઈ પણ means કરતું નથી. SAME app ને twice build કરવું, 2 languages માં, 2 stores માટે, એ રીતે small teams die થાય છે.

આ એ ridge છે જે subject હવે cross કરે છે: Units 3 થી 5 app ને Flutter માં rebuild કરે છે, બંને phones માટે એક codebase. પણ Flutter એ એક language બોલે છે, અને તે Java નથી. meet કરો Dart: તમારા future ના 2 units, starting કે શા માટે તે exists કરે છે.

Theory

Dart, formally

Dart એ Google ની open-source, client-optimised language છે (2011): designed કોઈ પણ screen પર fast user interfaces ને build કરવા માટે.

તેનો identity card:

  • object-oriented: બધું object છે, numbers અને even functions included
  • C-style syntax: braces, semicolons: Java reader એ 80% at home છે sight પર
  • statically typed with inference: declare int seats = 350; અથવા var ને deduce કરવા દો: બંને રીતે type fixed છે અને checked છે
  • null safety: modern Dart એ may-be-null ને type system નો ભાગ બનાવે છે
  • Flutter ની language

Practical

First Dart: main, var, અને interpolation

void main() {                       // execution અહીં start થાય છે, જેમ Java
  var fest = 'TechnoUtsav';         // var String ને INFERS કરે છે, પછી તેને fix કરે છે
  int seats = 350;
  int booked = 310;

  // String interpolation: string ની અંદર $variable
  print('$fest: ${seats - booked} seats left');
  // Output: TechnoUtsav: 40 seats left
}

Theory

double life: JIT અને AOT

Dart નો defining engineering trick એ 2 different ways compile કરવાનું છે 2 different moments માટે:

  • While developing: JIT (just-in-time). Code incrementally compile થાય છે જેમ તે runs કરે છે, તેથી saved change running app માં એક second ની નીચે appear થાય છે: Flutter નું celebrated hot reload
  • When shipping: AOT (ahead-of-time). release build fully native ARM machine code માં compile થાય છે: પાર્ટીમાં કોઈ interpreter નહીં, full phone speed

Java એ તમને javac-then-JVM આપ્યું; Dart કહે છે: lab માં interpretive agility, store માં native muscle. ત્રીજો compiler, dart2js, browsers ને target કરે છે (next lesson).

Theory

Installation: બે doors

  • Standalone Dart SDK: dart.dev થી, pure Dart work માટે: command-line programs, servers
  • Bundled with Flutter (આ subject માટે usual route): Flutter SDK ને install કરવું (Unit 3) Dart ને automatically સાથે લાવે છે: એક download, બંને tools

બંને રીતે, verification એ terminal માં એક command છે:

dart --version

અને today માટે, even installation optional છે: DartPad Dart ને browser માં runs કરે છે, zero setup: આખું next lesson.

Quiz

શા માટે આ subject Java થી Dart માં switch થાય છે at all?

  1. Dart programs Java થી faster ચાલે છે Android પર
  2. Flutter, એક-codebase-for-Android-and-iOS toolkit Units 3 થી 5 નું, Dart ની આસપાસ built છે
  3. Google એ all Android development માટે Java ને deprecated કર્યું છે
  4. Dart easier છે, declare કરવા માટે કોઈ types નથી
Show the answer

Flutter, એક-codebase-for-Android-and-iOS toolkit Units 3 થી 5 નું, Dart ની આસપાસ built છે

switch એ strategic છે, stylistic નહીં: Flutter એ destination છે (એક app, બંને phones: secretary નો iPhone problem), અને Flutter ની language Dart છે, chosen JIT/AOT double life માટે જે hot reload AND native releases ને possible બનાવે છે. Option A overclaim કરે છે: બંને fast છે; speed motive નથી. Option C false છે: Java/Kotlin Android development alive અને well છે: Flutter એ alternative છે, replacement નહીં. Option D doubly wrong છે: Dart IS typed છે: var type ને infer કરે છે, તેને abandon નથી કરતું.

Think first

શા માટે Java જેમ એક compiler નહીં?

Java એ development અને release બંને માટે એક pipeline (javac થી bytecode થી JVM) ને use કરે છે. Dart બે (JIT અને AOT) ને maintain કરે છે. reason out કરો કે app ના life નો દરેક moment શું demand કરે છે, અને શા માટે એક pipeline બંને ને serve કરવા માટે struggles કરે છે, પછી tap.

Show the answer

Development એ fast iteration ને wants કરે છે: change, see, change: JIT જે needed હોય તેને live compile કરે છે, hot reload ને enabling કરે છે; પણ JIT machinery ને running app ની અંદર ship કરવું પડે છે અને time સાથે warms up થાય છે. Release એ raw speed અને small size ને wants કરે છે: AOT બધું pre-compile કરે છે native ARM માં: instant startup, phone પર કોઈ compiler નહીં: પણ બદલાવ દીઠ fully rebuild કરવું development ને crawl કરાવે છે. એક pipeline એક moment ને optimise કરે છે; Dart ના 2 pipelines દરેક તેના own ને serve કરે છે. Exam line: hot-reload development માટે JIT, release માટે native code માટે AOT.

Watch out

First-contact confusions

var એ "no type" નથી: var seats = 350 seats ને int બનાવે છે forever; પછી 'full' ને assign કરવું compile error છે. truly untyped opt-out એ dynamic છે, sparingly used.

Dart એ "Java for iOS" નથી: તે its own language છે; syntax similarity એ welcome mat છે, identity નહીં.

print interpolation beats concatenation: '$fest: $seats' એ Dart idiom છે; fest + ": " + seats.toString() લખવું તમને tourist તરીકે mark કરે છે.

Theory

Dart ને Java eyes થી read કરો, accents ને note કરો

તમારું BCA403 investment almost whole transfer થાય છે: main(), braces, semicolons, if/for/while, classes. small accent list ને keep કરો જેમ તમે જાઓ: single quotes strings માટે idiomatic છે, $interpolation concatenation ને replace કરે છે, var infer કરે છે, અને print() ને કોઈ System.out ની જરૂર નથી. next lesson તમે Dart ને write અને run કરો છો ZERO installation સાથે: browser માં DartPad, plus compiler જે Dart ને JavaScript માં turn કરે છે.

Summary

Key takeaways

  • Dart: Google ની client-optimised, object-oriented language C-style syntax અને null safety સાથે.
  • Statically typed with inference: var type ને once deduce કરે છે અને fix કરે છે; dynamic એ rare opt-out છે.
  • Dual compilation: while developing માટે JIT (hot reload), release માટે native ARM માટે AOT.
  • dart2js additionally Dart ને browsers માટે JavaScript માં compile કરે છે.
  • Dart એ Flutter ની language છે: Android અને iOS માટે એક codebase: switch નું reason.
  • dart.dev થી standalone install કરો અથવા Flutter સાથે bundled; dart --version સાથે verify કરો.
  • Memory hook: lab માં JIT, store માં AOT, દરેક phone પર એક language.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Working with DART

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

DART overview, concept, features and installation · Mobile Application Development - 2 (option B) · Gri-Learn