News for hackers. Stuff that matters.
Re:Lockless Algorithms for Mere Mortals by lalaland1125 on Wednesday July 29, 2020 @10:54PM (#23994054)
> 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.

Re:Lockless Algorithms for Mere Mortals by rurban on Thursday July 30, 2020 @07:13AM (#23996808)
This 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.
Re:Lockless Algorithms for Mere Mortals by danappelxx on Thursday July 30, 2020 @03:38AM (#23995615)
But... give an example. When is shared-memory concurrency (with locks) faster?
Re:Lockless Algorithms for Mere Mortals by lalaland1125 on Thursday July 30, 2020 @04:06AM (#23995747)
One 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.