4 ms·
Thanks for your answer. > Pony forces you to think about how objects can be accessed from different actors, which can sometimes make it hard to do things that
by erokar 9y ago
Thanks for your answer.
> Pony forces you to think about how objects can be accessed from different actors, which can sometimes make it hard to do things that seem like they would be simple, especially if you are new to the language.
Can you write single-threaded code in Pony without doing this, or do you have to do it regardless? The former would seem like a form of premature optimization.
- spooneybarger 9y agoPony is an actor based language. You have to have at least one actor. Effectively, the answer is no. You could write "single-threaded" Pony code but it's not something you would do. Pony is designed to make something hard- writing efficient, safe, concurrent code- easy. Anything you make something that is hard easier, you are invariably going to make some other things less easy, perhaps even difficult.
- aturley 9y agoYou can mostly do this by making all of your objects "ref", meaning you can have multiple readers and writers but you can't share the objects between actors. However, you can run into multithreading quickly because so much of the system is built on top of actors. For example, you can have a mutable (ref) string, but you can't easily print it out because the stdout stream is managed by an actor and you can't send a ref object to another actor. Once you get used to reference capabilities they aren't really a big deal, but it can be hard at first, especially if you aren't thinking about your program executing thing concurrently. Even after years of programming, most people (myself included) still instinctively think of concurrently executing code as the exceptional case, rather than as the common case. Pony makes it easy to write concurrent programs, but it makes you be explicit about how to do it safely. So I guess I see it less as a premature optimization and more as a different way of thinking about problems.