Dart Tutorial
Dart is an open-source, structured programming language developed by Google. It is a high-level programming language that emerged in 2011, but its stable version emerged in 2017. It is largely used to build web and mobile applications.
The language syntax of Dart language is very similar to that of Java, C#, and JavaScript. The primary goal for creating Dart language was that the language seemed familiar to the developers. It is a class-based, optionally typed and single-threaded language with closure and lexical scope. It supports some additional features such as interfaces, mixins, abstract classes, generics, and type inference.
Dart is more than just a language; it comprises of an entire ecosystem that helps in improving the workflow while building complex web applications.
Dart Ecosystem
It is widely used to develop mobile applications, modern web apps, desktop applications, and the Internet of Things (IoT) using the flutter framework. The best example of Dart applications is Gmail.
There are various ways of running an application created in Dart, either by using a browser that supports Dart like, Dartium browser or compiling the Dart code to JavaScript using the Dart2js tool. It can also be run on the command line, hosted in a Dart Virtual Machine. This feature allows the application's client and server parts to be written in the same language. There are two compilation techniques:
- Ahead of Time (AOT): Code compilation takes place at the build time. In this technique, the Dart code is converted into JavaScript code using the dar2js compiler, making it run on all modern web-browser.
- Just-In-Time (JIT): In this technique, only necessary byte code is converted into machine code.
Online compiler Dart Pad can also be used to run Dart code. Some IDEs which support Dart language are WebStorm, Intellij, Eclipse, Visual Studio Code, Android Studio, etc.
History of Dart
Dart emerged at the GOTO conference in Aarhus, Denmark, for the very first time in October 2012 as a project by Lars Bak and Kasper Lund. Later, on November 14, 2013, Dart 1.0 was released.
In July 2014, Ecma International approved the first edition of Dart language at its 107th General Assembly and the second edition in December 2014.
Dart 1.9, released in 2015, focussed on compiling Dart to JavaScript. And, then in August 2018, Dart 2.0 was released with some change in language and a sound type system.
Dart2native, a new extension, was introduced in a new version of Dart, Dart 2.6, which extends native compilation to various operating systems and desktop platforms. With this extension, it became possible to compose a Dart program into self-contained executables. This newer extension was integrated with Flutter to use the compiler for backend services.
Characteristics
- Dart is a dynamic object-oriented programming language supporting all the features of object-oriented paradigms.
- It is a platform independent language that supports all the operating systems such as Windows, Mac, Linux, etc.
- It is a BSD licensed and Ecma standardized language.
- Every number, Boolean function, etc., are treated as an object in Dart. All such objects inherit from the Object class.
- Dart tools also report some warnings and errors, if any. Warnings indicate problems in the program but don’t interrupt the code’s execution, whereas errors don’t let the program be executed.
HIGH-LEVEL PROGRAMMING FEATURES COMPARISON
Feature | Dart | Java | JavaScript |
Type System | Dart supports dynamic type system, but is optional. | Java supports strong and static type system. | JavaScript supports weak but dynamic type system. |
First-class functions | It supports first class functions. | It doesn’t support first class functions but can be simulated with anonymous functions. | It supports first class functions. |
Closures | Closure feature is supported. | Closure is supported using anonymous classes. | Closure feature is supported. |
Classes | There are classes that follow single inheritance. | There are classes that follow single inheritance. | There are classes with prototypical inheritance. |
Interfaces | There are multiple interfaces. | There are multiple interfaces. | There is no interface. |
Concurrency | There is concurrency with isolates. | There is concurrency with threads. | There is concurrency with HTML5 web workers. |
Prerequisite
There is no pre-requisite to learning the Dart programming language, and it is an easily understandable language even for beginners. The syntax of Dart is very similar to C#, Java, JavaScript, etc. Therefore, people already familiar with these programming languages can easily understand and learn the Dart language efficiently.
Audience
This tutorial has been developed keeping in mind all the readers at beginner, intermediate or professional levels. This is best suited for those who want to build a career in web development, Dart or Flutter. There is list of topics available under this tutorial that will help you learn the Dart programming language easily.
DART Tutorial Index
- Dart Tutorial
- Single-Page Application Architecture
- Dart Features
- Dart Installation Guide
- Dart Basic Program
- Dart Syntax
- Dart Keywords
- Dart Variables
- Dart Comments
- Dart Standard Input Output
- Dart Important Concepts
Data Types
- Built-in Data Types
- Numbers
- Strings
- Booleans
- Lists
- Sets
- Maps
- Runes and Graphemes
- Symbols
- Enumerations
- Constants
- Queues
Other data types
OPERATORS
- Precedence and associativity
- Arithmetic operators
- Equality and Relational operators
- Type Test Operators
- Assignment Operators
- Logical Operators
- Bitwise and Shift Operators
- Miscellaneous operators
Control Flow Statements
- Introduction
- If statement
- If-else statement
- If-else-if statement
- Loops
- Switch and case
- Dart Break And Continue
- Assert In Dart
FUNCTIONS
- Dart function
- Types of Functions
- Anonymous function
- main( ) function
- Lexical scope and closure
- Recursion
- Common Collection Methods
Object Oriented Concepts
- Dart Object-Oriented Concepts
- Dart Classes
- Dart Constructors
- Dart This Keyword
- Dart Super Keyword
- Static Members
- Method Overriding
- Dart Interfaces
- Inheritance
- Dart Abstract Classes
- Dart Builder Classes
- Dart Callable Classes