Introduction to Dart


Introduction to Dart includes the basic definition and the need for Dart Langauge, also we will see some of the specialties of dart. So Let’s get started.

What is Dart?

Dart is a programming language for Flutter, a mobile app SDK from Google. It is a client-optimized programming language for fast apps on multiple platforms. It is developed by Google and is used to build mobile, desktop, backend and web applications.

Why Dart was Created?

Dart was created, more or less, because Google wanted a language that was “better” than JavaScript to write server-side and front-end code. The main issue they had with JavaScript is that it updates very slowly with new features since it relies on a huge committee for approvals and several browsers to implement it. although the fundamentals of Dart are similar to all high-level languages.

Dart is a “safe” language to learn. Google didn’t try out to create anything innovative with Dart. They were just planning to make a language that was simple, productive and could be compiled into JavaScript.

Dart uses “Just-In-Time” or JIT compilation. Which provides you with hot loading for frequent UI changes. There is nothing particularly exciting about its syntax, and no special operators that will throw you through a loop.

You can write Dart functions in 1 minute, scripts in 5 minutes, and apps in 10 minutes, Whoa! Isn’t is Exciting?

Let Us see a basic example of hello world and Fibonacci program using dart

 main() {
  print('Hello World!');

Fibonacci Example-

int fib (int n) => (n > 2) ? (fib(n - 1) + fib(n - 2)) : 1;
/* this is a fibonacci function implementation with a ternary operator
this code shall be read as:
If int n > 2, return fib(n - 1) + fib(n - 2); 
otherwise, return int 1 as result */

void main() {
  print('fib(20) = ${fib(20)}');

Hope it was useful and you liked it 🙂

Leave a Comment