First look: Google Dart vs. JavaScript

Dart fixes a number of problems with Web programming, but introduces new problems of its own

By Peter Wayner, InfoWorld |  Development

Many of the decisions the Dart developers made are likely to be cheered by most JavaScript and Java programmers. Other changes will be seen as great victories by some and grave mistakes by others. Still others look like advances, but I think they create even more problems than they solve. Naturally, you might feel differently.

Any differences of opinion about Dart, though, aren't likely to be crippling. Switching to Dart from JavaScript or Java isn't much of a leap. There are no radical decisions or dogmatic structural impositions -- indeed, you can pretty much ignore the features you don't like because the developers aren't on a quest to convert you. While each of us will be able to find fault with something, no one should find anything noxious enough to be a deal breaker.

Google Dart: Art of the familiar Before I give my opinion about the type system in Dart, I want to explain that I began this project after spending two solid days trying to chase down a crashing bug in an Objective-C program that appeared after I upgraded a library. My code didn't change, but it started crashing in one small, yet crucial corner. The new version of the library renamed one of the objects that my code used as a base class, but I never noticed. The Objective-C compiler probably noticed, but it didn't bother to tell me it couldn't find that base class anymore. Nope -- it built my code and gave me a high five, perhaps because someone thought that the word "objective" means not sticking your nose into others' conflicts or taking sides of any kind. After a few days of fiddling, I found the conflict and the code stopped crashing.

Given that, you can imagine how overjoyed I was to read Gilad Brancha, one of the Dart developers, write in the Dart documentation, "Your program will have exactly the same semantics no matter what type annotations you add." Wow. Thanks for nothing -- literally. In response, some jokers suggest that Google just wanted to save you the hassle of putting comment marks around the type annotations.

It turns out that Dart doesn't throw the type information into the bit recycling bin. You can ask it to run more slowly and check to see if the types of the data actually agree with what you suggested. There's even a static checker that preprocesses the file to flag some of the problems. The Dart authors also suggest the compiler might do a better job if the type information is there, but that awaits a future spec.


Originally published on InfoWorld |  Click here to read the original story.
Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Answers - Powered by ITworld

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question
randomness