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.

Asynchronous IO in Rust

160 pointsby nercuryover 9 years ago

5 comments

jerfover 9 years ago
If you use threads, green or otherwise, you don&#x27;t have to &quot;implement&quot; special code for composing things together, you get the full set of tools for composing code together, which includes, in passing, state machines, among all the other things it includes. This basically implements an Inner Platform Effect of an internal data-based language for concurrency that the language interprets, which will A: forever be weaker than the exterior language (such is the nature of the Inner Platform Effect) and B: require a lot of work that is essentially duplicating program control flow and all sorts of other things the exterior language already has.<p>There are some programming languages that have sufficiently impoverished semantics that this is their best effort that they can make towards concurrency.<p>But this is <i>Rust</i>. It&#x27;s the language that fixes all the reasons to be afraid of threading in the first place. What&#x27;s actually <i>wrong</i> with threads here? This isn&#x27;t Java. And having written network servers with pretty much every abstraction so much as mentioned in the article, green threads are a <i>dream</i> for writing network servers. You can hardly believe how much accidental complexity you&#x27;re fighting with every day in non-threaded solutions until you try something like Erlang or Go. Rust could be something that I mention in the same breath for network servers. But not with this approach.<p>There&#x27;s plenty to debate in this post and I don&#x27;t expect to go unchallenged. But I would remind repliers that we are <i>explicitly</i> in a Rust context. We must talk about <i>Rust</i> here, not 1998-C++. What&#x27;s so wrong with <i>Rust</i> threads, excepting perhaps them being heavyweight? (Far better to solve that problem directly.)
评论 #10229436 未加载
评论 #10231393 未加载
评论 #10230080 未加载
评论 #10230155 未加载
评论 #10231094 未加载
ameliusover 9 years ago
It would be much nicer to use coroutines instead of state machines. This means that you could write code as if it were doing i&#x2F;o in a &quot;blocking&quot; fashion, but behind the scenes it is actually asynchronous.
mtanskiover 9 years ago
I think a lot of folks think of Network IO when they say Asynchronous IO. That&#x27;s only half the story, unless you&#x27;re just building proxies and caches you have to deal with Disk IO at some point in time. And, async disk IO is horrible in every OS &#x2F; language.
评论 #10232364 未加载
评论 #10231660 未加载
评论 #10231879 未加载
vvandersover 9 years ago
Really awesome stuff, great example of how well composability works with traits and the nice handling that tagged unions bring to state machines.
geertjover 9 years ago
This is identical to the Protocol abstraction in Python&#x27;s asyncio, right?