×

Dart Features

Dart is a fully-featured, object-oriented modern language with its roots in the programming language ‘Smalltalk’. It has some of its eminent features similar to the languages such as Java, C# and JavaScript. 

Some of its prominent features are : 

1. Open-Source : Dart is an open-source programming language developed by Google. Open-Source means that it is easily accessible and modifiable to the public. Dart is a BSD licensed, and Ecma approved programming language.

2. String Interpolation : Dart provides ways of converting expressions to strings either by using toString( ) inbuilt function or string interpolation method. String Interpolation uses $ or ${ } expression enclosed within single or double-quotes. For example, to convert the expression "hey" to a string, we can use $hey. Multiline strings can be created using three double-quotes.

For example, 

var name = "This" "is" "Dart". 

Space after "This" and "is" is intentionally left to add spaces between the words while printing them. 

The result would be : 

"This is Dart". 

Note that there is no '+' operator to concatenate two strings. 

3. Optional Type System : Unlike other languages, Dart provides the feature of optional typing, meaning that it is optional to mention the data type. Optional type annotations are used in variables definition, function parameters definition and return types and class definitions.

For example,

var a = "This is a Dart tutorial"
String b = "This is a Dart tutorial"

No type annotation is provided in the first example, while in the 2nd example, the data type String is mentioned. Dart can be considered as documentary typed language because the code runs the same with or without types. 

4. Traditional class-based structure : Dart uses classes and interfaces inspired by object-oriented concepts similar to those of Java and C# but not JavaScript. It supports single inheritance and multiple interfaces.

An important point to note is that all the classes in Dart inherit from the Object class by default. They have public and private members and getter and setter functions to use fields interchangeably with properties without affecting users of the class. Private members are indicated by prefixing the variable or method with ‘_’ (underscore) character. This makes it instantaneous to detect the scope. 

‘this’ keyword refers to a specific instance of the class and not the owner of the class at any instant, like in JavaScript. 

Another important point to remember is that the classes are optional in Dart, and this means that functions can be declared even if they don't belong to any class. Functions can exist in top-level scope if they are not the part of any class. 

5. Implied interface definitions : Dart has a powerful feature of implementing a class that doesn't have an explicit interface. It mocks a class or provides custom implementation of a class, making it optional to inherit from a shared base class explicitly. Ideally, all classes define an implicit interface on their public members.

6. Factory constructors for default implementations : At times, it is required to use a single implementation of an interface under most circumstances. Dart supports this feature using the concept of factory constructors. The programmer defines a base class as an interface and supplies a factory constructor to provide a default concrete instance of the class.

7. Libraries and scope : Dart breaks up a source code into different modules stored in separate files. A library is a collection of all those files that make up a whole single file. In Dart, a library is one or more. Dart files are grouped together in a logical manner. Each file can have none or many classes and top-level functions. A particular library can import other libraries that its source code uses. Source files can reference the code of other source files from the same library or imported libraries.

A library can be declared or defined using a library keyword. Other libraries can be imported using the import keyword, and other source files are referred to using part keyword. 

A library can contain any number of source files, including 0. 

8. Functions as first-class objects : Functions are regarded as first-class citizens because they are capable of performing all the functions available to Objects. Dart allows you to pass functions as objects, store a function in a variable, pass a function as a parameter and anonymous functions to use as call backs.

9. Concurrency with isolates : Dart is a single-threaded language with a simple model to code in.

Isolates are the unit of work in Dart with their own memory allocation that establishes an isolated security model. Memory sharing is not allowed among isolates, but messages can be communicated. Each code runs its own isolate in a web page. Dart enables the code to spawn a new isolate from the running code. Isolates are also used to load the code dynamically outside the application's core code that is loaded into their own memory protected space. 

Whenever a message is passed within an isolate, the receiver isolate receives a copy of the message from the sending isolate. Any changes to the received data aren't automatically reflected on the sender's site. Therefore, another message reflecting the changes has to be sent back to the sending isolate. 

The Dart Virtual Machine implementation sometimes use multiple cores to run isolates as per the requirements. 

