322 points · by ibraheemdev · 5y ago · 152 comments
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 right thing, and doesn't allow me to "I guess I could get away with X", and this reassurance is a huge boon.
It is hard to learn, and if you are not in the concurrency space, don't know what a thread is and don't care much for data integrity, then Pony is not for you. The effort you need to put in will not be appreciated by you.
If you have a strong opinion on how things must be done, Pony is not for you, because it won't allow you to follow your opinion all the time, because the opinion is not safe.
Pony is not for everyone, but for those that can think in the Pony model, then it is an incredible tool to ensure your code is correct, safe and performant.
My primary factor was "Actor Model" and I was struggling with Erlang's lack of static types, so that put Pony in the focus. An Actor Model framework on top (I recalled there was one for Rust) had given me "questionable" results with Akka (due to compromises/constraints in the JVM and Java/Scala).
HTH
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.
EDIT: s/data races/race conditions
The borrow checker (in safe rust) always[0] prevents data races. It can't, however, prevent race conditions (but neither can pony do[1])
From your experience with Pony, which escape hatches did you notice? How would a Pony programmer shoot themselves in the foot?
I still have no idea what actual Pony code looks like and I'm not sure where to click to find it.
I even clicked the link "learning pony." Of all the places to see at least a hello world, I'd like one there please.
When I am checking out a language for the first time, I like to at least see a sample of what I'll be committing to writing for the next few months.
go lang as a sample you can run on the home page! rust used to but you can still press playground to get it.
https://playground.ponylang.io/
...but the example isn't very enlightening.
Here's a networking example:
https://github.com/ponylang/ponyc/tree/master/examples/net
with the Main being in net.pony and the rest being the infrastructure.
And here's the start of an HTTP 1.1 app server (basically, just the HTTP parser at this point).
https://tutorial.ponylang.io/getting-started/hello-world.htm...
> Pony doesn’t care about filenames other than that they end in .pony. But it might matter to you! By giving files good names, it can be easier to find the code you’re looking for later
I cannot imagine anyone is going to be learning to code from the first time from this Hello World page. Although, the rest of the page is very much not for beginners, so maybe this was a fluke.
Often with new programming languages I wish they would present themselves in the form "Here's what you need to know about this language if you're already a professional developer" instead of an actual tedious tutorial.
https://ponylang.zulipchat.com/#narrow/stream/189985-beginne...
Before jumping in, we suggest folks read our code of conduct here:
https://www.ponylang.io/community/code-of-conduct/
And social rules here:
https://www.ponylang.io/community/code-of-conduct/#social-ru...
To understand what the general expectations are within the community.
There was a big focus on both performance and stability/safety.
If there is anything you ever want to chat about from that podcast or anything pony related, feel free to find me on the Pony Zulip and DM me.
4 months ago https://news.ycombinator.com/item?id=24398469 (thanks threatofrain!)
2019 https://news.ycombinator.com/item?id=20370448
2018 https://news.ycombinator.com/item?id=18212633
2018 https://news.ycombinator.com/item?id=17195580
2018 https://news.ycombinator.com/item?id=16768706
2018 https://news.ycombinator.com/item?id=16264845
2017 https://news.ycombinator.com/item?id=15558051
2017 https://news.ycombinator.com/item?id=14999899
2017 https://news.ycombinator.com/item?id=14676505
2017 https://news.ycombinator.com/item?id=13846063
2016 https://news.ycombinator.com/item?id=12331458
2016 https://news.ycombinator.com/item?id=10902906
2015 https://news.ycombinator.com/item?id=9482483
related from 2019 https://news.ycombinator.com/item?id=19241427
The reference capability stuff can be a bit hard to wrap your mind around, but mostly in a good way, and the compiler errors are generally pretty helpful. If you come from an OO or procedural background, there will be a sharp learning curve. My experience of learning pony reference capabilities is roughly similar (in terms of forcing you to think differently about data sharing) to learning how to work with the rust borrow checker, despite them having different goals and operational models.
Isn't Pony object oriented?
Pony features classes and actors are like classes that can receive asynchronous messages.
However, unlike some OO, there's no inheritance. Unlike a lot of other OO there's a heavy emphasis on asynchronous messaging.
I wouldn't use "OO background" as an indicator of what might make Pony harder to learn. I think the key parts are experience with rigorous type systems and experience with concurrency. Without a background in those, your path to learning Pony will be harder than the path for someone who is already familiar with them.
https://github.com/ponylang/ponyc/tree/master/examples
You can find a number of pony library projects under the ponylang org on GitHub:
This is the best page I have seen so far.
Sylvan is still involved but not in a coding kind of way. He's still involved in a variety of Pony decisions, discussions, etc. It's a rather different role than what he had in the beginning when he was the primary coder on it.
There was an uptick in contributions that were driven by Wallaroo Labs that involved improvements that were needed for Wallaroo, beyond that, it's all volunteers.
If you'd be interested in contributing, swing by the Zulip. We love to get new folks involved.
How does Pony relate to Joule? They seem to be on a continuum, what with Actors, object capabilities etc.
Pony needs to have something that shows how it's references are more/differently useful in a multi-actor program. I suspect that's a tall order.
Whether this is has a big impact on running systems remains to be seen, Erlang is very good at quickly collecting data.
Another thing that I would say Pony has that Erlang doesn't is an easy FFI mechanism. You can write NIFs for Erlang, but in my experience writing native code or wrapping C libraries has been much easier in Pony.
(Disclaimer, self-promotion):
It doesn't get easier than this: https://hexdocs.pm/zigler/Zig.html
(I'll be dropping direct c support in there in the next release)
"There’s plenty to love about Pony, but more than anything else, what we love most is that Pony makes it easy to write fast, safe, efficient, highly concurrent programs."
In Erlang you can write safe highly concurrent programs, but you might struggle with fast and efficient. Of course, how much fast and efficient you need depends on what you are trying to do.
[0] https://www.ponylang.io/blog/2017/05/an-early-history-of-pon...
https://news.ycombinator.com/item?id=24398469
Has anything new happened to the language?
There has been nothing large or dramatic in the last 4 months. We are plugging away at improving ecosystem tools, the runtime, and a variety of other things; incremental improvement.
We spent money from our open collective account recently to purchase a couple Apple Silicon mac minis so we can get pony working on Apple Silicon machines. That's probably the biggest "outside the community" news that is coming.
And I'm probably stretching the definition of "outside the community" there.
I don't know exactly how it works, but at some point it writes things to some memory address. This is the point where the Rust compiler starts complaining about the situation if you try to use the bindings from something that can potentially be sent between threads. So you use some mutex, or a lock, and maybe wrap the whole thing in an atomic reference counted entity.
What would be the Pony way of solving a situation like this? It does say that it is possible to directly call C or C++ libraries.
I'd really appreciate if someone from the Pony community can elaborate a bit on such use cases.
Joe is probably the best person to talk to if you want to use ZMG as a reference point, you can find him on the Pony Zulip.
I mean, the answer can be 'just rewrite the underlying library in Pony'. Which would be fair enough.
"It depends on the specifics" would be the general answer.
Once you use FFI, there's no guarantee of memory safety as the C code has access to the entire address space of the process. There is no sandboxing of foreign code at this time.
If the code you are calling isn't thread safe and you run your Pony program with more than 1 scheduler thread (pony actors get run on 1 or more scheduler threads- generally 1 per scheduler thread per CPU) then "bad things canhappen". Becaue you are running unsafe code that can be accessed from multiple threads- but... well, maybe you can structure the Pony API so that you don't do that.
It really depends.
- Error handling. Uninspectable, untyped errors that still must be declared and caught is just a total waste of an error system. It's not actively harmful, since you can just use primitive unions instead, but it's still a waste. If it's a recoverable error, it should have types and be inspectable so you can recover from it; if it's unrecoverable, it shouldn't have to be caught or declared.
- The file-based package resolution scheme. It is an absolute blight on any language that has it.
- The lack of function overloading. I excuse this in Rust because Rust trait implementations have their own namespace, so nothing conflicts, but if there are two Pony traits with the same function with different types or a different arity, there doesn't appear to be a way to implement both on the same class.
Does Pony have such ambitions (I mean, the Pony team)?
My UC is an actor system in the browser and the ability to create a DSL created using the same language used in programming the actor system.
Pony is not dynamic but statically typed? Maybe it can be overcome by substituting actors since any actor can create any other actor?
Plus I'm interested in graphics. I googled but didn't see any examples of integrating either web or desktop graphics, like Skia.
As far as graphics go, I'd say Pony is quite early stage for such elaborate API's like Skia.
A partial function is where you can't compute a result based on the input.
If you need to know what went wrong (because more than one thing might have gone wrong and that needs to be communicated), you can use a union type for the result and match accordingly (as you would in Rust as an example).
If you have used it and have any ideas on what you'd like to see there, feel free to drop by Zulip!
"Makes the files package better" is something that has been on a "list of things to improve" for a long time.
open:[String]->FileDescrptor
ReadWrite restriction FileDescriptor to
read -> Item,
write[item] -> Void
ReadWriteOpen:[String]->ReadWrite
[aString] |->
aDescriptor <- Open.[aString],
Implementation ReadWrite
read |-> aDescriptor.read,
write[anItem] |-> aDescriptor.write[anItem]
fd <- ReadWriteOpen.["/etc/passwd"]
Now we have an Actor fd that can only do reads and writes onthe opened file.
Consequently, fd is just one thing in Actors as opposed to
kind of being two separated things in Pony.
Is the separation in Pony really a good idea?
I'm sure that's true in some domains, but I think they're pretty narrow. E.g., if I were building an internal API that managed money, I might buy that. But I think the vast bulk of software is essentially exploratory. We ship something minimal and see what we next need. In that context, learning what we really need to do is far more valuable than doing the not-quite-right thing with provable correctness.
Clearly, the sentence you quote is making an unqualified absolute statement, which are usually easy to pick apart and tear down. After reading the whole philosophy, I'm not really sure what they mean by "guarantee" and "pointless" here. I doubt they're saying that all programming in "unsafe" languages is "pointless."
I suspect they could just reword that sentence to say something more clear. E.g. what kinds of correctness they weigh most heavily. Does Pony protect me from all classes of all possible bugs? No? Because that is impossible? Agreed. Then which kinds of bugs?
Just before, it also says: "The Pony philosophy is neither “the-right-thing” nor “worse-is-better”. It is “get-stuff-done”." This is admitting some sort of balance is being struck here...
At least for humans, correctness and consistency are very difficult, and therefore very expensive to achieve except under narrow conditions. Mainly we don't bother. That's part of why dynamic languages like Python and Ruby are so popular. Correctness takes a back seat to convenience.
There's nothing wrong with Pony making these choices. Let a thousand flowers bloom. But when I look at a new language or tool, my first question is, "What kinds of problems might it be good for?" From this quote, plus a number of other things, it's pretty clear to me that they've chosen a relatively narrow domain, one I do very little work in.
"Pony is an open-source, object-oriented, actor-model, capabilities-secure, high-performance programming language"
Can you give an example of this? How is Pony "much" safer than Rust?
Given how easy it is to use c-ffi from Pony, it can be hard with existing tooling to feel confident in what your Pony code might do. Once you call out via C-FFI, all safety guarantees are off.
In this way, the c-ffi in Pony is as problematic for reasoning about safety as `unsafe` is in Rust.
Pony allows you to turn off FFI for all packages except for some that you allow but even then, FFI is an end around for the memory safety and capabilities security that the language otherwise provides.
Improving FFI tooling is an ongoing conversation amongst the core team.
https://www.ponylang.io/media/papers/a_prinicipled_design_of...
Capabilities describe both uniqueness and read-write ability. `iso` is fully unique and hence sendable, `trn` and `val` are write-unique (but `val` is also sendable since it isn't writable). The `tag` capability allows identity/message sending and is fully sendable
Recover blocks and automatic receiver recovery allow creation/usage of isolated data if only sendables are used from the external environment.
Only sendables can be included in messages.
Actors have `ref` access to themselves but `tag` access to other actors.
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 compatible capability when a new alias to an object has been made" with "Aliasing" presenting the cases. There is "Unaliasing" and that's where I'm checking out.
Is there a general theory behind these kind of indexed judgement rules with case splitting?
* 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^`
I’ve seen this from other new languages lately. Please, study the Swift or TypeScript sites!
Most of the time the Promise/Future or async/await add mental overhead to code just for the sake of performance (because the monadic operations are only for sequential operations, it only make sense for applicative/parallel operations to use async/await if we don't care about performance). And with the Actor model, you don't need to use Promise or async 9 out of 10 times as you would in most languages without sacrifice performance.
If anyone from the Pony teams sees this, are actors in Pony conceptually similar to actors created with ray?
Turns out an easy google search answered my question as well... this post https://medium.com/distributed-computing-with-ray/ray-for-th... does say that ray uses the actor model, and ray is listed on The Actor Model wikipedia page as an Actor Model library.
A valid comparison would be to compare a Pony program to specific type of Rust program that involves considerable concurrent processing of data.
Pony's killer feature is a type system that allows programs to be written that are guaranteed to be safe from concurrency bugs. Like Rust, the Pony compiler is based on LLVM, and Pony programs compile to native code. Due to the Pony type system, the Pony GC is very efficient. Pony performance is pretty good, but as a language Pony is about much more than performance.
Most web apps generally need a lot of libraries to be "a good choice". Pony is lacking in libraries for "web development", so you'd need to do a lot of work that you wouldn't in other languages.
That's the case with most areas with Pony. You'll invest time in developing libraries you wouldn't in many other languages. In return, you get the nice list of "why pony" features, but, you are putting in a decent amount of work to get there.
That said if you release those libraries into the wild and get help maintaining them, the next time someone asks there will be less reason to say "you'll have to do some work".
It sounds like there is not (yet!) a package like Cowboy for Erlang for Pony? There is TCP server support but not HTTP and Rails-like stuff, eh?
If you don't mind me asking, what about using SQLite from Pony?
- https://github.com/ponylang/http_server
- https://github.com/theodus/jennet
Someone might have done SQLite for Pony, but I'm not aware of it. Writing network protocol stuff in Pony is usually pretty easy and the C-FFI is usually pretty easy which generally makes writing database connectivity (for at least happy path basics) fairly easy. (Add lots of caveats here).
If you'd like to talk more in-depth, swing by the Zulip and myself and other folks from the community can help out with answers.
template <class T> using shared_immutable = std::shared_ptr<const T>;
template <class T> using isolated = std::unique_ptr<T>;
That's basically how you'd guarantee that shared data is immutable and data passed along is held by only one thread.
Sure, sure, if you try, you can explicitly take out raw pointers out of them. You can also take an axe to your computer but, as they say, "just don't do that".