3 ms·
If you're doing frontend dev, then you must use Javascript or a language which compiles to Javascript. I believe Dart currently has a mostly functional tool to
by Lazare 13y ago
If you're doing frontend dev, then you must use Javascript or a language which compiles to Javascript. I believe Dart currently has a mostly functional tool to compile Dart code to Javascript.
As for callback hell, Dart has "Futures" which are basically Promises. If you like Promises, you could use Dart...or one of the many excellent Promise libraries for Javascript; the syntax is almost identical.
(The linked article savages Promises for no obvious reason. I happen to like the syntax. In any case, Dart uses the same syntax, so if you buy the articles criticisms, Dart is no panacea.)
- nbevans 13y agoThe "syntax" of promises in JS and Dart isn't really a syntax. They are library features in the form of fluent method chaining. This is merely a library pattern, it is not a syntax. A syntax would be something like the async/await support in C#. Or the async and let!, do! etc along with pipelines in F#.
- k__ 13y agoAre there any compile-to-JavaScript languages out there, which do this? I read about function* and yield, but this seems to require all functions to be rewritten. Also I don't quite understand how this accomplishes to run 2 functions in parallel, if they are async.
- balakk 13y agoHere are a couple : Saltarelle - C# to JS compiler: http://www.saltarelle-compiler.com/documentation/supported-c-language-features http://www.saltarelle-compiler.com/documentation/supported-c... Funscript: http://funscript.info/samples/simpleasync/index.html http://funscript.info/samples/simpleasync/index.html
- k__ 13y agoThank you! Are there any non-ms solutions?
- balakk 13y agoFunscript is not really MS - it's done by a third-party developer, and F# itself is open-sourced under a very liberal license, and runs well on Xamarin/Mono in OS X. I don't think there are direct equivalents in other languages, although similar approaches exist. Checkout Elm for example: http://elm-lang.org/Examples.elm http://elm-lang.org/Examples.elm
- Lazare 13y agoA valid point; that just seemed like the easiest way of phrasing it to me. Anyhow, what I was trying to say is that the linked article trashes Promises, and Dart has Promises, so Dart is at least in that respect not a solution.
- k__ 13y agoAnd this aspect is one of the biggest problems I got with JavaScript. The only big things, which Dart seems to solve, is modularization and the many tiny JavaScript quirks, for which IDEs or a strong understanding of the language is needed.