10. Platform Independent : Dart is a platform-independent programming language which means it can be run on any operating system like Windows, Linux. This feature is enabled through Dart Virtual Machines that can provide support to run the code in any programming language. 

11. Browser Support : Dart is compatible with all modern browsers. The Dart2js compiler converts the Dart source code into JavaScipt code, making it suitable for any web browser. 

These are some of the major features of the Dart language. It supports additional extensive utilities such as interfaces, mixins, abstract classes, reified generics, and type inference which will be discussed later in the tutorial. 


Related Topics

Lexical Scope and Closure

Lexical Scope : Lexical scope is a very important term in any programming language. It defines the scope of the variable based on the block it is contained inside. According to...

2 minutes read.

Dart - extends, with and implements Keywords

The application development in Dart programming language using the Flutter framework, regularly experience different usage of the implements, extends and with keywords. Dart has full support for inheritance that is...

5 minutes read.

Dart Anonymous Function

Dart functions are the user defined functions that are designed to perform specific task. The use case of the functions is that they can be directly called any number of...

3 minutes read.

Dart Standard Input & Output

Standard Input in Dart (stdin): The standard input stream reads data both synchronously and asynchronously from the keyboard.  In Dart programming language, .readLineSync( ) function is used to accept input from the...

3 minutes read.

Dart Generics

Dart Generics is similar to Dart collections, which are used to store homogeneous data. As we have discussed in Dart's features, it is a language with types being optional. By default,...

4 minutes read.

Dart Common Collection Methods

Most of the programming languages have arrays as a way to list items together. However, Dart has a collection of data structures similar to array. These are supported by the...

3 minutes read.

Dart Switch Case Statement

In the case of if-else statements, we prefer not to use the if-else ladder when there are many test conditions to be evaluated. In such a situation, it is preferable...

4 minutes read.

Dart If statement

If statement is used to set the control on the lines of code. Using if statement, block of code is executed only if the expression in the statement returns true....

1 minute read.

Dart Break and Continue

Loop statements are used to change the normal sequence of flow of the program. Dart supports two types of loop control statements: Break StatementContinue Statement Break Statement : The ‘ break ’ statement is...

4 minutes read.

Dart Isolates

Dart successfully supports asynchronous programming which runs our program without any hindrance. This asynchronous programming is used to achieve concurrency. Dart supports concurrent programming with features such as ‘ async-await...

9 minutes read.

Soundness in Dart

What is soundness? Soundness ensures that the program never comes across any invalid state that may lead to abrupt termination of the program. As its name suggests it ensures perfect type...

4 minutes read.

Dart Type Test Operators

Type Test Operators in Dart These operators are used to check the types of expressions at runtime. Dart is a typed language, and we often want to assert that a value...

1 minute read.

Dart Function

A Dart function is a collective line of code that are targeted to perform a specialised task. Such lines of code (function) can be reused whenever we need to perform...

6 minutes read.

Dart Comments

Comments are the statements that are used to enhance the readability and understandability of the code. The compiler does not execute these lines. It simply ignores these comments when it scans...

2 minutes read.

Dart Bitwise and Shift Operators

The Bitwise operators are the operators that perform different operations bit by bit on the value of the two operands. List of Bitwise Operators in Dart Sr. Operators Description 1. & ( Binary AND ) It returns...

2 minutes read.

Dart Recursion

Recursion is one of the most important and interesting concepts in any programming language. It can be defined as a process in which a function calls itself directly or indirectly....

5 minutes read.

Dart Numbers

Dart provides an in-built data type ‘Numbers’ that provides two types of values: intdouble 1. int data type int data type supports integer values, and their size or values range is platform-dependent. Integers...

4 minutes read.

Dart Built-in Data Types

A data type defines the type of value a variable can hold, such as integer, double, or string.  Dart supports two data types:  1. Built-in data types : These are the data...

1 minute read.

Typedef in Dart

In Dart, typedef is used to generate a function type that we can use as a type annotation for declaring variables and return types of the function type. An alias...

4 minutes read.

Dart Runes and Graphemes

Runes and Graphemes data types in Dart Runes and Graphemes Runes are the special string of Unicode UTF-32 bits that represent the special syntax. Unicode defines a unique numeric value for each...

2 minutes read.