For what it's worth, the other issue that has "bothered" us a bit is lack of an Eclipse plug-in version of the dev tools. We use Eclipse all over our curriculum, and also in many of our graduate research projects and classes. It'd be really great to have access to Dart within an already set up / configured version of Eclipse, rather than in a closed & dedicated build of Eclipse.
For a very first course, the closed environment is actually ok, but for any more advanced courses, in our environment in any case, there'd be significant value in having an E. plug-in.
In the sample code that you have sent, what happens when I have a 1000 listeners. Iterating over the listeners and generating the "onMessage" events is sybchronous although these event-handlers themselves are asynchronous.
On the other hand here is some hypothetical code that you may find interesting. Pardon the ruby style pseudo code.
var listeners = new Channel()//not just a regular List
//var listeners = new List(); // add/remove listener not shown.WebSocketHandler handler = howeverYouWantToObtainOne();handler.onOpen (WebSocketConnection ws) {ws.onMessage = (message) {listeners.push(message);}// skipping onClosed etc.}class Channel
{
//subscribe and unsubscribe code omitted
def push(message)
Schedule_on_the_reactor{@subscibers.forEach((each) => each.onMessage(message))}//the iterations are sequential but asynchronous with the event loop.
end
}
Hypothetically, the channel will schedule all operations on the main reactor thread for thread safe reactor operations. How would you make it possible to iterate asynchronously? (i do not mean parallel execution of each item which would be a different problem but just schedule the iterations so that the event-loop can continue without being blocked.)
I could have just missed out on a trick in Dart to accomplish this.
For the first question:
The essential feature of jQuery missing from Dart is its user interface library. So, not a deficiency of Dart itself, but rather a reflection on the infancy of the language -- I'm sure this will change with time. Unfortunately, the absence of basic UI components (both "behavioral" like drag-and-drop or sort, and "widget" like tabs and tables) is a huge blocker to effective Web 2.0 development in Dart -- "rolling your own" UI components just isn't feasible for most projects.
I am nervous about the lack of browser support for Dart, and hence the requirement that it be cross-compiled down to JS. I have seen several examples mentioned in docs where code executed on the Dart VM behaves differently from the same code compiled to JS (presumably this is due to bugs in the compilers which will be fixed). More subtly, I haven't seen a study evaluating the cross-browser support of Dart-sourced JS. Especially given the large amount of JS code that gets generated, do all the major modern browsers execute it the same? This is one of the big selling points of jQuery -- browser support is excellent and predictable. And, admittedly, the lack thereof is one of the worst flaws in "vanilla" JS.
I do miss the terse $ function syntax from jQuery, but that's pure personal preference and not important.
Cheers,
Matthew