News for hackers. Stuff that matters.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by bluejekyll on Sunday December 15, 2019 @12:03PM (#21797238)
I’m always excited to see people experimenting with different things.

I wonder if the author could comment on how the goals of this project might differ from those of Actix?

Many people are still new to async/await; did you consider add a runtime/executor in your readme example? I didn’t see the creation of a Runtime to drive the futures, that might be a nice thing to show.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by ljph on Sunday December 15, 2019 @12:16PM (#21797361)
Hi mate,

The goal is to eventually have actors spread across multiple servers with automatic load balancing etc. I'm currently working on remote actors, with the goal for the API to be exactly the same whether you're talking to a local actor or a remote actor - it shouldn't matter to the user!

The runtime is just Tokio's runtime, actors are just tasks awaiting on messages (and handling them) from their Receiver!

Cheers!

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by FpUser on Sunday December 15, 2019 @07:46PM (#21800028)
This sort of reminds me of an old agent based Java middleware called Voyager I've encountered sometime in the 90s. The rough idea of this middleware was that you could write Java class derived from a special prototype and the instance of said class can travel around various Voyager servers all over the world to perform tasks on local context and then come back with the answer. Could be used for the whole bunch of scenarios from map reduce to accessing some content that only available at particular place and not accessible by public API. It was neat. Not sure what did happen to this middleware later on.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by nine_k on Sunday December 15, 2019 @11:58PM (#21800904)
Hiding the network layer is often problematic.

Networks are much less reliable or predictable than a PCI or SATA bus. You have to honesty handle timeouts, unavailability, retries at the very least.

Hiding this from the user is usually a bad idea. An intelligent handling layer does help, but it cannot e.g. entirely mask unavailability.

So the common interface would have to be the handling-it-all interface, likely as a number if separate traits.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by PudgePacket on Sunday December 15, 2019 @07:24PM (#21799932)
Have you heard of Citybound? The author has implemented something similar for the simulation of the units in a multiplayer scenario. Cars/houses/people are all actors and can be simulated on any computer in the game and it all just magically works.

They have a talk somewhere where they explain it and do a live demo, pretty neat stuff :)

https://aeplay.org/citybound

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by bluejekyll on Sunday December 15, 2019 @12:42PM (#21797550)
Ah. Cool. What are your plans around data serialization and compatibility of different nodes during version upgrade?

And thanks for the answer!

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by ljph on Sunday December 15, 2019 @12:50PM (#21797619)
Regarding data serialization, I'm currently using serde_json, however that's just because it's easy to work with for development/testing purposes though I do love the idea of using protobufs!

Node compatibility and I guess distribution overall are problems I'm extremely looking forward to tackling! :)

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by leeoniya on Sunday December 15, 2019 @01:12PM (#21797784)
> though I do love the idea of using protobufs!

or FlatBuffers!

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by samcodes on Sunday December 15, 2019 @01:49PM (#21798026)
Not sure on rust compatibility, but have you considered Cap’n Proto? https://capnproto.org/
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by aseipp on Sunday December 15, 2019 @02:46PM (#21798479)
Cap'n Proto has good a good Rust library, but it's overall language support versus alternative formats is somewhat lacking, unfortunately.

That said, Cap'n Proto has a substantially better design (both in theory and implementation) than any of the alternatives IMO, so it's worth using anyway if your language supports it well. And especially so if you're using it "internally", so other language clients aren't as big of a deal.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by steveklabnik on Sunday December 15, 2019 @02:07PM (#21798181)
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by sagichmal on Sunday December 15, 2019 @05:24PM (#21799394)
Are you familiar with CORBA?
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by vertexclique on Sunday December 15, 2019 @12:18PM (#21797374)
Worth to mention that Bastion has been developed a lot and it has its own design(in simple terms SMP based executor) to leverage asynchronous programming (with fault-tolerant manner). It isn't dependent on any runtime. You can mix and use any runtime with it and supplies hierarchical reduction based concurrency.

We proudly take Erlang's runtime model and implemented it in Rust. Moreover, we are currently working on distributed carrier protocol to make Bastion form a cluster, exchange data and recover from partial failures in distributed workloads too.

Local failures are recovered and we have built-in lifecycle management.

Maybe after these words you might want to take a look: https://github.com/bastion-rs/bastion

You can write a fully fault-tolerant program with our macro mechanisms too: https://github.com/bastion-rs/fort

Here our distributed protocol repository: https://github.com/bastion-rs/artillery

And our landing page: https://bastion.rs/

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by detaro on Sunday December 15, 2019 @03:58PM (#21798930)
Not engaging at all with the thing shown and just talking about yours, without any comparison, seems fairly rude on a Show HN.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by threatofrain on Sunday December 15, 2019 @10:08PM (#21800538)
Rude to the users? Because users win when they see interesting competitors.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by Dowwie on Sunday December 15, 2019 @03:56PM (#21798919)
What are your thoughts about the project that you sidelined-- Coerce? That is what brought people here in the first place and the project deserves recognition.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by asdkhadsj on Sunday December 15, 2019 @01:12PM (#21797782)
I'm not familiar with this family of technology, so forgive the dumb question:

But.. what is this?

I read the landing page and browsed a couple examples and I have no clue what I would use it for.

Would it be a pile of distributed workers handling jobs? Sort of like pushing a job into a job queue and having a bunch of workers consume jobs?

If that's the case, what are some reasons I might choose this Bastion model over a more traditional JobQueue <-> Worker model?

Thanks to any replies. I feel I should be interested, but I'm confused :)

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by vertexclique on Sunday December 15, 2019 @01:23PM (#21797845)
As landing page states it is a runtime supplies actor-model like concurrency. If you are familiar with Erlang. Bastion is the reflection of the Erlang runtime in Rust. Far beyond an actor system implementation. It is a complete system with full asynchronous communication.

"...It supplies actor-model-like concurrency with a lightweight process implementation and utilizes all of the system resources efficiently guaranteeing of at-most-once message delivery."

It might be a single process, pile of workers, a bunch of http servers dispatching requests, various middleware layers connected with asynchronous boundaries. With all these built on top of crash and fault recovery.

For more information what it provides please take a look to my latest presentation at Rust Berlin: https://slides.com/vertexclique/crash-course-with-bastion#/

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by ProfHewitt on Sunday December 15, 2019 @02:10PM (#21798201)
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by mmastrac on Sunday December 15, 2019 @06:01PM (#21799582)
This is pretty cool. We ended up building our own version of something like this internally last year, but I could see us tossing our code in favour of this.

The big advantage to writing code this way is that you just don't need to write these actors thread-safe. They will only ever handle a single message at a time. For an async system it's really fast to get something up and running.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by staticassertion on Sunday December 15, 2019 @12:20PM (#21797385)
Nice. I tried building an actor library in rust, using proc macros. It ended up being super annoying to deal with generic actors.

Maybe I'll just write a proc macro over this lib instead.

* https://github.com/insanitybit/derive_aktor

edit: Is this not on crates-io?

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by ljph on Sunday December 15, 2019 @01:56PM (#21798094)
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by staticassertion on Sunday December 15, 2019 @04:05PM (#21798973)
Thanks.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by windor on Friday December 20, 2019 @04:32AM (#21842795)
Read through the code just now.Thanks for the small but powerful project,I have tried to make something similar, but failed. The lib is very close to what I want to do actor-based programming in Rust. It would be great if actor can send message to itself.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by xiphias2 on Sunday December 15, 2019 @11:37AM (#21797051)
Isn't async-std interface the future of async at this point?

It seems that there's still a huge split inside the community between async-std and tokio interfaces that should be resolved ASAP.

Is there some working group to help standardizing the interfaces and upgrade tokio based apps to the standard?

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by swsieber on Sunday December 15, 2019 @11:41AM (#21797072)
No, it's not the standard.

There has been some friction between the two groups (tokio and async-std) unfortunately.

I'm not sure what the original source of friction was, but bad feelings seem to seep out when the projects are discussed in active Rust communities. I wonder how long the drama will go on. But at least both parties seem to be trying to be civil about it (and succeed).

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by bluejekyll on Sunday December 15, 2019 @11:55AM (#21797176)
Folio => Tokio
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by estebank on Sunday December 15, 2019 @01:25PM (#21797858)
Now that is another nice name in search of an async/await project.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by swsieber on Sunday December 15, 2019 @12:00PM (#21797222)
Argh. Thank you. I caught that autocorrect once but then reworded things.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by oconnor663 on Sunday December 15, 2019 @11:53AM (#21797162)
> should be resolved ASAP

I'm not sure having multiple runtimes is such a problem. The Rust async IO model was explicitly designed to accommodate different runtimes. There are a lot of tradeoffs around how a runtime does multi-threading, for example, and embedded systems may also do their own thing. Tokio vs async-std might or might not make sense as a long term split, but I think it's too early to say.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by xiphias2 on Sunday December 15, 2019 @12:03PM (#21797239)
I think the main clash was not about runtime differences but about the interface incompatibility (futures.rs)

There's a bug for it in Tokio, but it's low priority as far as I know.

https://github.com/tokio-rs/tokio/issues/1297

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by steveklabnik on Sunday December 15, 2019 @12:20PM (#21797383)
It's not particularly low priority https://github.com/tokio-rs/tokio/pull/1744

(See the last section in particular)

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by twic on Sunday December 15, 2019 @04:17PM (#21799052)
This is a great thread! Lots of different perspectives on a difficult technical problem, plus appearances from many of my favourite Rust characters: we've got Ralf telling everyone that only abstract machines exist, boats turning up halfway through to contradict everyone, and Douman dropping by to offer the unhelpful C++ perspective.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by xiphias2 on Sunday December 15, 2019 @12:54PM (#21797648)
Oh, so there's a pull request that I didn't see, the bugs don't show that it's being worked on.

I understand that there are lots of hard technical issues to be resolved, it's just the visibility of this pull request wasn't that good.

Thanks for the answer!

Very interesting thread.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by Argorak on Sunday December 15, 2019 @12:44PM (#21797570)
> I think the main clash was not about runtime differences but about the interface incompatibility (futures.rs)

There is a huge amount of complaints just fundamentally about async-std's existence, though.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by Argorak on Sunday December 15, 2019 @12:39PM (#21797521)
The position of the async-std project is that people should use _futures-rs_ as the integration point and avoid integrating into tokio or async-std if possible. (both are IO optimised)

Especially for things like an actor system, I would recommend to not use either, but instead spawn a dedicated number of threads handling the actors. This allows you to be specifically optimised to the problem. bastion is a great example for that.

async-std ships a second library called "async-task", which implements just the task/future allocation component and allows you to quickly implement your own runtime.

Full disclosure: I'm one of async-std's maintainers.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by xiphias2 on Sunday December 15, 2019 @12:48PM (#21797600)
I understand this, but it still doesn't answer the main point: are you working together with tokio maintainers to move to futures-rs as soon as possible and even extend the interface of futures-rs more if needed?

In my view the separate interfaces increase the long term damage that new libraries are creating every day, and it should be higher priority to resolve it together before implementing new features in either of the two libraries (async-std and tokio).

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by Argorak on Sunday December 15, 2019 @01:02PM (#21797712)
We don't maintain futures-rs. But for the reasons you outline above (stability), our interface is also effectively done.

The choice of not using all of futures for their interface is outspoken the strategy of tokio. We have encouraged them to prefer the futures layers, but we don't see the work happening.

So, to answer your question: we are not working with them, the place of collaboration is futures-rs.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by ComputerGuru on Sunday December 15, 2019 @01:00PM (#21797697)
I have heard that using the async-std APIs (but not the reactor and executor) causes background futures to be spawned to the async-std specific executor. I’m not sure of the veracity of this claim, can you comment?
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by Argorak on Sunday December 15, 2019 @01:08PM (#21797761)
Sooo... in standard profile, yes. `async_std::spawn` uses async-stds runtime. Also, our io interfaces (TcpListener, etc.) are effectively bound to our runtime (they need our mio instance in the back).

But this cannot made work generically in the current ecosystem, as there are no common abstractions here. We can't come up with those unless we have buy-in from other players.

For applications, that doesn't really matter: you pick one Listener type and you're done. Applications aren't very generic.

For libraries, that's harder, but there's strategies around that make it feasible to work with this situation (mainly: injecting the exact type to use into your library).

Finally: there's a flag in async-std called "runtime". If you turn it off, you can use async-std without that behaviour, at the cost of having to bring your own runtime.

Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by ComputerGuru on Sunday December 15, 2019 @01:35PM (#21797923)
Thank you. I’m mainly concerned with library development, so I found your answer helpful.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by Argorak on Sunday December 15, 2019 @01:43PM (#21797988)
We're working on the rest :). Look out for some announcements in the coming days and weeks.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by mamcx on Sunday December 15, 2019 @02:14PM (#21798238)
Let me derail a little: Which one is better to have a coroutine like experience?
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by Argorak on Sunday December 15, 2019 @04:45PM (#21799206)
None, I would suggest pushing on the stabilisation of generators ;).
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by mamcx on Sunday December 15, 2019 @07:40PM (#21799998)
Yeah, but it look like is still far away :(
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by zozbot234 on Sunday December 15, 2019 @11:49AM (#21797129)
There's nothing "standard" about async-std as of yet. The name is because it tries to build something that can be used just like std library facilities, except for the async support.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by Argorak on Sunday December 15, 2019 @12:46PM (#21797586)
You are right, but I also want to point out that we fully buy into the futures-rs interface over custom implementations.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by Dowwie on Sunday December 15, 2019 @04:09PM (#21799001)
Why should it be resolved ASAP? This mentality that there should be no more than one viable solution to address a need is what needs resolving. Rust would not even exist if enough people agreed with that sentiment.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by artfulhippo on Sunday December 15, 2019 @11:16AM (#21796931)
Cool. And good thing you open sourced it now, before you built failover strategies (e.g. supervision) — you still have time to change the name.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by tunesmith on Sunday December 15, 2019 @07:14PM (#21799891)
Coerce is often misused to imply encouragement or persuasion - but it specifically means to engage the efforts of others through violence or threat of violence. It's an ugly word.
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by bvelica on Sunday December 15, 2019 @12:00PM (#21797218)
Ok, for the uninitiated (i m still learning rust) why do we have this split? Thank you!
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by steveklabnik on Sunday December 15, 2019 @12:18PM (#21797369)
Which split are you talking about?
Re:Show HN: Coerce – Actor runtime for Rust using async/awai... by paulddraper on Sunday December 15, 2019 @10:52PM (#21800675)
I'm guessing async-std and tokio.