At its heart, Dart is a conservative programming language. It was not designed to champion bold new ideas, but rather to create a predictable and stable programming environment.
The language was created at Google in 2011, with the goal of unseating JavaScript as the language of the web.
JavaScript is a very flexible language, but its lack of a type system and misleadingly simple grammar can make projects very difficult to manage as they grow.
Dart aimed to fix this by finding a halfway point between the dynamic nature of JavaScript and the class-based designs of Java and other object-oriented languages.
The language uses a syntax that will be immediately familiar to any developer who already knows a C-style language.
Like all good programming books, we’re going to start with a program that prints “Hello, World” (kind of) to your console. In your favorite text editor,
Create a new file in the hello_world directory called hello_world.dart. Write this code in the file:
void main() {
print('Hello, Dart!');
}
Now, back in your terminal, you can execute Dart code with the CLI command dart. To follow along with these instructions, make sure you’re in the right project directory where your hello_world.dart file lives. Then, run the “Hello, Dart” example:
$ dart hello_world.dart
// => Hello, Dart!
If “Hello, Dart!” did in fact print, congrats!
You wrote your first Dart program, and you’re officially a Dart programmer!If “Hello, Dart!” did in fact print, congrats!
Let's understand how the Dart Works!