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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Goru, an experimental, Go-inspired concurrency library for Ruby

6 点作者 bryanp大约 2 年前
Hey folks, wanted to show this off and get feedback. Still early&#x2F;experimental but there are quite a few concepts I&#x27;m excited about here. This project came about while writing a program in Go and loving its approach to concurrency. Being a long-time Rubyist I immediately started to think about what similar concepts might look like in Ruby.<p>I set out with two main design constraints:<p>1. Lightweight: I didn&#x27;t want routines to be backed by fibers or threads. Having been involved some in the async project (<a href="https:&#x2F;&#x2F;github.com&#x2F;socketry&#x2F;async">https:&#x2F;&#x2F;github.com&#x2F;socketry&#x2F;async</a>), I had some experience using fibers for concurrency but was curious if they could be avoided.<p>2. Explicitness: Routine behavior must be written to describe exactly how it is to behave. I always felt like concurrent code was hard to fully understand because of the indirection involved. On the spectrum between tedium and magical I wanted to err more on the side of tedium with Goru.<p>Goru routines are just blocks that are called once for every tick of the reactor. It is up to the developer to implement behavior in terms of a state machine, where on each tick the routine takes some action and then updates the state of the routine for the next tick. This fulfills both design constraints:<p>1. Because routines are just blocks, they weigh in at about ~345 bytes of memory overhead.<p>2. Routine behavior is explicit because it is written as a state machine inside the block.<p>Couple more features worth noting:<p>* Goru includes channels for buffered reading&#x2F;writing (similar to channels in Go).<p>* Goru ships with primitives for non-blocking IO to easily build things like http servers.<p>Curious your thoughts!

2 条评论

bhu1st大约 2 年前
Language difference : Goru (गोरु) means an Ox in Nepali language.
Alifatisk大约 2 年前
Very cool project, I&#x27;ll keep an eye on this.