It feels as if there are almost as many pro­gram­ming languages as there are grains of sand on the beach. Among the numerous options out there, the pro­gram­ming language Dart is the new kid on the block. When comparing internet pro­gram­ming languages, the basic pro­gram­ming paradigms are usually fairly similar. It is only when you take a deeper dive into them and examine them in detail that the dif­fer­ences become apparent.

Recently developed pro­gram­ming languages are often dedicated to creating mobile ap­pli­ca­tions for smart­phones and tablets. These languages need to enable a good user ex­pe­ri­ence (UX) with minimal syntax and also use as little of the device’s available memory as possible. In the following, we will explain how Google’s pro­gram­ming language Dart fits into this category and what it can do.

What is Dart?

Dart is a pro­gram­ming language that was and still is primarily developed by Google. Dart is ECMA stan­dard­ized (European Computer Man­u­fac­tur­ers As­so­ci­a­tion). Dart is intended to be an at­trac­tive al­ter­na­tive to JavaScript for pro­gram­ming in modern web browsers. Dart de­vel­op­ers believe that it is no longer possible to solve the issues with JavaScript by con­tin­u­ing to develop the language.

The pro­gram­ming language Dart was developed in 2010 and first released the following year. Browsers did not and still do not natively support Dart, so the Dart2js compiler (“Dart to JavaScript”) was developed since JavaScript can be executed in all modern browsers. Dart is similar to common object-oriented pro­gram­ming languages (e.g. Swift, C# and Java) which are based on specific pro­gram­ming paradigms. Its rules for combining specific char­ac­ters (i.e. the syntax) are similar to those in the pro­gram­ming language C. This sim­i­lar­i­ty makes the language quite easy to learn, so you can get started using it without having to overcome any huge language barriers.

How is Dart struc­tured?

Dart is comprised of variables, operators, con­di­tion­al state­ments, loops, functions, classes, objects, and enu­mer­a­tions. It features in­her­i­tance and generic pro­gram­ming which are important concepts of an object-oriented pro­gram­ming language – much of which will be familiar to an ex­pe­ri­enced pro­gram­mer. If you are looking to try out this language for the first time, there is an open source platform called DartPad available which you can use to get a feel for the language and check out some examples from a drop-down menu.

All programs written in Dart start by calling the “main” function:

void main() {
}

The following example demon­strates how to define a variable and execute a con­di­tion­al statement:

void main() {
    var animal = 'horse';
    if (animal == 'cat' || animal == 'dog') {
        print('This animal is a pet.');
        } else if (animal == 'elephant') {
        print('That\’s a huge animal.');    
     } else {
        print('This animal is not a pet.');
     }
}

In DartPad, this results in the following output in the console:

For the variable “animal” (var animal), replace “horse” with “cat”, “dog”, or “elephant” and watch how the output changes in the console on the right-hand side. For more detailed in­for­ma­tion on how to program with Dart, check out our Dart tutorial.

What is Dart used for?

Dart is primarily used to program for internet-enabled devices (e.g. smart­phones, tablets, and laptops) and for servers. Until recently, it has not been realistic for pro­gram­ming beginners to try to develop mobile or web-based ap­pli­ca­tions them­selves. Dart’s approach aims to make pro­gram­ming such apps easier. Google’s own software de­vel­op­ment kit (SDK) Flutter and the well-known ad­ver­tis­ing tool Google Ads are both pro­grammed with Dart. Ad­di­tion­al examples include the websites for the New York Times and Groupon. DartPad, mentioned above, provides a con­ve­nient way to get to know the language using the trial-and-error method and acquire basic pro­gram­ming skills with it.

What are Dart’s strengths and weak­ness­es?

Dart has a number of ad­van­tages but also some dis­ad­van­tages.

Ad­van­tages

Dart is an open source pro­gram­ming language and can be used by anyone free of charge. Dart is developed by Google. Being backed by such a large company means that this language has long-term prospects for further de­vel­op­ment. Dart is easy to learn for pro­gram­mers because of its syntax. Its de­vel­op­ers have sim­pli­fied and in­tel­li­gent­ly condensed many of the com­pli­cat­ed syn­tac­ti­cal concepts found in other languages. Anyone who has already worked with C# will be able to quickly fa­mil­iar­ize them­selves with Dart. This pro­gram­ming language has been developed for the web. Due to being able to be quickly and directly converted into JavaScript, Dart can work in all modern mobile and desktop browsers. To program with this language, all you need is a simple text editor. However, this will require a deeper knowledge of the pro­gram­ming language. It is easier to work in special editors like Android Studio (Google) and Visual Studio Code (Microsoft).

Dis­ad­van­tages

Dart is a rel­a­tive­ly new pro­gram­ming language. This means that its support community is not very large yet and it doesn’t have as many learning resources available as JavaScript. However, it is safe to assume that this will soon change. The initial in­stal­la­tion of an editor and its technical resources on a computer is well doc­u­ment­ed but is also fraught with pitfalls. Critics have also pointed out that once again a new language has been in­tro­duced to the market instead of trying to perfect the existing ones.

How is Dart different from other pro­gram­ming languages?

One major way that Google’s pro­gram­ming language Dart stands out from other pro­gram­ming languages is by being easier to read with a syntax that is similar to that of a human language. It uses fewer commands but more options. You can freely choose the names for your variables making any code you write yourself un­der­stand­able. This also elim­i­nates the need to make tons of ad­di­tion­al comments in the code. You can use spaces, tabs, and line breaks as you wish. This allows a pro­gram­mer to clearly structure the code in a way that will ul­ti­mate­ly be ignored by the compiler. There are ex­cep­tions such as keywords, variable names, and function names (i.e. defined terms in Dart). These include “if”, “else”, “string”, and “void” among others. Lastly, a clear dis­tinc­tion is made between using uppercase and lowercase letters which sig­nif­i­cant­ly increases the scope for naming.

In an analysis of the most popular pro­gram­ming languages in 2019, the developer platform Stack Overflow found that Dart (66.3%) was just behind JavaScript (66.8%).

Go to Main Menu