What is Dart Language?
Dart was first unveiled at the GOTO conference in Denmark on October 10, 2011. Dart is a General Purpose Language originally developed by Google.
Table of contents
Flutter 1.0 is officially announced on Dec 04, 2018. After that, the demand for dart programmers is gaining popularity now. Because the entire Flutter app development is completely based on a dart.
It seems that tech-giant Google has some big plans with the language. That’s why Dart is implemented on two big projects including Flutter and Fuchsia OS. Here is a quick intro of Dart’s features, use cases, and its humongous power Which will answer why Google chose it for Flutter and Fuchsia OS.
Dart was first unveiled at the GOTO conference in Denmark on October 10, 2011. Dart 1.0 was released in November 2013 and Dart 2.0 was released in August 2018 with a sound-type system.
Dart is a General Purpose Language originally developed by Google.
Dart is a very powerful language that you can use to write from simple scripts to full-featured native apps using Flutter. It is mainly used in four platforms including Native Mobile App, Web App, Desktop App, and Server-Side App.
Designed By — Lars Bak and Kasper Lund
First appeared — October 10, 2011
Typing discipline — 1.x: Optional, 2.x: Static
License — BSD
File Extensions — .dart
Dart supports mainly five types of paradigms:
Scripting
Object Oriented
Imperative
Reflective
Functional
Dart is influenced by five languages:
Dart is a member of the ALGOL language family, alongside C, C++, Java, C#, JavaScript, and others.
So if you are from C, Swift, or Java background you’ll feel just like your hometown in a dart. Its syntax is closer to C.
C#
JavaScript
Erlang
Smalltalk
Strongtalk
It has four major implementations:
Dart VM
dart2js compiler
Flutter
Fuchsia OS
Ways to Run the Dart Code
Dart is implemented on a wide range of platforms. So it needs multiple ways to run the dart code depending on the platform. Below are three main ways to run the dart code:
Through Transcompile to JavaScript
Through DartVM
Through the AOT compilation process
Through Transcompile to JavaScript
Dart code can be compiled into JavaScript so that it can run on browsers. For that Dart uses a source-to-source compiler (dart2js) to convert its code to JavaScript.
So when you want to deploy your Dart code on browsers, first you need to convert that code via the dart2js compiler. dart2js will convert your code into JavaScript. So it can run on all modern browsers.
The here amazing thing is, dart2js will not only produce JavaScript code, instead it will produce optimized JavaScript code. That means compared to hand-written JavaScript code, your converted dart code will run faster on browsers.
Through DartVM
Like Java has JVM, Dart has its virtual machine for running Dart code-named DartVM.
If you want to create console apps or server apps you can use DartVM to run Dart code. DartVM is a highly optimized, powerful, and fast virtual machine that can run your Dart code in a fraction of a second.
DartVM is directly coming with Dart SDK. You just need to set up SDK’s path in your environment variables and you are ready to go. Your imagination is the only limit now…
Through the AOT compilation process
AOT means Ahead-Of-Time compilation is the process of compilation in which we covert a higher-level code such as C, C++, or an intermediate code such as Java Byte Code or .NET Framework’s CIL code (Common Intermediate Language), into a native machine code which is system dependent code. And that code can be run on a particular machine that understands it.
AOT produces machine-optimized code, just like a standard native compiler.
Apps built with Flutter use the same AOT compilation process to generate native Android and iOS apps from a single code base.
Snapshots: For faster code execution
According to Wikipedia: SnapShot is the state of a system at a particular point in time.
The same concept applies here, SnapShots are files that store objects and other runtime data.
So in the next startup whole program does not need to be compiled, the compiler will take saved data from snapshot files and compile only newly added data. Which results in faster startups and code execution.
Snapshots are a core part of DartVM.
There are two types of SnapShot files in Dart:
Script snapshots
Full snapshots
Script SnapShots
Dart programs can be compiled into SnapShots files. These files contain the program code and dependencies pre-parsed and ready to execute. This allows fast start-ups.
Full SnapShots
The dart core libraries can be compiled into a snapshot file which allows fast loading of the libraries.
Dart VM has a prebuild snapshot for the core libraries which is loaded at runtime. That’s how DartVM provides faster code execution.
So, guys, these are the features and use cases of a dart. It’s a very powerful language in itself. If you’re planning to go into the app-development domain then you should start to learn Dart and Flutter. I’ll try to share as much as I can on Dart and Flutter. Feel free to let me know if I missed something. I’ll like to learn that.
Till then Keep Coding, Keep Coding. Jai Hind, Vande Mataram 🇮🇳
For More Information Check Out Below Links