9 Features I Love About the Dart Programming Language
A quick overview for those already familiar with similar languages, like Java, Kotlin, C++, and C#
Dart is primarily known as the programming language for Flutter, Google’s UI toolkit for building natively compiled mobile, web, and desktop apps from a single codebase. It’s optimized for building user interfaces and developed by Google. It’s used to build mobile, desktop, server, and web applications. Dart can compile to native code and JavaScript.
If you want to follow along with this article, which I highly recommend, you can do so without installing anything on DartPad.dev.
1. Indentation (and a Hello World)
Let’s start with the obligatory “Hello world”:
void main() {
print('Hello World!');
}
A few conclusions that we can already draw:
- Dart needs a
main()
function as a starting point - Dart doesn’t require a class (like C, unlike Java)
- Dart uses two-character indentation by convention
Two-character indentation makes the code more compact. This is really helpful when you start creating a Flutter application since Flutter apps are based on a tree of nested widgets. The amount of indentation can get out of hand pretty quickly.
2. Dart Code Is Compact
Dart code has many modern features to reduce code size. As you can see from the above example:
- You can simply refer to instance variables in a bodiless constructor to automatically assign values to them.
- Strings have template-like features, allowing you to directly use variables or even expressions like
${age - 10}
.