4 ms·
To me the fundamental shortcoming for javascript is not its typelessness, it's the lack of language syntax support for asynchronous programming, which is the bu
by kailuowang 13y ago
To me the fundamental shortcoming for javascript is not its typelessness, it's the lack of language syntax support for asynchronous programming, which is the butter and bread for most javascript applications (server or client side).
I really hope I can do something like
for (
ra <- asycn_opA(),
rb <- async_opB(ra),
_ <- asycn_opC(ra, rb)
).run()
- judah 13y agoFWIW, there is talk of adding async/await like features (C#, Python) to TypeScript in a post 1.0 release.
- apaprocki 13y agoSo if you used Q or a similar library: Q.async(function*() { var ra = yield opA(); var rb = yield opB(ra); yield opC(ra, rb); })().done(); Are you wishing for the other syntax or something that you can't achieve with generators/promises today?
- v13inc 13y agoFortunately, with a bit of hacking, this style of syntax is possible without generators :) (I'm hoping to open source a library I wrote that works all the way back to IE6) Here's your example rewritten in the 'monads' library (I probably need a better name): monads(function() { var ra = opA.defer(); var rb = opB.defer(); var result = opC(ra(), rb()); });
- dangoor 13y agoIs that open source? I'd be interested in taking a look.
- masklinn 13y ago> it's the lack of language syntax support for asynchronous programming spawn(function*() { var ra = yield async_opA(); var rb = yield async_opB(ra); yield async_opC(ra, rb); }); This works right now in Gecko: http://taskjs.org/ http://taskjs.org/. Something very close ought work in ES6/Harmony.
- deleted 13y ago[deleted]