10 ms·
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 w
by spooneybarger 8y ago
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.
- Yoric 8y agoHi spooneybarger. I'm curious: why is 1/0 == 0? Is it because there is no way to panic/kill the current actor with an error?
- spooneybarger 8y agoThat's covered in the Pony tutorial. https://tutorial.ponylang.org/gotchas/divide-by-zero.html https://tutorial.ponylang.org/gotchas/divide-by-zero.html I can elaborate a bit on what is in the tutorial. With the current semantics, you as the application programmer can check for division by zero and throw `error` if you want. Otherwise, every division operation would be partial which given that pony forces you to handle all partial functions, can get to be very painful. We are working on adding value dependent types and will be revisiting the divide by 0 question. Some work was done on that for a thesis a couple years back but hasn't been integrated into Pony by the author as they have had time constraints since leaving school. You can check out a video about the work here: https://vimeo.com/175746403 https://vimeo.com/175746403 It's definitely something that folks bring up. We aren't thrilled with the current functionality but feel its better than the previous functionality and are looking to slow improve the situation over time. It can definitely bite the uninitiated if they aren't careful.
- philipwhiuk 8y agoIt's better to be wrong and functional than correct and complicated? PS: This is the approach PHP took in the early days too.
- pron 8y agoBTW, this is the same approach taken by the Coq, Isabelle and Lean theorem provers. In all of them, 1/0 = 0. It is certainly unconventional, but whether this is wrong is a matter of philosophy. Basically, division by zero is undefined, but you can define it to be zero and so extend the definition. This is consistent with the rest of arithmetic. You get more theorems (like for all a, b and c, a/c = b/c), but no inconsistencies.
- OskarS 8y agoYou'd think that in these kinds of dependent type systems you would have to use the type system to prove that when doing a/b, b is never equal to 0.
- pron 8y agoWell, designing a language (even a mathematical one) is an art, and you need to trade off measures of convenience. The mathematical axioms that define division by zero to be equal to zero are consistent and so "correct" (if unconventional), and it turns out to be more convenient to define things in this way in those particular formalisms (rather than having to prove each time that you're not zero). You can define different theories in those systems that leave zero outside the domain of division or define it to be some value that means "undefined", but that's how it's done in the default arithmetical theories in those languages (and, BTW, Isabelle/HOL is not based on dependent types; Coq and Lean are). Other proof systems, like TLA+, do it differently. For a recent discussion about this on the Isabelle mailing list, see here https://lists.cam.ac.uk/pipermail/cl-isabelle-users/2018-March/thread.html https://lists.cam.ac.uk/pipermail/cl-isabelle-users/2018-Mar... (search for 1/0)
- wafflebear 8y agoThe users of Coq and Isabelle are generally people with mathematics degrees who check their work. Not your average programmer.
- pron 8y ago
- Serow225 8y agoIt might be worth clarifying in that tutorial that this behavior is different for floating point division by zero (correct?) I believe that numerical tools like MATLAB give the same result as Pony for integer divide by zero, if that gives you or others more comfort... Although they return a 'divide by zero warning' at the same time which can be user-disabled.
- mwahl 8y agoBTW, I recently opened an RFC (the way substantial changes to ponylang are introduced and discussed publicly) that introduces partial versions of basic arithmetic operators. The partial division is going to error on division by zero. This would allow the programmer to chose between what kind of behavior is most desirable for the use case. https://github.com/ponylang/rfcs/blob/partial-arithmetic/text/0000-partial-arithmetic.md https://github.com/ponylang/rfcs/blob/partial-arithmetic/tex...
- zzzcpan 8y agoI 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.
- spooneybarger 8y agoSorry, I don't understand your question but I'm going to answer it as best as I understand. Apologies if it ends up being a non-answer. There's a good talk by Scott Fritchie on the differences between Pony and Erlang that I would suggest. talk: https://www.youtube.com/watch?v=uv-3ptTD8hg&feature=youtu.be https://www.youtube.com/watch?v=uv-3ptTD8hg&feature=youtu.be slides: https://github.com/slfritchie/wide-world-of-actors https://github.com/slfritchie/wide-world-of-actors Like Erlang, each Pony actor has a mailbox that is processed in a serial fashion so that only one message is being processed. In Erlang, you have selective receive that allows you to receive messages out of order that they arrived. Pony has causal messaging where each message has to be handled in the order it was received. Otherwise they are same in terms of how received messages are handled. There's no `receive` in Pony as the behaviors are called directly. I would not call that "very limited and bare bones". Its different.
- aturley 8y agoPony'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 8y ago
- sharpercoder 8y agoThe website does not show any code in the first or second page. Only a cheatsheet after 3 clicks - which is a pdf.
- spooneybarger 8y agoYou'd be looking for the tutorial: https://tutorial.ponylang.org/ https://tutorial.ponylang.org/
- nalllar 8y agoIt would be good to show off the language more prominently, on the home page. You could consider some runnable demos like python and rust's. [1], [2] [1]: https://www.python.org/ https://www.python.org/ [2]: https://www.rust-lang.org/en-US/ https://www.rust-lang.org/en-US/
- qop 8y agoNot every language presents itself as an object to be marketed. Also, pony is still an early product. It's secure, but it still needs more work before extremely important work happens using pony. In that regard, it's better to attract only those who propel themselves then to attract a bunch of users who wont/cant contribute and will impose their demands on the core team. It's just not time to market yet.
- cobythedog 8y agoI'm on mobile and I don't see any code or links to code. Is it different on desktop?
- spooneybarger 8y agointeresting. do you see code on mobile when you visit: https://tutorial.ponylang.org/getting-started/hello-world.html https://tutorial.ponylang.org/getting-started/hello-world.ht...
- Hamcha 8y agoAny plans to make the compiler on Windows work with clang/msys rather than Visual Studio? I played with the flags and somehow managed to get an Hello world compiled to .exe, but it would crash upon start. I know it's kind of stupid, but relying on such a huge behemoth was my biggest turnoff.
- kulibali 8y agoThere's an issue for that: https://github.com/ponylang/ponyc/issues/2079 https://github.com/ponylang/ponyc/issues/2079 Also you can use the Visual C++ Build Tools, which is just the compiler without the IDE. https://github.com/ponylang/ponyc#windows-using-zip-via-bintray https://github.com/ponylang/ponyc#windows-using-zip-via-bint... http://landinghub.visualstudio.com/visual-cpp-build-tools http://landinghub.visualstudio.com/visual-cpp-build-tools
- ghosttie 8y agoSince there are no exceptions, in a try-else how can you tell what the error was?
- spooneybarger 8y agoIf you need to distinguish between different errors than a union type like (Result | ErrorA | ErrorB) should be used.
- ghosttie 8y agoI mean like try if not x() then error end if not y() then error end else // which error happened? end
- spooneybarger 8y agoIf you need to distinguish between error then that would inappropriate. Without a real example, I can't really say what the right approach would be. Looking at your example, I would say, if you care about which error happened, you should be using separate try blocks. Errors aren't meant for flow control like that so really, you shouldn't be indicating error inside a try like that. One option that Pony could have gone with is to use union types to always indicate errors: (My Result | MyError) There's overhead to that though. You always have to match on the type. For situation where an error is unlikely, partial functions are nice. Partial functions are not exceptions though, and aren't designed to do flow control so trying to use like some might use exceptions (to do flow control) is going to be painful (as your example points out) because they weren't designed for that use case.
- ghosttie 8y agoHow about things like opening a file, where there could be a variety of reasons it could fail?
- spooneybarger 8y ago