What are the chances to bake actor model into compiler?

Hi,

As it's proven by the Pony language https://www.ponylang.io/media/papers/fast-cheap-with-proof.pdf understanding actors at compiler level can unlock a possibility to write data-race free applications.
It's the same thing that Rust did with memory management, but for concurrent programming.

Do you think that there is a chance that this model can be adopted by Rust?

What's needed, specifically?

So far a lot of things that are built into other languages have been implemented as libraries in Rust, with minimal or no help from the compiler.

1 Like

The compiler understands Send and Sync, and libraries like rayon get thread safety using those constraints.

This has been a design goal of rust since pre-1.0!

Rust doesn't employ an actor-specific pattern, but as @cuviper stated, it does guarantee no data races. It uses Send and Sync marker traits to do this, and ensures all multithreaded rust programs, including actor-based ones and non-actor-based ones are free from data races.

See How Rust Achieves Thread Safety - In Pursuit of Laziness for more information on how this works, and Races - The Rustonomicon for the technical description (rust doesn't prevent race conditions, only data races).


Regardless of that, it seems like this could be applicable to actor systems implemented in rust (possibly manipulating generics with Send and Sync to implement entirely as a library). I haven't read through the whole paper, but I'm looking forward to doing that in time - thanks for linking it here!

2 Likes

Thanks for your interest.
I understand that everything has to have it's time and place, otherwise it won't be possible to build anything.
Hopefully adding higher-level abstractions that community can leverage on will allow to build network applications with ease for a bigger amount of people (esp. for such simple heads as I am :slight_smile: ).

Glad to help!

If you are interested in using actors in rust, https://actix.rs/ is the biggest & most mature actor system, and it offers these same guarantees. It isn't baked into the compiler, but as mentioned, it doesn't need to be.

It's not 1.0 yet, but it's quite usable and a decently well designed system. I've written a web server in actix-web and found it a pleasent experience.

1 Like