Junior — Middle
Can you list the main features of the Dart programming language?
sobes.tech AI
Answer from AI
Main features of the Dart language:
- Static typing with type inference — Dart allows explicitly specifying types, but they can often be omitted thanks to type inference by the compiler.
- Object-oriented language with support for classes, mixins, abstract classes, and interfaces.
- Asynchronous programming is implemented through the keywords
async,await, andFuture, which simplifies working with asynchronous code. - Garbage Collection — automatic memory management.
- Support for functional programming: first-class functions, lambda expressions, closures.
- Hot Reload — fast code reloading without losing state, especially useful in Flutter development.
- Cross-platform — used for developing mobile, web, and server applications.
- Null Safety — a safety system against null values, helping to avoid runtime errors.
Example of a simple class in Dart:
class Person {
String name;
int age;
Person(this.name, this.age);
void greet() {
print('Hello, my name is $name and I am $age years old.');
}
}
void main() {
var p = Person('Anna', 30);
p.greet();
}