DEV Community

Cover image for Dart: The Language behind Flutter and Fuchsia OS.
Jay Tillu😎
Jay Tillu😎

Posted on • Updated on

Dart: The Language behind Flutter and Fuchsia OS.

Flutter 1.0 is officially announced on Dec 04, 2018. After that, the demand of dart programmers is gaining popularity now. Because 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 give you answer why Google choose 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:

  1. Scripting
  2. Object Oriented
  3. Imperative
  4. Reflective
  5. 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’s background you’ll feel just like hometown in a dart. Its syntax is closer to C.

  1. C#
  2. JavaScript
  3. Erlang
  4. Smalltalk
  5. Strongtalk

It has four major implementations:

  1. Dart VM
  2. dart2js compiler
  3. Flutter
  4. 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:

  1. Through Transcompile to JavaScript
  2. Through DartVM
  3. Through the AOT compilation process

Through Transcompile to JavaScript

Dart code can be compiled to 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.

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

Just like Java has JVM, Dart has its own 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 seconds.

DartVM is directly coming with Dart SDK. You just need to setup 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 build with Flutter uses 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 which stores object 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:

  1. Script snapshots
  2. 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 have 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 itself. If you’re planning to go into app-development domain then you should definitely 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 definitely like to learn that.

Jai Hind, Vande Mataram 🇮🇳

Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊

Top comments (6)

Collapse
 
josemunoz profile image
José Muñoz

Interesting for sure, but I would take Dart with scepticism, Google's reputation taints the project and the fact that no consumer-grade devices are running fuschia is also a factor in the Language's longevity.

Collapse
 
stargator profile image
Stargator • Edited

Google has said Fuchsia is used to test out OS features before applying them to Android. But that could be a cover.

Right now, Fuchsia isn't being marketed for use in any products, so I can't see Fuchsia not being marketed as a consumer product as a Con when it doesn't look like that is what Google wants to do it.

Collapse
 
incrypto32 profile image
Krishnanand • Edited

Have you ever felt there is something weird about Fuschia,
First of all, it was sort of a secret project until they released the development website and second when we look at the timeline ,
First introduction of dart then the introduction of flutter then the announcement of Fuschia everything was planned af. Google has big plans with Fuschia thank god it is opensource.

Thread Thread
 
jay_tillu profile image
Jay Tillu😎

yaa you are right

Thread Thread
 
stargator profile image
Stargator

@Krishnanand I don't think this was always in Google's plan. But Dart has evolved to be more type sound and a better fit for enterprise projects like Google Ads which uses AngularDart.

And now it is the underlying language for Flutter, so it makes sense for them to push what can be done with it.

Collapse
 
daanchuk profile image
daanchuk

Great write up!