
Introduction to the Pony programming language - spooneybarger
https://opensource.com/article/18/5/pony
======
coldtea
> _" A programming language is just another tool. It's not about syntax. It's
> not about expressiveness. It's not about paradigms or models. It's about
> managing hard problems." —Sylvan Clebsch, creator of Pony_

Well, isn't that a zero content statement?

Sure, if you can't help in managing problems (and hard problems) the language
is not that good.

But I'd argue a language succeeds or fails in helping you manage problems
through its syntax, expressiveness, paradigms, models, and other attributes
(like community size, lib ecosystem, tooling, speed, etc).

~~~
kjeetgill
My hunch is Sylvan was just trying to moving conversations about Pony language
past some of the "shallower" topics that swirl around new languages.

The amount of times new language conversations nitpick c-style semicolons and
curly brace blocks, lisp's parentheses, prolog ending statements with a ., or
Python's significant whitespace ... It's exhausting. If I never have to read
the words "visual line noise" causing "cognitive load" again I'll be happy.
It's not that those aren't occasionally interesting but they are over trodden
topics.

I've found myself steering conversations like this: "It's not the language
it's the runtime!" Whats _interesting_ about erlang, go, and pony are the
runtimes. The languages play a role in how they expose those goodies but
that's a conversation well beyond whitespace and semicolons.

------
spooneybarger
Hi all,

In addition to being the submitter, I'm also the author and a member of the
Pony core team. I'll check the comments here from time to time and answer what
I can.

~~~
zzzcpan
I understand that its actor model pursues very different ideas from Erlang and
is therefore very limited and bare bones, basically allowing only per actor
event handlers (behaviors in Pony terms). How does it work in practice, do you
use higher order functions to construct basic flows? Like doing something,
then entering receive loop for certain messages and making sure no other
handler gets called to mess with the state until we are in receive loop for
this type of message, then doing something else and entering another receive
loop and so on.

~~~
aturley
Pony's model is different than Erlang's, so trying to think of it in terms of
Erlang's model ("entering receive loop") may not be helpful when trying to
understand it.

The Pony runtime takes care of scheduling an actor to run when there is a
message for that actor. The actor runs through the behavior and then waits to
be scheduled again by the runtime when another message is available. If you
want to filter messages you need to arrange a way to do that in your code.
There's no way to inspect the message queue.

~~~
abritinthebay
So kind of like the RabbitMQ worker/message/job dynamic?

~~~
aturley
Pony uses a queue for storing messages that have been sent to an actor, so
that's probably a reasonable way to start thinking about it. I'm not sure how
far I would stretch this comparison, though. :)

------
thecodingmonk
Please consider putting some code snippets in the home page, I needed I don't
know how many clicks to find a random code snippet to look at in the docs.

~~~
zzzcpan
[https://bluishcoder.co.nz/2016/05/11/exploring-actors-in-
pon...](https://bluishcoder.co.nz/2016/05/11/exploring-actors-in-pony.html)

~~~
abritinthebay
Looks like JS crossed with Python (not a bad thing at all)

~~~
spooneybarger
We've heard the Python comment before, never the JS one. That's a new one to
me. What brings JS to mind?

~~~
abritinthebay
Nothing specific! Just a general impression.

I’m primarily working in JS these days and it felt very familiar and
approachable so...

------
hellofunk
> Pony's reference capabilities and Rust's borrow checker both provide data
> safety; they just approach it in different ways and have different
> tradeoffs.

Would like to see a summary of what those tradeoffs are. Very curious!

~~~
spooneybarger
This won't be an exhaustive answer, but I can asnwer a little. Also note, this
is purely based on my own experiences with Rust (and Pony) and from what I've
heard from other folks as well.

Both are difficult for folks just learn the languages to grasp. When I tried
doing async programming in Rust, I found the borrow checker especially hard to
deal with. Pony's reference capabilities, once you understand them, apply
quite naturally to async code. This is important as most actions in Pony
involve sending asynchronous messages between actors. There are certain
patterns of passing around isolated regions of memory that are a pain in the
ass to do in Pony that are very easy to do in Rust (once you know how to work
with the borrow checker). It's something we are aware of on the Pony and are
working to address.

Reference capabilities are part of the type of variables. This can make
writing your own generics really hard unto you have a really good grasp of the
type system and reference capabilities. It's the steepest learning curve in
all of Pony.

Reference capabilities exist only at compile time but, something about how
people think about them leads people to wanting to be able to match on them at
runtime. I suspect this is something about how we teach them. It's a bit of a
hurdle for some folks and can lead to some confusion early on.

Someone who has spent more time writing Rust and helping people learn Rust
could come up with a similiar list. From time to time, Steve Klabnik and I
have talked about similiarities in how problems folks have in learning the two
languages.

I prefer reference capabilities to the borrow checker because reference
capabilities more closely align with how I think about data safety.

~~~
steveklabnik
Being the dual of Sean, I know Rust super well, but don't have as much
experience with Pony, especially newer versions. This basically corresponds to
my understanding as well. I also say "Pony is like Rust with Erlang" too.

I'd like to do a comprehensive comparison someday, but just don't have the
time...

~~~
spooneybarger
Same (on the just dont have the time).

------
hellofunk
Lots of discussion from three years ago:

[https://news.ycombinator.com/item?id=9482483](https://news.ycombinator.com/item?id=9482483)

~~~
hellofunk
It appears in the last three years they haven’t made good on this admission to
show language examples on the website:

> Yes you're right, we will put some code samples in earlier on.

[https://news.ycombinator.com/item?id=9483621](https://news.ycombinator.com/item?id=9483621)

------
todd3834
I was surprised to see such a long intro to a new language without any code
samples. Did I miss something?

~~~
spooneybarger
I, the author, don't find code samples particularly interesting. When I want
to consider a language, I start by asking what the hard problems it solves
are. Why would I want to learn this language? What does it give him, what is
it better at than the languages I already know. Given that is my bias and I am
the author, that is what I wrote about.

~~~
qedqfqef
Was the article for you or an audience, what outcome are you trying to
achieve, does your decision still hold true?

------
jb3689
This is not a great intro to Pony. The most interesting thing about Pony is
how data permissions work and how that allows for safe shared memory (a place
where Erlang can fall down for certain applications as data is always copied
between actors with the exception of large binaries)

Unfortunately for me the language felt a bit big and like it was doing too
much (I guess you could say Elixir is in that same boat and I eventually got
over that). It has the same "kitchen sink" problem as C++ and Scala. The use
case for safe shared memory is interesting though and I'm keeping an ear to
the project in passing

------
acobster
> it's compiled to efficient native code

When people say this, do they mean that it's compiled to assembly? So what's
native about it is the instruction set, yes?

~~~
abiox
"native code" insofar as i've ever seen it, means something "natively
understood" by the cpu. the typical alternative is "byte code" which must be
interpreted (or jit'd, etc).

------
qedqfqef
Pony is a slang word in UK, not great choice for name.

~~~
qedqfqef
Yes it does mean £25, but rarely used any more however the alternative is

Meaning: Rubbish; nonsense, or 'of poor quality'. Often shortened just to
'pony'.

What's the origin of the phrase 'Pony and trap'? This is Cockney rhyming slang
- pony and trap -> crap.

------
TruffleLabs
Snark: Pony Express will be a library or framework to help resolve current
issues.

------
IshKebab
Zero examples.

