Pony is an open-source, actor-model, high performance programming language
ponylang.org
ponylang.org
pony-lang devs: put some examples on the home page!
Visually examining a code-snippet that directly communicates the above would be a huge sell!
A few examples to look at
1. Rust - https://www.rust-lang.org/
2. Elixir - http://elixir-lang.org/
3. Go - https://golang.org/
If your program compiles, it won't crash.
There will never be an unhandled exception.
There's no such thing as null, so your program will never try to dereference null.
There will never be a data race.
Your program will never deadlock.
Your code will always be capabilities-secure.
All message passing is causal.> Ownership and Reference Counting [...] We propose Pony-ORCA, a fully concurrent protocol for garbage collection in the actor paradigm
> with shared memory [...] introduces a new form of write uniqueness
> a dedicated actor for the detection of (cyclic) garbage
So, Erlang + shared state? Rust + GC + green threads?
I'm very happy there is activity in this space; I feel like there a whole class of massively online realtime applications just waiting to happen.
5k users first person shooter anyone?
[1] https://github.com/ponylang/ponylang.github.io/tree/master/p...
> Rust + GC + green threads?
I haven't used Pony much yet, but when I first saw it, this was my first connection. In some, but not all, ways, it is like what Rust used to be at a certain moment in its history. The languages have different goals, so it's not like I think this means Rust is better or something.So Pony might be better compared to Erlang with a strong type system and without a blocking receive method than to Rust or Go.
(And I'm thinking about Rust _pre_ ownership model, here. And Rust does have non-blocking IO, just not in the standard library. It's not imcompatible with ownership.)
wget -O - http://releases.ponylang.org/buildbot@lists.ponylang.org.gpg.key | sudo apt-key add -
This is not secure. Non https connections cannot be trusted. It is trivial for a cafe owner to MITM this and now he is generally trusted with your apt-get. BAD.There are a few things I wonder about. From the first page of the tutorial (http://tutorial.ponylang.org/):
> It's exception safe. There are no runtime exceptions. All exceptions have defined semantics, and they are always handled.
This seems contradictory. Are there exceptions or not? EDIT. Apparently there are (http://tutorial.ponylang.org/expressions/exceptions/). But then I don't understand what the above means.
> It's deadlock free. This one is easy, because Pony has no locks at all!
This is nonsense. Deadlock happens when multiple processes/threads are waiting for each other. It is not caused by locks.
From another tutorial page (http://tutorial.ponylang.org/types/static-vs-dynamic/):
> There's no such thing as null, so your program will never try to dereference null.
But there is "None" (http://tutorial.ponylang.org/types/primitives/). How is "None" so different from this "null" that we want to avoid?
On the positive side:
As I said this looks interesting. The type system appears to have been well thought out. Intersections look like a sane way to provide functionality that other PLs either implement poorly (perhaps via "multiple inheritance"), or simply disallow.
And if the type system really does offer all the claimed guarantees, then it is a very good thing indeed.
The partial applications, the concurrency model, and the handling of immutability are also clearly features that someone has given a lot of thought to. I cannot judge the results at this point, but I like well-thought-out things. :-) And the notion of "apply", along with the shortcut syntax, seems like it provides a standard, easy to understand way to make lot of code pretty simple.
I hope to be able to look into this PL more closely in the near future.
> This is nonsense. Deadlock happens when multiple processes/threads are waiting for each other. It is not caused by locks.
Actually deadlocks happen when 2+ resources are not locked in the same order by 2+ processes/threads... As far as I know, in Pony there's no way to send a blocking message to another actor, so there's no lock, so there's no deadlock.
Please correct me if I'm wrong
> A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause.
That is from Modern Operating Systems, 4th ed. (2015), by A.S. Tanenbaum & H. Bos, page 439. (By "process" they really mean "process or thread".)
One way for thread A to wait on thread B is as you said: thread A can request a lock that thread B currently owns; then A waits for B. So requesting locks in opposite orders can result in deadlock. But of course if there are no locks, then no such waiting occurs, and so deadlock from this cause is impossible.
But there are other ways to wait. If var_a and var_b are shared variables, then code like the following might result in deadlock (The following code is in C; to simplify things, I'm assuming that data races and memory-access ordering are not issues.)
Thread A does:
var_a = 1;
while (var_b != 0) ;
var_a = 0;
And thread B does: var_b = 1;
while (var_a != 0) ;
var_b = 0;
If Pony is capable of executing code like the above, then deadlock is possible.Okay, supposing we have a definition of deadlock that agrees with your usage: sure. But then these "other problems" you mention will have exactly the same practical effect as deadlock, right? A program will hang, sometimes unpredictably, based on more or less random decisions made by some low-level scheduling algorithm.
And in that case, Pony's guarantee of no deadlock is (1) completely correct, and (2) completely meaningless, from the point of view of a programmer whose concern is that his code will behave as required.
Am I wrong? EDIT. Maybe: https://news.ycombinator.com/item?id=10903876
> How is `None` so different from this "null" that we want to avoid?
The difference is the defaults. Languages "with null" generally assume that any value can be null. Other languages, like Pony, do not allow any type to be null.Pony's "None" type is an example of a "unit type": a type with only one possible value. It's a totally different thing.
http://tutorial.ponylang.org/pattern-matching/match/#matchin...
I see how it can be used in new and different ways, and is definitely safer, but it's not like the idea of "that thing you want isn't here" goes away by introducing a None type.
EDIT: Sorry, I was thinking of sum vs product here, union types are sum types. So this is the same thing as Option. Sounds good. The advantage of using a union type is that you _have_ to check. This is significantly better than nulls.
(I am 99% sure that's what you mean, but since I already screwed up terms once in this thread...)
Disjoint unions aka sum types (as seen in Haskell/ML etc) entail some runtime way of keeping track which side of the sum any given inhabitant lies on. Tags are one way to do this, but e.g. in a language where pointers/references are never the zero machine word, and unit is represented as the zero word, no tag would be needed for the type Maybe String.
Union types (as seen in Pony, apparently, and also in Typed Racket), by contrast, /don't/ preserve information about which side of the union an inhabitant came from.
So, disjoint types: A + A ≠ A but union types: A ∪ A = A
So expanding (Maybe X) into (X + 1), we have that (Maybe (Maybe X)) = ((X + 1) + 1) ≠ X + 1,
but if instead (Maybe X) expands to (X ∪ 1), we have that (Maybe (Maybe X)) = ((X ∪ 1) ∪ 1) = X ∪ 1 = (Maybe X).
This is one of the problems with uses of null in languages that have it.
> Pony often uses the primitive None to indicate that something has "no value".
So that is not a special value that we can assign to any variable.
"None" would seem to be pretty pointless all by itself, but I guess we could do a union of any old type with "None", to get a result much like Haskell's "Maybe". And then the Pony type system would give us much the same guarantees as Haskell's would; so we get a nullable variable that still allows for typesafe operations -- e.g., dereferencing, if applicable. (I guess ....)
> Of course, it does have a value, so that you can check what it is, and the value is the single instance of None.From the page I linked above:
> var x: (String | None)
> Here we have an example of using a union to express an optional type, where x might be a String, but it also might be None.
That's pretty clearly a Maybe.
EDIT: Ugh, sorry, those are the same, I was thinking of sum vs _product_ type, ignore me.
Rust supports tagged unions, but can also optimize them to untagged in certain circumstances. We will probably add some kind of untagged union as well, mostly for FFI, but they're very unsafe, for the above reasons.
Or to put it more simply: an exception will never crash a program.
> This seems contradictory. Are there exceptions or not? EDIT. Apparently there are (http://tutorial.ponylang.org/expressions/exceptions/). But then I don't understand what the above means.
I think the author is using a terminological Java-ism. In Java, a "runtime exception" (RuntimeException and subclasses) is an exception that doesn't have to be handled, and therefore may be thrown unhandled at runtime. Pony has exceptions, but no unhandled exceptions, i.e. no "runtime exceptions" in Java speak.
So the point is that a program will never crash due to an exception.
But I do see where the claim is coming from. Pony is aimed at the same kind of compile-to-bare-metal that we do with C, C++, Fortran, etc. Furthermore, Pony's design explicitly deals with many of the issues that get in the way of aggressive optimization in other PLs: pointer aliasing, dynamic type checking, data races, etc.
So Pony was clearly designed with high performance in mind. And it seems likely to me that the efforts made in that direction are practical, workable ones.
But that is not the same as saying, "We can write a Pony compiler that generates fast code." And it is certainly not the same as, "We have written a Pony compiler that generates fast code."
[1] https://cdn.rawgit.com/darach/my_little_pony/master/my-littl...
As a hardcore JavaScript programmer I make use of clusters or spawn child process to handle "actors" and I think that is much easier to reason about.
I would be happy if Pony had some examples of how to manage "world" state. For example if two objects in a 2D world intersects, or when one actor fires a laser, decide if another actor was hit by it.
I'm writing server code for MMO's and it seems like Erlang, Pony, etc would be the magic tool for such systems, but I never seem to "get it".
What is difficult from devs coming from the imperative world is getting recursion & bind-variables-only-once (what is commonly known as "the syntax is ugly").
Please, have a look at http://learnyousomeerlang.com/content
Honestly, these days, we have a lot of choices, you really need to woo us, show us why would we want to program in this language.