What Is Dart, and Why Should You Care?
What Is Dart?
Straight from the horse's mouth (which is located here):
Dart is a class-based, single-inheritance, pure object-oriented programming language. Dart is optionally typed … and supports reiﬁed 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.
If that's a great, steaming pile of mumbo-jumbo to you, allow me to paraphrase the above.
Single-inheritance: Classes can extend other classes, but only one at a time. This is a common structure in Object-Oriented Programming. A rare few languages support multiple-inheritance, but the general consensus is that that causes more problems than it solves, so most OOP languages go for single-inheritance.
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
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.
Reified generics: Generics are a language feature that allow you to type the elements of a collection. For example, 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. Reiﬁed 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. It's 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.
So What Is Dart Really?
Yes, I had to provide the "official" explanation of Dart. But that may or may not satisfy you. Here's what Dart is, with the typical web developer in mind.
So, whether or not Google gets its way, it is certainly possible to write Dart projects for the web today, and we'll do just that by the end of this tutorial. Hopefully, along the way, I'll convince you that Dart is actually pretty promising.
What's Wrong With Dart?
Lastly, Dart is currently in development. That's exciting, and it's not something "wrong" with Dart per se, but if you start developing in Dart now, there's a certain chance that the API will change, or that things won't be documented fully or correctly, and the amount of information on the web is less than, say, the amount you can find about jQuery. It's bleeding edge, and that may not be for you, or for a given project.
What's Awesome About Dart?
At the same time, it's bleeding edge, and that's awesome. Investing in a little time now to learn Dart could put in a nice place once Dart is more stable. If you get involved now, you even have the opportunity to help shape the language. The Dart mailing list on Google Groups often has some back-and-forth between people suggesting ideas and Google engineers responding to that idea. Often user-contributed ideas are considered and it's not uncommon to see them incorporated.
I've already discussed the advantages of a typed, object-oriented language, and it probably goes without saying that those traits are also awesome.
Should You Care?
This is, of course, a loaded question, and I'd be inviting a comment-based Inquisition no matter how I answer. But answer I shall.
You'll probably already care, or not care, depending on how much you're bothered by Dart's problems, or excited by Dart's advantages. The previous two steps give you plenty of information the lead you to your own conclusion.
a redneck someone who cares about good programming, regardless of the language or platform, in which case you might care about Dart. You at least owe it to yourself to try it out.
Having said that, I feel it's always worth learning about new stuff. You may learn that the new thing isn't worth your time, but you should formulate that opinion on your own, through experience. We'll provide some experience in this tutorial, so if you're feeling adventurous, get ready for Dart.
This brief discussion of Dart has hopefully sparked your interest in this new language that may or may not take the web by storm. If you'd like to try it out, take a look at my Facebook-exclusive tutorial that will get your hands dirty with a simple Dart project.
(If you're not on Facebook, don't worry. The tutorial will be on the main Activetuts+ site eventually, and we have plenty more Dart content lined up in the mean time.)
Thanks for reading! Share your opinions about Dart in the comments.