Hacker News new | ask | show | jobs
by phloxicon 4364 days ago
That's really helpful. Thanks.

I have another question. C++ already has types, a main function, collections etc. and is really fast. What are the advantages of Dart over C++ with emscripten?

1 comments

Dart is much more of a scripting language than C++. It makes as many code issues static warnings and runtime errors as it can, rather than runtime errors, so you can run a partially incorrect program.

Dart is also strongly typed, doesn't have pointers, has GC, has no shared-memory concurrency, uses dynamic dispatch, don't require a compiler (for development), has full access the the DOM (with a much nicer API than in JavaScript!)...

Isn't the the API specified by the DOM?

Like, when I use DOM in any language, it will be conform the the DOM spec, like having the same classes, methods, etc.?

Dart's DOM API is way nicer than the one from JavaScript since the Dart team had the ability to re-think naming & structure.

This article has a nice summary of the improvements https://www.dartlang.org/articles/improving-the-dom/

Almost, but we have made it better.

For instance, rather than use callbacks everywhere, most of our async APIs return Futures and Streams. All the "Array like objects", like NodeList, are actually lists in Dart. You can iterate over them and modify them list any other list. element.classses.add('foo') works, as well as some jQuery-isms like element.classes.toggle('foo', show). setInterval is replaced with the standard dart:async Timer class.

There is a ton of cleanup in the dart:html library that makes programming the DOM nice. I'd say there will never need to be a jQuery equivalent in Dart.

"There will never need to be a jQuery equivalent in Dart."

You should read the "Criticism" part of this page.

http://en.wikipedia.org/wiki/Dart_%28programming_language%29

Apple, FF, MS are all against Dart.

Google "percentage of website power by Jquery" and tell us how are you going to convince 50% of websites to abandon JQuery and use dart.

Dart today = GWT of yesterday!!!

That's such a straw man argument. It's 1995 - how are you going to convince 50% of C++ developers to give Java a chance?
You don't, instead you use your existing connections with corporate management and your massive advertising budget to convince managers to force developers to use it. Even if they are perfectly fine using C++ or Smalltalk.
You are missing the point. jQuery fixes the DOM API. Dart's "dart:html" already provides a clean nice-to-use API. All those list-like things are actual Lists. Futures and Streams are also baked into the language. Normalization also isn't needed anymore.

> Apple, FF, MS are all against Dart.

Oliver Hunt isn't Apple. Brendan Eich isn't Mozilla. He doesn't even work for Mozilla anymore.

Mircosoft's JavaScript team also isn't equivalent with Microsoft itself. It also would be pretty weird for them to endorse Dart.

They have TypeScript, which sells Visual Studio, which sells Windows licenses, which sells the Microsoft ecosystem, which sells Windows Server licenses.

That's how they operate and there is nothing wrong with that, really. If you have a large existing JavaScript codebase which you want to keep, TypeScript is a pretty good choice.

I'm familiar with the criticisms, what about them? The have nothing to do with DOM APIs.