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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

"Ruby developers need to stop using EventMachine. It's the wrong direction."

149 点作者 caseorganic超过 12 年前

9 条评论

programminggeek超过 12 年前
If you really like evented programming, use node. Everything there is evented. I tried EventMachine and it just felt worse than node, documentation is worse, libraries are worse, it just wasn't a whole lot of fun.<p>I haven't tried celluloid yet, but I've learned one lesson building things with PHP, Ruby, Python, Node, Java, Scala, etc. That lesson is to use tools with a community of people around it that are using those tools to solve the same problems as you. The more community is around a project the more likely that someone else has stumbled upon whatever bug or problem you have hit already and found a solution if it exists. Also, documentation tends to be better and easier to find on more popular languages and frameworks.<p>So, if you like busting out CRUD web apps, you probably should look at PHP and Zend/Symfony/etc. framework or Ruby on Rails or Python Django or Java Play. If you like doing single page JS apps you should look at Knockout, Backbone, and Ember. If you want to do more evented/parallel networked apps you should look at node, scala, clojure, go, and erlang because those communities care a lot about threading, evented, actor pattern type programming.<p>Evented/multicore/multithreaded programming is just not something that say PHP, Ruby, and Python have embraced as much as a community because it's not for the most part a problem that the average PHP, Ruby, and Python dev is trying to solve most of the time.
评论 #4696378 未加载
评论 #4696865 未加载
评论 #4696920 未加载
ericb超过 12 年前
I've looked at Celluloid. It offers a much nicer paradigm than eventmachine. It also provides a nice way to distribute actors over multiple machines (DCell). I strongly agree with this slidedeck. Callback muck is maddening.
评论 #4695990 未加载
评论 #4696027 未加载
评论 #4696169 未加载
newobj超过 12 年前
Not to judge this presentation up or down; I'm not a Rubyist... but a reflection for myself - you know you're getting old when you see ideas that have come and gone and come and gone come again.
评论 #4697831 未加载
tptacek超过 12 年前
We write a <i>lot</i> of EventMachine code here; I have some questions. He writes:<p>EventMachine is • A frankenstein guts the ruby internals • Not in active development • Makes non-blocking IO block • Requires special code from Ruby libraries • Hard to use in an OOP way • Is really difficult to work with • Poorly documented<p>I'm not sure I understand how EventMachine "guts the Ruby internals" (I didn't watch the talk). It's true that EventMachine's internals are C++, not Ruby; there was originally a reason (again, I think it had to do with green threads) that it was designed this way. I'm not sure I can think of the Ruby functionality that EventMachine changes, or the manner in which EventMachine mucks with the interpreter or its runtime. I'm obviously ready to be corrected, but I'm missing how this impacts me as a programmer. Maybe he's talking about exception handling?<p>I also wasn't aware EventMachine "wasn't under active development". Because it's just an IO loop. Is libevent in active development? Do I need to be aware of that to use it? The underlying OS capabilities EventMachine maps haven't changed in over a decade. I think I'm actually <i>happy</i> they aren't constantly changing it.<p>I also don't understand how EventMachine "makes non-blocking block". All EventMachine I/O is nonblocking; it's essentially a select loop.<p>I also don't understand what special code EventMachine demands from libraries. Maybe he means database libraries? That is, maybe he's referring to the fact that you can't use standard Ruby database libraries that rely on blocking I/O inside an EventMachine loop? I'm wondering, then, what he expected. We wrote a little library (a small part of it is on Github) to do evented Mysql, but we stopped doing that when we realized that Redis evented naturally, and we just hook Mysql up through Redis.<p>"Hard to use in OOP way" just seems wrong, given that the ~30 evented programs I can find in my codebase directory all seem to be pretty object-oriented. So, that's not so much a question on my part.<p>Really difficult to work with? I've taught 7 different people EventMachine, in a few hours each. EventMachine is <i>easier</i> than Ruby's native sockets interface, in several specific ways.<p>I think maybe the issue here isn't so much EventMachine, but the idea of using EventMachine as a substrate for frameworks like Sinatra and Rails. <i>That</i> idea is whack, I agree. Trying to retrofit a full-featured web framework onto an event loop seems like an exercise in futility.<p>But on the other hand, I've been writing Golang code for the past 2 months, and Golang is <i>militantly</i> anti-event; it doesn't even offer a select primitive! Just alternating read/write on two different sockets seems to demand threads! And what I find is, my programs tend to decompose into handler functions naturally anyways. I try to force myself to write socket code like I did when I was 13, reading a line, parsing it, and writing its response, but that code is brittle and harder to follow than a sane set of handler functions.<p>So, long story short: I'm not arguing that evented code is the best answer to every problem, or that web frameworks should all be evented, or that actor frameworks aren't useful. It's probably true that a lot of people rushed to event frameworks who shouldn't have done that. But there are problems --- like, backend processing, or proxies, or routers and transformers, or feed processors --- where event loops are the most natural way to express a performant solution.
评论 #4696217 未加载
评论 #4696064 未加载
评论 #4696489 未加载
评论 #4696046 未加载
评论 #4696610 未加载
评论 #4696796 未加载
评论 #4696206 未加载
chrislloyd超过 12 年前
After using EventMachine in heavy production at Minefold for the last year and a half we're finally ditching it for Go. Our experience has been similar to the OP's. However we had random exception gobbling, internal threading issues and increasingly worse performance + code maintainability.<p>We've been happily using Go for a few internal systems are are slowly galvanising most of our backend with it too. Life is happier.
dacort超过 12 年前
I just replaced an EventMachine-based project with Celluloid::IO - it was a pretty simple replacement, although I had some issues with concurrent connections (<a href="https://github.com/celluloid/reel/issues/11" rel="nofollow">https://github.com/celluloid/reel/issues/11</a>).<p>I have yet to test it in production, but it looks pretty promising.<p>I had a lot of problems with EM blocking networks connections if an event loop was tying up CPU, but I suppose that's to be expected.
PaulHoule超过 12 年前
Well, when I hear about Actors I reach for my gun.<p>I knew a guy who chose Scala for a project so he could use Actors for concurrency.<p>The system never gave the same answers twice and wouldn't peg all the cores on a 4-way machine.<p>I spent two days trying to fix it, then I got wise and switched back to Java and got it working in 20 minutes with ExecutorService with (i) no race conditions, and (ii) nearly perfect scaling up to eight cores.
numbsafari超过 12 年前
1999 called and it wants its DCOM back.
johnkchow超过 12 年前
There's a fork out there called EventMachine-LE, which is currently in active development for latest features (i.e. IPv6). <a href="https://github.com/ibc/EventMachine-LE" rel="nofollow">https://github.com/ibc/EventMachine-LE</a><p>Anyway, just wanted to throw it out there that I've deployed several production apps (gaming/messaging servers) using EventMachine, and combined with em-synchrony, I'm pretty comfortable with its performance and limitations. There seems to be good community support (thanks to Ilya Grigorik's articles and em-synchrony) with plenty of examples/documentations.<p>Just wondering, are there any people out there with Celluloid app experience that's currently in production? Like any other geek, I love programming "the right way" but I know nothing about Celluloid and it's real-world benefits/drawbacks (performance, API, code maintainability, code documentation, community support, blog articles, etc).
评论 #4697647 未加载