TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Bullet-proof Node.js coding

141 点作者 ideamonk大约 14 年前

10 条评论

tlrobinson大约 14 年前
While this is a good article, things like this make me wonder if Node's asynchronous programming model is a good one. Certainly I don't think it's worth the mental overhead when you aren't dealing with highly concurrent IO situtations.<p>I constantly feel like I have to jump through hoops when programming against async APIs. None of the code in the article feels "elegant" to me.<p>Of course the popular alternative, preemptive multithreading with shared mutable state, is probably worse.
评论 #2370303 未加载
评论 #2370035 未加载
评论 #2370045 未加载
ddispaltro大约 14 年前
Im curious on node fibers. They seem like a second class citizen in node, any chance they will become mainstream or will it always be like Twisted is to Python.
评论 #2370068 未加载
Cyranix大约 14 年前
Cache link: <a href="http://webcache.googleusercontent.com/search?q=cache:http://stella.laurenzo.org/2011/03/bulletproof-node-js-coding/" rel="nofollow">http://webcache.googleusercontent.com/search?q=cache:http://...</a>
stephenhuey大约 14 年前
This arrived just in time since I deployed my first Node app on Joyent last night! Great examples--they're all pretty new to me, but I'm planning to revisit your tips when I get further along.
jhrobert大约 14 年前
I'm experiencing "node anxiety", let me explain:<p>There really are two kinds of functions in a node program.<p>Synchronous functions and asynchronous functions.<p>This has major consequences during refactoring when what used to be a synchronous function now needs to become an asynchronous function =&#62; all synchronous functions that used to call the synchronous function needs to be turned into asynchronous functions themselves.<p>Sometimes the ramifications go way beyond first expected.<p>Sometimes the ramifications turned to be massive.<p>This becomes worse when one realizes that synchronous function are much more readable, half the code and about 5 times faster than asynchronous ones (see <a href="http://jsperf.com/asynch-cost" rel="nofollow">http://jsperf.com/asynch-cost</a>)<p>Eventually the idea of refactoring a synchronous function into an asynchronous function becomes a source of worries.<p>And that, my friends, is not something easy to figure out and is what I call "node anxiety"
cpr大约 14 年前
Excellent, meaty article with a lot of practical examples and hard-won knowledge.
noacctplz大约 14 年前
For #1, why not suppy a success and failure callback function to your doSomeAsyncCall function? There is no reason to muddle those two lines of logic together (which is the real reason for the described error).<p>And for #2, Relying on javascript hoisting functions isnt a smart way to keep your code organized.
BillSaysThis大约 14 年前
Fairly amusing that a page with this title returns a 404 at this moment (and I tried reloading twice more).
sausagefeet大约 14 年前
Anyone used node-fibers? What are the gotcha's?
评论 #2369518 未加载
allan_大约 14 年前
seems like laurenzos bulletproof node.js code just got caught in the eventloop
评论 #2369333 未加载