11 ms·
In Defense of Async: Function Colors Are Rusty
- bruce343434 5y agoWhat I don't understand is why these functions must be declared async at the function declaration site. Why not allow the programmer to run any expression asynchronously, which wraps the return value of the expression in a future or promise or what have you? let promise = async {something+someother();}; // other computations let result = await promise; You'd essentially be creating a very ergonomical shortcut to fork-join multithreading which is infinitely more powerful and expressive than whatever this "async function" stuff is. ETA: perhaps it would be a good idea to have a thread-unsafe keyword, though I'm not sure if rust needs that since rust has a really stringent resource pointer/reference aliasing guarantee. ETA2: I misunderstood async semantics for rust, it's not a fork/join but send/poll. In any case, I still think you should be able to declare async at the call site, not the function site. That doesn't seem to clash.
- wizzwizz4 5y ago> You'd essentially be creating a very ergonomical shortcut to fork-join multithreading which is infinitely more powerful and expressive than whatever this "async function" stuff is. But that would require starting other threads, which requires everything to be `Send + Sync`, has the overhead of multithreading, and can't be managed with any sort of scheduler (without platform-specific hacks). Unless you use green threads, and that's discussed in the article.
- bruce343434 5y agoSo what then is async? If there is no scheduling/preemption in executing an "async" function, it's not really "async", but rather synchronous. Is async just a new way to say "instruction reordering"? Or is async really just "*defer* until the last possible moment: await"? edit to match yours: not sure what a "green" thread is. In any case, if threads are not an option, an async may always be ignorable, after all, a program may not rely on the order of the execution of its threads/its preemption; that would be a race condition. Textbook definition. As I see it, the fork/join model is very useful for "shingling" code paths that don't have to happen in sequence, but _could_ happen in parallel. Final edit: nothing is otherwise stopping the implementer of async to add a pre-started threadpool to the runtime, with whatever configurable parameters one would want. Post final edit: I think fork/join vs send/sync are just implementation details. But I respect Rust for going with send/sync, just that it doesn't change all that much in terms of the programming interface.
- AndrewDucker 5y agoAsync is running many tasks on many less threads, using polling. See https://rust-lang.github.io/async-book/01_getting_started/02_why_async.html https://rust-lang.github.io/async-book/01_getting_started/02...
- steveklabnik 5y ago(but note that this doesn't mean busy-loop polling, while that will be used in "my first executor" tutorials, production executors don't call a future until it's ready to have more progress made via an event, often from an epoll/kqueue/iocp or similar mechanism.)
- bruce343434 5y agothis sounds like a lot of overhead, though
- DenseComet 5y agoRather, Rust just makes this overhead explicit. Go, Node, etc do the same thing, but just hide what actually happens.
- Groxx 5y agoIt is, relative to not doing it. But it's quite a lot less overhead than a native thread.
- chmod775 5y agoAs opposed to what?
- monocasa 5y agoIt's "compile this as a state machine such that when other futures are waited on internally by this function, store stack state in an anonymous struct that implements Future + Poll, and allow repumping when that Poll implemention says it's ready. This allows you to reuse the same stack when this async function is blocked"
- jayd16 5y agoWrapping sync in async is usually not so hard but usually an anti-pattern. In C# for example, if that synchronous work is long running, it might consume a thread in the shared thread pool and have side effects (starvation) elsewhere in the application.
- bruce343434 5y agoI don't understand what you mean. What is to say that an async-fn is not long running? It can just as well consume a thread, right?
- lijogdfljk 5y agoI may not follow you - but to expand what _(i believe)_ the GP comment said; any long running code - say a loop that spins for an hour, is bad in the async context, because that async thread is part of the runtime. Better to take those special cases and let the executor move the computation to a dedicated thread. At my work i mix a lot of compute heavy work in an async context, and if i let this compute heavy stuff run on my async threads i'd potentially starve my runtime. Tasks wouldn't get woken up on time, etc.
- bruce343434 5y agoright, but this isn't an argument against allowing arbitrary async expressions. I can make an async-fn that runs an infinite loop just as easy.
- lijogdfljk 5y agoThat's the point though - anything blocking the async thread is bad. If your loop is going to run for an hour, you'd put arbitrary yield points in it so that the executor can reliably call other tasks
- jayd16 5y agoWell I can only speak to C# really but... The preferred pattern is to avoid long running tasks in the default thread pool as it's a shared resource. Long running tasks should be executed somewhere else, either some new thread pool or just a new thread or just don't use async and make it your caller's problem. The point is that you don't want to consume the limited shared resource. In your case, what would happen? Would a new thread be created? Is it ok to use the default pool? Did the synchronous method writer even consider this? It's hard to say. Now, does this need to be enforced by the language? No. Developers could simply append "_Async" to make it clear a method can be put on the default thread pool or not. That's still a form a coloring though. Even if you consider it a choice by the caller, it's still a color that needs to be determined and you never want to exhaust your default thread pool. That said, there are other reasons why calling an async method should have different semantics than calling a normal sync method. Just saying that the "can use shared threads" aspect of async methods can probably live as a convention.
- deleted 5y ago[deleted]
- throw10920 5y ago> I still think you should be able to declare async at the call site, not the function site This is the big point. I'd love to see anyone put forth a concrete, valid reason why this couldn't be implemented, because as it stands, it appears that the function coloring problem is exclusively due to poor language design, rather than a technical limitation (where an example of a technical limitation would be escape analysis, which is hard).
- henrydark 5y agoI think the CPS attempt in Nim could do this https://github.com/nim-works/cps https://github.com/nim-works/cps
- jayd16 5y agoExplicit await and promise semantics are useful incase you want to, say, start multiple async calls instead of awaiting one and then the other. But ok, lets say you just want await to be implicit in some cases... Do you actually want this? Currently, you can assume that a function will not change threads mid execution, and that that thread will also not be used to execute other things. Implicit yielding breaks that assumption. Cooperative multithreading becomes impossible because it's much hard to reason about when a method call will yield execution or not.
- throw10920 5y agoI wasn't proposing implicit async/await. I was proposing declaring those at the call site, instead of per function declaration.
- Rusky 5y agoIronically escape analysis is the one thing Rust went above and beyond to solve in a novel way.
- throw10920 5y agoNo, Rust did not solve escape analysis - it was designed to constrain valid programs to those for which escape analysis is trivial (as evidenced by unsafe Rust, which doesn't have those constraints, and yet has nothing else enabling escape analysis). That's like saying that "C solved type inference" - no, it just constrained you to write your types by hand, and then did some checking of them afterward.
- remram 5y agoThis is possible pretty much with the syntax you wrote: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=da3b001b18caae2c91eaf4503c767d5b https://play.rust-lang.org/?version=stable&mode=debug&editio... Of course you need a runtime to drive that future forward, so it's more: let result = runtime.block_on(future); [edit: or if main() is async, I'm not sure if that's what you want to avoid: `let result = future.await;` https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=715b7fe32cf73132803237899d65afcc https://play.rust-lang.org/?version=stable&mode=debug&editio...]
- Rusky 5y agoThe reason to mark a function as async (in today's Rust) is that you want to `await` something within it. If a function does this, it must be async- there's no other way to implement it. If a function does not do this, there is no reason to make it async in the first place- it will never suspend. (Things get uglier when it may or may not need to await something, e.g. if it accepts a closure parameter. Rust doesn't really handle this today, but one approach would be to make the function polymorphic over async-ness- this is similar to but not really the same as what it sounds like you're talking about.) Async functions are for language-level cooperative multitasking, not concurrency per se. The difference between fork/join (what you imagined async to be) and what it actually is, is more than an implementation detail- it's a semantic change to how the program behaves. If you want to make something happen in the background at the call site, there are already ways to do that, they're just not spelled "async fn."
- ridiculous_fish 5y agoBut what's the difference between an async function returning int, and a function returning `impl Future<int>`? If there's no difference why do we need the async keyword? Other parts of the language are conditioned on the return type. For example the ? operator only works if the return type is Option or Result. It seems like `await` could inspect the return type in the same way.
- kibwen 5y ago> But what's the difference between an async function returning int, and a function returning `impl Future<int>`? If there's no difference why do we need the async keyword? No difference, but while the feature was being explored early users found it simpler if they didn't need to think about lifetimes on the returned future. Sometimes sugar is just sugar; same reason that `for` loops exist instead of just using `while`.
- steveklabnik 5y agoYou can't await inside of a function returning impl Future<Int>. (You can inside an async block inside one, but there you go with language-level support again.) You need the collaboration with the compiler to make it all work well. And that means keywords and language-level infrastructure. We tried no sugar, and it was rough: http://aturon.github.io/tech/2018/04/24/async-borrowing/ http://aturon.github.io/tech/2018/04/24/async-borrowing/ (And a proc macro didn't work out either)
- ridiculous_fish 5y agoThe answer is actually pretty dumb: functions are declared async at the declaration site because that's how C# supported legacy code. Introducing a new keyword is a breaking change because existing code may have a variable with the same name. So `await` is a conditional keyword in C#, conditioned on whether the function is marked `async`. And other languages have since just copied that choice. https://dotnetfiddle.net/JUE0Sy https://dotnetfiddle.net/JUE0Sy
- kibwen 5y agoThat may have been C#'s rationale, but it wasn't Rust's rationale. Rust doesn't even strictly require the `async` keyword in a signature to define functions that work with `await`; `await` works by polling a future, and `async fn` is just sugar for defining a function that returns a future. In fact Rust does precisely what the parent suggests, and also offers `async {}` blocks as sugar for defining inline futures: fn bar() -> impl Future<Output = u8> { async { let x: u8 = foo().await; x + 5 } }
- ridiculous_fish 5y agoNeat, I didn't know about the `async {}` feature. I think it's obvious that Rust chose `async fn` for familiarity with other languages. As you say `async` is just sugar on the return type, so logically it should decorate that type, not the fn keyword. "async fn" is even misleading since the function itself returns synchronously (and immediately): it's the returned value where the async-ness lies. So I think Rust's use and placement of `async` is for familiarity, which traces back to C#'s original choice. Not to say that's a bad rationale. Admittedly I didn't follow any of the Rust async design discussions so I could be completely wrong about all of it.
- Rusky 5y ago> "async fn" is even misleading since the function itself returns synchronously (and immediately): it's the returned value where the async-ness lies. You've got the causality backwards- it's the async-ness that causes it to return immediately. Async is primarily about the execution model of the entire function, and the return type is only changed in service of that model. The course of the design discussions started without async or await, using library-based Future combinators. Async was introduced as a way to desugar control flow and move knowledge of Futures into the compiler for borrow checking reasons, not out of any intention to mimic C#.
- wizzwizz4 5y ago> In both these cases, it’s like the meaning of having one statement come after another has changed: ; itself has been overriden. I don't agree with this analogy. With Result, it's ?; – with async, it's .await; . That's not overriding or overloading; it's explicit.
- jeff-davis 5y agoMy complaint about the async rust world isn't so much function coloring, but dependency craziness. For instance, the postgres driver for rust (which is an excellent driver, by the way), is built in on async primitives. That's a good thing, because it means that it can be used effectively from async code. Unfortunately, a "hello world" program that uses the client takes 38s to build and downloads 65 dependencies, many of which are at 0.x.y versions and I have no idea what they do (parking_lot_core v0.8.5? slab v0.4.5?). This is not just an issue of build time, but overall confidence in the quality and security of the code, and knowledge of who the authors even are. Also, it just adds complexity and magic, and sometimes I just want my code to be simple and tight and understandable from beginning to end. One idea to resolve this is if rust has a standard futures runtime API, and you can just choose one in Cargo.toml or something. By default it would be a built-in single-threaded runtime, but you could choose tokio if you want. If you want to call async code from sync code, there would be an easy way to do it (maybe more syntax?) that would use whatever runtime you chose in Cargo.toml.
- jkarneges 5y agoI typically vet dependencies by doing reverse lookups, e.g.: https://crates.io/crates/slab/reverse_dependencies https://crates.io/crates/slab/reverse_dependencies And then looking into the biggest results and understanding community sentiment. Ultimately you need to trust the authors. Do this enough and you start seeing the same popular projects, making it easier to trust things. > sometimes I just want my code to be simple and tight and understandable from beginning to end I hear ya! This is one reason I wrote my own async runtime, and the output of “cargo build” fits on my screen. :) But I don’t recommend this unless you have a LOT of time.
- lijogdfljk 5y agoYea, i don't really get the distrust of the ecosystem tbh. Yea, i agree the `0.x` stuff is annoying/concerning, but the volume of dependencies feels very.. meh. I use NixOS for example. The number of things i download is _insane_ when i build my system. This isn't a Rust or JavaScript "problem", it's just how natural distribution of work occurs. People build off of the work of their peers. And if you reduce the friction of work distribution, like how NPM and Crates do, you naturally get a lot - sometimes to a comical degree. However are we going to expect crate authors to repeatedly reinvent wheels? Would we trust them if they did?
- jerf 5y agoI wouldn't call the coloring "a good thing". I would call it "an acceptable compromise". It would be better if you didn't have to label it and it all Just Worked, just like it would be better if you didn't have to annotate lifetimes and it all Just Worked, but for the space Rust is operating in, it is an acceptable compromise. Rust sits high on the "force programmer to put more effort in, give programmer more out in return", on a pretty nice cost/benefit tradeoff place in that space. But the fact you get benefits commensurate with the costs doesn't mean it's not a cost at all, and it's probably not good to get into the habit of conflating costs and benefits. Clarity of view of both sides of the balance is very important for engineers.
- jayd16 5y agoWhat would be "just working" in your mind WRT promise, unwrap and thread context semantics? Sugar around thread yield, unwrap and context return? That seems like a lot of possible gotchas to simply be hidden and lurking under every benign looking synchronous method. Remember that the point of async/await is cooperative threading and not pre-emption. Hiding these details makes it much harder to reason about. If you don't know when your execution will be yielded, you're essentially being pre-empted, no?
- gpderetta 5y agoSure, you can be preempted by another thread (or even process) even within an async function, so why should it matter? The borrow checker should still prevent anything bad from happening. I'm not a rust programmer, but personally I think that stackless coroutines are probably a necessary evil in system languages as full stack switching might have too much overhead. But let's stop pretending that it is actually a good thing. Still I think that even with stackless coroutines await should be the default (the async keyword would be used if you explicitly want the promise), which, in addition to better ergonomics, would allow the async-ness of a function to be inferred, possibly as a function of its type parameters. This at the very least would avoid duplicating a lot of functionality.
- jayd16 5y ago
- yccs27 5y agoHere's my (oversimplified) understanding of async: It's functions with yield points, at which other code can be run until execution returns to the function. Then, isn't it almost trivial to call an async function from a synchronous context? Just skip over the yield points?
- jayd16 5y agoIt depends on the context of the yield but assuming the caller and callee contexts can be the same, most async/await implementations will not actually yield until some kind of thread sleep or explicit yield is hit. So yes, this happens in most languages I'm aware of.
- munificent 5y agoI don't agree with the article that the idea of colored functions is tied to dynamic types. I think it applies equally well to Dart, TypeScript, C#, and any other language considering async await. It's mostly a question of usability and the ability to encapsulate use of asynchronous operations. But for Rust, I think having colored functions is probably the right call. Asynchronous operations are fundamentally different at the OS/machine level. Since Rust is a language where code deliberately has very high affinity to what the underlying system is doing, it makes sense to make that distinction visible to users even if it means that it's harder to write and reuse asynchronous code.
- Ericson2314 5y agoThe key part with the "monad" bit at the end is we have monad polymoirphism allready, e.g.. foo :: Monad m => m () in Haskell. If that goes to rust, maybe we can have "async polymorphism". This, and the far more easier "mut polymorphism" (no more as as_mut boilerplate) means we get best of both worlds: color and code reuse!
- necovek 5y agoThis is somewhat covered by other comments, but it's not made explicit enough. Is async-style the best possible tradeoff to achieve the best result when programming with blocking calls? The fact that you should not be applying the same approach to a very similar problem (blocking CPU-bound code) kinda sucks, which means that you need to be employing multiple concurrency approaches in the same program. I am all for syntactic sugar to make concurrency easier and less error prone, but I'd prefer it if the same approach trivially worked for all sorts of concurrent functions without heavy penalties to execution.
- Matthias247 5y agoIt depends on what you mean with „best result“. Async functions in Rust are not about improving ergonomics compared to classical threading. They are strictly worse. They are a tool which can be used to lower the amount of OS threads used by a n application- by multiplexing multiple logical tasks in one thread. Callbacks and state machines are other options for that - but those are even harder to get right. If your application requires that from an efficiency point of view async programming might be a good option. If not threads are fine.
- necovek 5y agoSure, the definition of the "best result" is the question. In short, "the best approach" to me is one that: 1. Is suitable for all sorts of concurrency 2. Has a low memory overhead and low switching costs like the async functions today 3. Is the most "ergonomic" (leading to fewest bugs, easiest debugging and easiest maintenance): yeah, this one is not too well defined either, which is why I would measure developer satisfaction and things like defect rates to establish which one is it, not that this makes it any easier to define :) 4. Provides "enough" safety and encapsulation without impacting performance (much) If 4 has a huge cost, perhaps go with special-cased "async isolated" concurrency primitives when you need added safety in addition to "async", and if the cost is low, allow not paying it anyway with the inverse ("async unsafe"): basically, different defaults depending on what's realistically achievable and nature of the language. I think that ideal lies somewhere near the "non-cooperative multitasking" async programming approach, but I am not sure, and I haven't played with enough recent developments in programming languages either to know if any one of them gets close. But having thought through it a bit with this comment, I think my main gripe is how your (developer's) decision of the concurrency tool (threads, async/await, callbacks, green threads...) affects your syntax simultaneously (eg. why should awaiting a compute-intensive task be problematic? that's an implementation detail a developer should not have to worry about if all else is equal).
- cube2222 5y agoI'm one of the people always critiquing the use of function coloring[0] to do async programming in most languages and defending the Go model as The Way. However, I totally get why Rust chose to go down that path. It's the way to go if you want to have zero-cost abstractions, even if it's a PITA. And since you're programming in Rust, you've already accepted that PITA's in the name of performance and low-level access are occasionally alright. [0]:https://news.ycombinator.com/item?id=27545031 https://news.ycombinator.com/item?id=27545031
- kibwen 5y agoSeconded. If you're shipping a language with a meaty runtime, then save your users the headache and just include built-in support for green threads; your runtime probably already takes care of things like garbage collection and your users are fine with it, so they're unlikely to complain about not being able to squeeze out every last bit of single-threaded performance. But there are certainly niches for languages where users do expect to be able to squeeze out those last drops of performance, and Rust inhabits that niche. Different intended contexts can call for different approaches.
- rastignack 5y agoHowever rust is so hairy that it’s damn slow to develop in. You would expect database engine devs would pick rust to get those last drops of performance. Yet there is no production quality storage engine written in rust, whereas there are several of those in go. Ergonomics matter. Iteration time too. Rust fails hard there.
- klabb3 5y agoMeh. When rust was designed it didn't make a distinction between blocking and non-blocking functions (here, I mean having a syscall which may yield to the OS scheduler, such as `read`). Together with threads, this let users enjoy the traditional kernel-space concurrency model seamlessly. When async got added, this simplification stood in conflict with the new explicit user-space scheduler (reactor-executor in Rust terms). Today, std is a minefield within an async app — your program may deadlock non-deterministically — without as much as a compiler warning. Every project member needs to worry about intricate details of different types of mutices and which std::fs APIs are kosher, and so on. I would have preferred a plug-in system where you could use the same application code with different scheduling backends - threaded by default, the M:N model or even the M:1 model if you're feeling web scale. This way, code reuse would have been a breeze. What we got was a mess of application code where the compatibility matrix (what code is compatible with what runtime) is not clear, enforced or even well documented. Even the proponents of the current model acknowledge that the current ecosystem is fragmented.
- dataangel 5y ago> your program may deadlock non-deterministically This was always true, even prior to async. Rust's thread safety features have never prevented deadlocks. They prevent races, but not deadlocks. RAII makes some patterns that can cause deadlock more avoidable. Nothing in Rust prevents you from spawning a thread that locks a mutex and then never gives it up.
- klabb3 5y agoAh, yes, absolutely! I should have been clear that async caused a fire sale of many more footguns, that didn't exist previously.
- Zababa 5y agoI think at this point the metaphor of "function coloring" has been overused, and we should use the real name: monadic async. The problem is obvious when you look at what a monad is: you have lots of ways in, but no way out. So every monad has to offer their specific way out, if they can. With a Option<T>, you can extract the value inside your function with unwrap. Your function will still be a regular function. With async, you can do the same with await. However, await can only be used inside async functions. That's the trap right there. The way to get out of the async monad is only usable inside the async monad.
- newpavlov 5y agoI have several issues with Rust async and prefer to stay as far from it as possible, but "colors" is not one of them. The article correctly mentions that we can view other function properties, like fallibility, as "colors". For a language like Rust it's important to expose such properties (similarly to how it relies on Result instead of using exceptions) since FSM and sequential code are quite different from each other. If anything, I would say that Rust does not go far enough to expose such properties. I would love to have compiler-enforced properties like "can not not panic", "execution takes bounded time", "uses bounded amount of stack space", "does not use allocations", etc. Some of those properties could've been useful for async code as well and the bounded stack usage is in a certain sense already implicitly part of async. One of my issues is that Rust continues to pile ad hoc solutions, without looking for more fundamental approaches. For example, in the async case, it was rushed in the current form instead of properly solving generators and linear types. Yes, it's probably helped with the language adoption, but it's a short-term win at the expense of the longer-term language health.
- ajuc 5y ago> it's a short-term win at the expense of the longer-term language health. this is how we get the mess that is C++
- dataangel 5y ago> it was rushed in the current form Are you the one withoutboats always chimes in here to correct by pointing out that there was actually tons of discussion and alternative designs evaluated? I seem to remember the last time rust async was discussed here the people who actually worked on the feature being pretty peeved by people claiming this.
- deleted 5y ago[deleted]
- newpavlov 5y agoAlways? If you mean https://news.ycombinator.com/item?id=26406989#26407395 https://news.ycombinator.com/item?id=26406989#26407395, then I don't remember repeating this discussion with him on HN or anywhere else. He took it really personally, so I don't see a point in rehashing it. I stand by my words behind the link and I don't think that I stand "corrected". You can read the HN discussion and github and IRLO discussions linked in it to form your own opinion.
- pkulak 5y agoSeems like a bit of a stretch to say that anything that's part of a method signature is the same as a "color" as it was described in the original article. If a method takes something by value, that doesn't necessarily mean that attribute needs to propagate up the call chain until the literal origin of the process. In fact, in my experience, it _very_ rarely does. Async does, however, always. That's the whole point.
- api 5y agoThe biggest problem with Rust async is the dependency mess. All the different runtimes, with some projects dragging in one and some dragging in another, is crazy. If you aren’t careful you end up with multiple runtimes in the same binary. That is what needs to be fixed more than anything else. As far as the complexity goes: it’s a systems language without a true “fat” runtime like C# or Go. You can’t do the sorts of pretty abstractions you can do in those languages. You can’t hide the details very much. Rust async is syntactic sugar around what would be much more verbose nested callback patterns. It hides that nastiness but you still need to have a mental model of what is actually going on.
- tybit 5y agoI think there’s a good argument that async is decent for performance critical languages, e.g C++ and Rust, and for languages looking to model effects, e.g Haskell and arguably Rust. I don’t see a good reason for it in mainstream languages like Java, JavaScript and C#. I think Java’s approach with Loom is going to be a big win over C# there, as someone that just wants to get stuff done and is a fan of both.
- merb 5y agoI'm not sure if Loom will be successful. It does not fit the ecosystem. Thus a lot of java async stuff needs a lot of rewriting, this can either disrupt the ecosystem or split it. at least on the library level.
- Matthias247 5y agoI actually feel it would be successful because it exactly fits the ecosystem. A lot of Java code is classical threaded code. E.g. the majority of Java servlet code, and older web frameworks. Those would all immediately benefit from Loom in terms of resource utilization and scalability. Of course Java also has some frameworks like Netty and things built on top of it - which won't benefit. But I feel like even though those are great from a performance point of view, they are actually more niche in the overall java world.
- hootbootscoot 5y agotangent: why is the basis of most async functionality a form of polling underneath? Why are interrupts not used? or are they? source: epoll, select(bsd at least), isn't kqueue also like a multiplexed epoll?
- Matthias247 5y agointerrupt-like things are used to schedule the next poll of the function. Polling doesn't happen randomly or within certain time intervals, but when an external event (via a Waker interface) tells the runtime to schedule the function again for polling.
- hootbootscoot 5y agoCall me weird, but I'll take callbacks any day over async await. If it goes too many levels deep, we have to ask what we are trying to achieve and perhaps consider a better approach (a specialized state machine? threads?)
- otabdeveloper4 5y ago> let's just agree to call this insane malpractice "rusty" and it suddenly becomes okay You're not making the case here, guys.
- 8bitsrule 5y agoI'm not a software engineer, but I recall that in the days before abstraction layers there was a tactic called a vectored interrupt. When some device needed attention, it tapped the CPU on the shoulder and got it. I don't understand why nowadays with 4- or more core machines, servicing an interrupt isn't easier. I'm naive enough to think that sounds like an architecture problem.