3 ms·
> For example, the Pony language is written in C and guarantees no races or deadlocks without using locks or mutexes so it's faster than C with locking. This c
by lalaland1125 6y ago
> For example, the Pony language is written in C and guarantees no races or deadlocks without using locks or mutexes so it's faster than C with locking.
This claim is misleading. The reason why Pony is able to "guarantee" no races or deadlocks is because it doesn't support shared memory concurrency. If you are willing to give up shared memory concurrency in C you can achieve exactly the same performance.
In fact, you often have the opposite: shared memory concurrency (implemented in languages like C) can often offer performance advantages that actor models like Pony can't provide.
- danappelxx 6y agoBut... give an example. When is shared-memory concurrency (with locks) faster?
- lalaland1125 6y agoOne good example would be writing a multi-threaded dictionary compression program. Dictionary compression is quite simple, you simply need to encode a bunch of strings to a series of integers and construct a dictionary that can perform the inverse mapping. The main trick is that you need a shared mutable dictionary to store the current list of string to integer mappings. Doing this with an actor model would be tricky to the point of impossible. Sending a message to the common "dictionary" actor is much, much, much less efficient than just holding the corresponding sharded lock.
- rurban 6y agoThis is wrong. The biggest advantage of Pony is to support pointers into shared memory and still guarantee all 3 safeties. It just doesn't support blocking IO if you need that. And pointers into shared memory have severe limitations, just as in the real world. But the advantage is that the compiler already guarantees safety.