Live data from Hacker News

Pony – High-Performance Safe Actor Programming

ponylang.io

131–140 of 159 posts

Re: Pony – High-Performance Safe Actor Programming

#131

Anyone know the judgement rules behind the interesting parts of Pony's type system? I'm about to crack the dissertation to see what's up but would love a concise description. https://www.ponylang.io/media/papers/a_prinicipled_design_of...

I took a stab at it, seems everything is indexed by capabilities which makes sense. There is "Equivalence of ephemeral capabilities" for ephemeral indexing outside of iso and turn. There is "Compatible capabilities with ephemeral modifiers" which shows ephemeral indexing does not matter for compatibility. This is extended to types with "Compatible types" then "define the aliasing operator +, to give us the minimum co…

Basically unaliasing distinguishes the cases:

* I have `iso^` because consumed the last reference to an `iso`, so this value can be sent anywhere or renamed

* I have `iso` because I've just evaluated a living reference to an `iso` object, so I can access fields and methods (with automatic receiver recovery) but can't move it anywhere

Unaliasing with `consume` is what produces `iso^`

Re: Pony – High-Performance Safe Actor Programming

#132

Earlier quoted context omitted.

Pony does not prevent race conditions. Two actors can wait forever for the other to send a message, deadlocking.

I didn’t say that Pony prevents race conditions. I agree that Pony (nor indeed any language) prevents race conditions.

I misread then. Though you did ironically just say that pony does prevent race conditions :P

Re: Pony – High-Performance Safe Actor Programming

#133
post #116

Earlier quoted context omitted.

Are they really "escape hatches"? Shared mutable state is as simple as `Rc::new(RefCell::new(x))`, or `Arc::new(Mutex::new(x))` for thread safety.

`Arc >` is not a shared mutable state. You cannot have two mutable reference at the same time. To mutate stuff inside the mutex, you got to hold the mutex, which guarantees that there are only one mutable reference at any given moment. `RefCell` is one "escape hatches".

Worth noting that RefCell still enforces single-mutable-reference, it just does so at runtime. It lets you do things that could never be verified statically, but if you ever actually violate the condition, you'll get a panic (which is still better than memory unsafety).

Re: Pony – High-Performance Safe Actor Programming

#135
post #94

Earlier quoted context omitted.

Rust is essentially C++ with restrictions that make threads safer. Pony is a completely new language based on the actor model where "threading" is a first-class operation and the type system is formally designed to make guarantees that make threads safer. Pony really wants you to think differently about your problem and solution.

While Pony is awesome, I think what you describe is a weakness and not a strength. If Pony were to move more of its hardest concepts to standard libraries, it would be a far simpler language, even if it maintained the actor/behavior concepts. Much of Pony can be done with Arc/Mutex/&/move in Rust, but with special syntax, and it's that special syntax that kills the language frankly. You can implement actors in Rust p…

The "move the hard parts to standard libraries" approach is exactly the approach Elixir and Erlang take. The OTP (the standard library for Erlang, and called seamlessly from Elixir) provides abstractions for almost every use case you'll ever need. It's super easy to write Elixir/Erlang without ever righting an explicit "receive" statement.

Re: Pony – High-Performance Safe Actor Programming

#136
post #61
post #57

Earlier quoted context omitted.

I am not an expert in Rust's mechanics and only looked at it superficially, but I got the impression that shared references can't be guaranteed (to not exist in mutable ways) all the way through an object graph. I am not surprised if I am wrong about that. It wasn't the main deciding factor for me... My primary factor was "Actor Model" and I was struggling with Erlang's lack of static types, so that put Pony in the f…

What issues did you run into on the JVM with Java/Scala? I spent 5 years working up and down the entire akka stack so I'm curious to learn from your point of view. Also did you try akka typed or classic?

I'm not the parent poster but I'll have a go. Please feel free to correct me if I've got parts wrong, I'm hoping to learn something too.

In other languages, lets say Erlang as an example, actors themselves do not have concurrency concerns. The receive loop/handler just executes everything as though it's single threaded. The code is very easy to reason about. It also applies backpressure in that if your synchronous loop is blocked, your mailbox will fill up.

If you need concurrency, it's done by talking to other actors, which can be processing on another thread under the hood. But the thread part of it is managed and you are not dealing with threads per se, you just know that if you have multiple cores and you send a message to another actor, it can be scheduled to run on another core safely.

If you want to run a bunch of tasks in parallel, you could use a pool of actors up to around the number of cores you have, and the parallelism is at maximum the number of actors in the pool.

Sorry if i'm over explaining, I just wanted to set the stage.

One of the benefits of this arrangement is if something is going slowly you can order the list of actors by biggest mailbox and you can see where your bottleneck is. And if you are using a lot of memory you can just order the actors by the memory usage and you can see where the big state lives.

With akka actors, instead of just dealing with the actors and actor pools, they suggest you make actors non-blocking. The way you do this is with Futures. Suddenly all the simplification of the actor model goes out the window. It mixes an async programming style with an actor model that doesn't need to be async! So you have the negatives of asynchronous programming and very few benefits of the actor model. I realise

How do you identify the bottlenecks of the system? Maybe your execution context is full - actually I'd love to know how people debug their execution contexts in general.

Last I checked, execution contexts would spawn new threads as well, so not only are they heavyweight (compared to erlang processes) but you have the operating system schedule them instead of the thing that knows how to best schedule them which is your language runtime.

Re: Pony – High-Performance Safe Actor Programming

#137
post #128

Earlier quoted context omitted.

I think the tool is probably this one: https://hn.algolia.com/

dang simply remembers all the item?id=N. Which is easy because they're sequential. To make the list, mentally go through the numbers and paste in the urls that are relevant.

That's O(n) sir, not worth it.

Re: Pony – High-Performance Safe Actor Programming

#138
post #45

As a regular Pony user, and coding seriously in it for a few months, this is what I think; I rather fight the Reference Capabilities (easily the hardest aspect of Pony and probably the number one reason people give up) than to spend endless amount of time CHASING concurrency problems, or even worse, HOPING that I didn't forget some lock/mutex/whatever and ending up having data corruption. Pony is forcing me to do the…

From my observation (as a curious non-user), all safe languages seem to include certain escape hatches. They guarantee safety, but if you know what you’re doing there’s always a %FEATURE% that opts you out and allows anything, including shooting yourself in the foot (getting a panic at runtime, etc.).

From your experience with Pony, which escape hatches did you notice? How would a Pony programmer shoot themselves in the foot?

Re: Pony – High-Performance Safe Actor Programming

#139
post #45

As a regular Pony user, and coding seriously in it for a few months, this is what I think; I rather fight the Reference Capabilities (easily the hardest aspect of Pony and probably the number one reason people give up) than to spend endless amount of time CHASING concurrency problems, or even worse, HOPING that I didn't forget some lock/mutex/whatever and ending up having data corruption. Pony is forcing me to do the…

From my observation (as a curious non-user), all safe languages seem to include certain escape hatches. They guarantee safety, but if you know what you’re doing there’s always a %FEATURE% that opts you out and allows anything, including shooting yourself in the foot (getting a panic at runtime, etc.). From your experience with Pony, which escape hatches did you notice? How would a Pony programmer shoot themselves in…

C FFI.
Post reply on HN