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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Evented I/O based web servers, explained using bunnies

30 点作者 r11t超过 15 年前

1 comment

stephenjudkins超过 15 年前
This is a good, simple explanation of how event-based servers work.<p>However, I strongly disagree with the "good code / bad code" dichotomy the author presents. Asynchronous, callback-based code is frequently more difficult to write, harder to reason with, more inflexible, and buggier than similar synchronous code. That said, moving to event-based code has generally been worth the cost for us, yielding improvements in performance and reliability that make up for the increase in developer time required.<p>The problem is that it's often very difficult to refactor synchronous code to be event-based since it requires an inversion of control. An attempt at changing clear, intention-revealing synchronous code to work asynchronously frequently results in ugly, hard-to-follow callback hell. Worse, a single piece of blocking code left inside the event loop can now render all of the work you've done moot, meaning such refactorings tend to sprawl.<p>This is why I think attempts to bridge this gap, making asynchronous read more-or-less the same way as asynchronous code, are very valuable. Scala's delimited continuations, coming in the upcoming 2.8 (<a href="http://www.scala-lang.org/node/2096" rel="nofollow">http://www.scala-lang.org/node/2096</a>), could help take a lot of the pain out of using event-based servers effectively.
评论 #1046641 未加载
评论 #1046358 未加载
评论 #1047216 未加载