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.

Bullet-proof Node.js coding

141 pointsby ideamonkabout 14 years ago

10 comments

tlrobinsonabout 14 years ago
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 未加载
ddispaltroabout 14 years ago
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 未加载
Cyranixabout 14 years ago
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>
stephenhueyabout 14 years ago
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.
jhrobertabout 14 years ago
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"
cprabout 14 years ago
Excellent, meaty article with a lot of practical examples and hard-won knowledge.
noacctplzabout 14 years ago
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.
BillSaysThisabout 14 years ago
Fairly amusing that a page with this title returns a 404 at this moment (and I tried reloading twice more).
sausagefeetabout 14 years ago
Anyone used node-fibers? What are the gotcha's?
评论 #2369518 未加载
allan_about 14 years ago
seems like laurenzos bulletproof node.js code just got caught in the eventloop
评论 #2369333 未加载