What Is Dart?

 

Dart is a client-optimized programming language for apps on multiple platforms. It is developed by Google and is used to build mobile, desktop, server, and web applications.

Dart is a class-based, single-inheritance, pure object-oriented programming language. Dart is optionally typed … and supports reified generics and interfaces. Dart programs may be statically checked. The static checker will report some violations of the type rules, but such violations do not abort compilation or preclude execution.

As a beginner, you may not understand what came previously, so I will explain each feature separately, knowing that understanding it is not necessary to start learning, but it may be useful for people who have some experience with other technologies.


Class-based: Dart expects you to use classes.

Object-oriented programming language: This statement is a bit redundant, given the "class-based" bit from before. But it is significant: Dart is OOP through and through.

Optionally typed: Most languages are either typed or not. JavaScript, for example, is not. When you define a variable, it will be untyped. You can set it to a String, then to a Number, and nobody will complain (well, I will). Moreover, you can call Array methods on that variable, and you won't have any problems until you actually run that line of code. In contrast, Java is typed. Every variable must be declared with a type, such as String or int. And when a variable is typed, you can't put a different type of value into it. And if you tried calling a method that doesn't exist on that type, the compiler will raise an error, letting you know your mistake before you run your code. C and its variants are other typed languages, while Ruby and Python are other untyped languages.

Optionally typed means, as you may now guess, that you have the option declaring a type for variables. It's as simple as this: you can leave the type off, and the compiler won't do any extra checking. If you supply a type, then the compiler will help you out with errors. ActionScript is an example of another optionally typed language. This is rather clever move, one that is probably intended to help speed adoption.

Reified generics: Generics are a language feature that allow you to type the elements of a collection. However, generics allow you to specify that every item in an Array - or any other collection type - must be of a certain type, perhaps a String. Thus, if you try to insert a Number into the Array, you can get warnings. Reified generics go an extra step and allow this type safety past the compiler. Type integrity at runtime is preserved.

Interfaces: An interface is a handy Object-Oriented technique. It defines a type without defining functionality. Its uses are hard to sum up in a sentence or ten, suffice it to say that they are integral to advanced (and clean) Object-Oriented Programming techniques (namely design patterns). Once you grok interfaces, you'll lament the lack of them in other languages.

Statically checked: This goes back to the typing thing. When typing is in use, a variable with a type is considered "statically typed," and as such the type can't be changed once it's been declared. This allows the compiler (or "static checker") to make assumptions about your intentions with your code; that is, if you declare a variable as a String, then you shouldn't try calling changeTimeZone on it. If you did (maybe you typed in what you thought was that variable holding the Date object), then the compiler can alert you to the error without having to run the code.



References

1. What Is Dart, and Why Should You Care?
2. Dart (programming language) – Wikipedia