TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

StratifiedJS: Javascript + structured concurrency

53 pointsby danhover 13 years ago

4 comments

olegpover 13 years ago
If you prefer vanilla JS and are only working with Node, you should check out <a href="https://github.com/laverdet/node-fibers" rel="nofollow">https://github.com/laverdet/node-fibers</a>. I use it in my <a href="https://github.com/olegp/common-node" rel="nofollow">https://github.com/olegp/common-node</a> package to address the same issues as those tackled by StratifiedJS.
skrebbelover 13 years ago
I'm probably missing something, but isn't this race condition galore? As per the front page example:<p><pre><code> var news; waitfor { news = http.get("http://news.bbc.co.uk"); } or { hold(1000); news = http.get("http://news.cnn.com"); } or { hold(1000*60); throw "sorry, no news. timeout"; } show(news); </code></pre> This starts the first 'or' clause the moment the http.get(BBC) suspends, which it does quickly because http.get is async. Now, if the BBC get returns <i>just</i> after my hold(1000) has completed but before http.get(CNN) had the time to really launch the http request and suspend, i'll have done the CNN get for nothing.<p>Of course in this case this only means a wasted request. But what in case of side effects?
评论 #3538866 未加载
评论 #3538472 未加载
jashkenasover 13 years ago
After the IcedCoffeeScript post the other day, I found Oni Labs' version -- which I don't remember seeing before -- Stratified CoffeeScript:<p><a href="https://github.com/onilabs/coffee-script" rel="nofollow">https://github.com/onilabs/coffee-script</a>
beggiover 13 years ago
Eliminating nested callbacks would be one hell of a feat.
评论 #3537551 未加载