jemc changed the topic of #ponylang to: Welcome! Please check out our Code of Conduct => https://github.com/ponylang/ponyc/blob/master/CODE_OF_CONDUCT.md | Public IRC logs are available => http://irclog.whitequark.org/ponylang | Please consider participating in our mailing lists => https://pony.groups.io/g/pony
foofighterbar has quit [Ping timeout: 265 seconds]
khan has quit [Client Quit]
khan has joined #ponylang
jmiven has quit [Quit: co'o]
jmiven has joined #ponylang
jemc has quit [Ping timeout: 264 seconds]
sarna has quit [Quit: Connection closed for inactivity]
khan has quit [Quit: khan]
khan has joined #ponylang
jemc has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
foofighterbar has joined #ponylang
foofighterbar has quit [Quit: Left.]
salDesk has joined #ponylang
foofighterbar has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
Guest30987 has joined #ponylang
<foofighterbar> So this may be a stupid question: What's the simplest way to do something with a partial value?
<foofighterbar> i.e., if I have a List[A] called list, and I do list.pop, it gives me an "A?"
<foofighterbar> how can I say "If A is defined, do something with the value of A-- otherwise do nothing"
<SeanTAllen> you get an A or an error is thrown
<SeanTAllen> A?
<SeanTAllen> means A can throw an error
<foofighterbar> How expensive is error handling?
<foofighterbar> like, if I'm checking in an inner loop for the head of a list, and handling errors-- does that have an overhead?
<foofighterbar> I'm more used to patterns like Option or Maybe
<foofighterbar> And I think I got a bit mixed up with the Kotlin nullable ? syntax-- I was viewing ? as an option type essentially.
Guest30987 has quit [Remote host closed the connection]
<SeanTAllen> lucky for you, i wrote this up a while ago!
<SeanTAllen> error is more expensive than an match
<SeanTAllen> assuming you got errors most of the time
<SeanTAllen> if you rarely get an error, it will be less expensive then always going a match
<foofighterbar> Thanks!
<foofighterbar> For some cases, like where List.head returns an "A?", do I have a choice to do a match instead of a try block?
<foofighterbar> Or is that the proper pattern?
<SeanTAllen> You do not.
<SeanTAllen> We have tried to think of a way library writers could make that optionally available but
<SeanTAllen> there's no good way to do that
<SeanTAllen> you'd need something like the c preprocessor to run first and select versions and implementation
<SeanTAllen> or macros
<SeanTAllen> i look forward to having macros someday
jemc has quit [Ping timeout: 240 seconds]
khan has quit [Ping timeout: 240 seconds]
<foofighterbar> Makes sense, thanks for the info SeanTAllen
<foofighterbar> I imagine there's some really interesting design tradeoffs that are required to be made, for this kind of language
<foofighterbar> the dividing by 0 == 0 aspect is particularly interesting
mahmudov has quit [Ping timeout: 256 seconds]
milisarge has quit [Ping timeout: 248 seconds]
<foofighterbar> So, I'm probably missing something obvious here, but I'm trying to get the value in the head of a list
<foofighterbar> _snake.head().apply()
<foofighterbar> Oh, so I need ? after both calls-- I was just trying it on one or the other
<foofighterbar> why is that?
<SeanTAllen> any method that is partial needs to have the ?
<SeanTAllen> no spooky action at a distance
<SeanTAllen> then you can look at the code
<SeanTAllen> and know every place an error might come from
<SeanTAllen> imagne for example
<SeanTAllen> that you have
<SeanTAllen> foo().test().blah()
<SeanTAllen> ok
<SeanTAllen> and right now blah() can throw an error
<SeanTAllen> foo().test().blah()?
<SeanTAllen> i wrap it in a try
<SeanTAllen> now later test starts being able to throw errors as well
<SeanTAllen> by requiring
<SeanTAllen> foo().test()?.blah()? that change in interface will result in an API error
<SeanTAllen> so you can consider...
<foofighterbar> ah okay, makes sense-- so the compiler could always infer it, but this makes it easily identifiable in the code
<SeanTAllen> do i want to handle errors from test()? differently than blah()?
<SeanTAllen> visible is one thing
<SeanTAllen> but the "no spooky action at a distance" when a method later becomes one that can throw errors is a very big part as well
<foofighterbar> yeah. Because hey, the method may have already been under a try block, and so the compiler wouldn't complain if the type signature switched to ? under you-- but the logic may be off
<foofighterbar> btw, feel free to take a look at this if you're interested: https://pastebin.com/C39RbZEN
<foofighterbar> just started learning Pony last night, working on a little snake game
<foofighterbar> it's a really interesting language, first time I've ever worked with capabilities like thos
<SeanTAllen> can you email me a link or send to the mailing list?
<SeanTAllen> sorry, i'm knee deep in working out performance in Wallaroo in the Go API where we are calling into Go from Pony.
<SeanTAllen> And I'm exhausted and completely busy for a bit
<SeanTAllen> if you send to mailing list though, i will take a look when i have time
<SeanTAllen> and others could give feedback as well
<SeanTAllen> this `let _main: Main tag`
<SeanTAllen> Main is an actor
<SeanTAllen> you don't need the `tag`
<SeanTAllen> `tag` is the default for an actor
<SeanTAllen> personally i dont like to do anything other than initialization in Main, so I'd create another actor for doing all the non intialization stuff
<foofighterbar> *shrugs* no worries, I don't have too many questions on it, just excited to learn the language.
<foofighterbar> I appreciate the help with the "?" questions I had, and good luck with the Go API!
<SeanTAllen> for this...
<SeanTAllen> you are passing env but not using all of it
<SeanTAllen> env is very powerful, you can use it do anything
<SeanTAllen> its good Pony advice to only pass what you need
<SeanTAllen> so if you need it to print to standard out
<SeanTAllen> dont pass `env` pass `env.out`, just the Outstream
<foofighterbar> Cool, making those changes.
<SeanTAllen> you can combine these
<SeanTAllen> let pressed: String val = String.from_array(consume data)
<SeanTAllen> i don't think you want the `None` at the end of this...
<SeanTAllen> fun ref _move_player(d: Direction) => None
<SeanTAllen> it doesnt do anyhting
<SeanTAllen> because there's more of the method later
<SeanTAllen> you are using case methods
<foofighterbar> ah, that was a leftover artifact from when I had _move_player be a case method
<foofighterbar> just tinkering around with various stuff
<SeanTAllen> i think anyway
<SeanTAllen> those are being deprecated
<SeanTAllen> due to problems in the implementation
<SeanTAllen> im not sure that is what you wanted anyway
<SeanTAllen> probably is
<SeanTAllen> but its easy enough to turn into 1 method
<foofighterbar> I had it in 1 method at first, but the syntax was kind of unwieldy
<SeanTAllen> well, thats the only option you'll ahve soon
<SeanTAllen> until someone has time to try to work out a new case functions implementation
<SeanTAllen> that's what i see with a quick glance
<SeanTAllen> it was a little garing for me, just because i'm used to standard library style
<SeanTAllen> but everyone has their own style that works for me
<SeanTAllen> didnt have time to look at logic or anything
<SeanTAllen> anyway, i need to try and sleep
<SeanTAllen> i'll talk to you later
<foofighterbar> I appreciate the quick review-- go get some rest, thanks again
<foofighterbar> I probably won't end up being super involved in the Pony community (not enough time), but I like what you're all doing here, seems really cool
khan has joined #ponylang
jemc has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
jemc has quit [Ping timeout: 264 seconds]
foofighterbar has quit [Ping timeout: 260 seconds]
milisarge has joined #ponylang
codec1 has joined #ponylang
lp has joined #ponylang
lp has quit [Client Quit]
khan has quit [Quit: khan]
mahsav has joined #ponylang
milisarge has quit [Ping timeout: 240 seconds]
mahmudov has joined #ponylang
mahmudov has quit [Client Quit]
mahmudov has joined #ponylang
jtfmumm_ has joined #ponylang
jtfmumm has quit [Ping timeout: 276 seconds]
jtfmumm_ is now known as jtfmumm
krig has quit [Ping timeout: 276 seconds]
krig has joined #ponylang
_andre has joined #ponylang
khan has joined #ponylang
woody_ has joined #ponylang
<mahmudov> i noticed pony terminate inifite loop after 10s
<mahmudov> i tried this
<mahmudov> # time ./loop > /dev/null
<mahmudov> sys0m4.984s
<mahmudov> user0m10.191s
<mahmudov> real0m9.269s
<mahmudov> Süreç durduruldu
<mahmudov> process terminated.
<mahmudov> it consumed 5.3GB ram and %50 cpu then terminate
<SeanTAllen> take longer for me, but eventually the oom killer kills it
<SeanTAllen> pony isnt exiting.
<SeanTAllen> oom killer whacks it
<SeanTAllen> mahmudov: gc only runs between behaviors so that infinite loop is going to use more and more memory until it gets killed
<SeanTAllen> there's work on a new gc that can run during behaviors
<mahmudov> hm is there any pre-ensure this in code
<mahmudov> can we determine the code whether include infinite loop or not
<mahmudov> maybe a try-catch
<SeanTAllen> i'm not sure what you are imagining...
woody_ has quit [Quit: Page closed]
<mahmudov> i mean can we analyse the code in itself.for inifinite loop
<mahmudov> is it possible that i wonder
<SeanTAllen> thats an incredibly hard thing to do beyond trivial examples
<mahmudov> i see.
codec1 has quit [Ping timeout: 248 seconds]
alxs has joined #ponylang
<mahmudov> more clear thnks dlowe
<mahmudov> i wonder can we intervene the gc in pony ?
<mahmudov> i tried same code in c++ it runs cpu %14 and 1.6mb
<mahmudov> in pony code gc is overloaded and terminated.isnt it
<SeanTAllen> i dont know what you mean by "overloaded"
<mahmudov> when i run inifinite code ram usage increased to 5.3gb
<mahmudov> i defined it "overloaded"
<mahmudov> if didnt define
<SeanTAllen> its not overloaded
<SeanTAllen> gc currently only runs between behaviors
<SeanTAllen> you wrote code that wont ever trigger gc
<SeanTAllen> there is work on a different gc that can run during behaviors
<mahmudov> hm.i messed a bit so why code was terminated
<mahmudov> couldnt run forever
<mahmudov> i expected as run like this
<mahmudov> is my pony code seems wrong.when i run it my ram up to 6gb .. then terminate
<mahmudov> but cpp code is ok 1.6mb ram ..
<SeanTAllen> mahmudov: sorry, im not sure how to answer beyond what i already have.
<SeanTAllen> you wrote code that will never gc, it will keep using memory but because the create method in main never exits, it will never be freed
<SeanTAllen> this is a limitation of the current gc
<mahmudov> hmm so cpp do this automatically ?
<mahmudov> just i do basic comparing to understand this.
<aturley> mahmudov the cpp and pony code do slightly different things.
<mahmudov> aturley just i want to understand : how should we code in pony like cpp runs
<aturley> the pony code creates a new string every time you call `count.string()`.
<aturley> each of these strings is allocated on the heap, and will stay there until the garbage collector runs.
<mahmudov> yeah thats point
<aturley> the garbage collector only runs in between behaviors.
<SeanTAllen> and it sends it another actor "env" that will asynchronously print
<aturley> `create` is a behavior.
<aturley> since your code runs forever within `create`, those strings remain on the heap.
<aturley> that's why you see memory growth in the pony example.
<aturley> cpp handles things a bit differently.
<mahmudov> hm aturley
<mahmudov> i changed to
<mahmudov> env.out.print("x")
<aturley> without going into too many details, all of the strings that are created in the cpp program get deallocated after they are printed because they are allocated on the stack.
<mahmudov> same results
<mahmudov> so env.out.print("x") creates new string ?
<aturley> sorry, i need to jump off for a bit.
<SeanTAllen> mahmudov: did you read the link i sent you?
<mahmudov> yes i am writing it so we should use timer ?
<mahmudov> for like a code
<SeanTAllen> ok, so... can you explain from what you read, why that is needed? you explaining what you understand, in your own words, would help me try to fill in the gaps
<mahmudov> my understoods: in behaviours like create gc doesnt attempt to it
<mahmudov> so heap usage can increase as a disadvantage
<SeanTAllen> do you understand that cpp is running in a single thread and that the pony code you wrote is running multiple actors that are communicating asynchronously? and could in theory be run using more than 1 thread?
<SeanTAllen> also... this would be the pony equiv to what you wrote in C++ : http://playground.ponylang.org/?gist=4e8e06665d8254b0ad701341309d1c6b
<SeanTAllen> everything is allocated on the stack and printed synchronously
<mahmudov> i missed it: my code runs multiple actors ?
<mahmudov> doesnt run one actor.cuz we created one actor ?
<SeanTAllen> no
<SeanTAllen> Env is an actor
<SeanTAllen> each call of env.out.print sends a message from your actor Main to the Env actor
<mahmudov> ahh
<SeanTAllen> sorry not Env
<SeanTAllen> Env is a class
<SeanTAllen> out is an StdStream
<SeanTAllen> and that is an actor
<SeanTAllen> Env.err is another actor as well
<mahmudov> hm i thought it is just a function to print something
<SeanTAllen> no
<SeanTAllen> you are sending a message that will be asynchronously printed
<SeanTAllen> so you dont block on that
<mahmudov> yeah i mislead there
<SeanTAllen> the link i sent you, it prints synchronously using a FFI call to printf
<mahmudov> yeb i run it.runs 3.9mb
<SeanTAllen> far less on my machine but thats good
<mahmudov> well if any stuff of actor finishes doesnt empty heap ?
<mahmudov> namely first it wrote "x" then still place on heap ?
<mahmudov> why still place on heap.it did its work
<SeanTAllen> the string for x is allocated on the heap of the actor Main
<SeanTAllen> each actor has its own heap
<SeanTAllen> actors will garbage collect their heaps AFTER behaviors are run not during
<mahmudov> hm
<mahmudov> cleared seanTallen.execuse me,i tired you.
<SeanTAllen> ?
<SeanTAllen> sorry mahmudov, i dont understand
<mahmudov> i made you tired.
<mahmudov> by many misleads
<SeanTAllen> you didnt
<mahmudov> ok.thnks much
jemc has joined #ponylang
<SeanTAllen> you're welcime
foofighterbar has joined #ponylang
<dougmacdoug> when i write an apply method if i want to use it together with create sugar i need to return this correct?
jemc has quit [Ping timeout: 256 seconds]
<SeanTAllen> sorry i dont understand dougmacdoug
<SeanTAllen> Foo calls a constructor with no args
<SeanTAllen> Foo() would call a no args constructor then call apply with no args
<SeanTAllen> Foo(1)(2) would call a single arg constructor with 1, then call apply with (2)
<dougmacdoug> right.. but if I said, let foo = Foo() then foo = None, unless apply returns this
<SeanTAllen> sorry still not following
<SeanTAllen> o
<SeanTAllen> right yes
<SeanTAllen> Foo needs to return this
<SeanTAllen> or Foo.create().>() might work
<SeanTAllen> yeah that didnt work
<SeanTAllen> i had to do
<SeanTAllen> one could perhaps consider having to use apply() rather than () a bug
<SeanTAllen> its certainly an intersting edge case
<SeanTAllen> anyway, sorry have to run
<dougmacdoug> unit tests saving my bacon on that one.. the tutorial never calls that out .. it makes perfect sense after the fact, but its not clear at all from the examples
jemc has joined #ponylang
foofighterbar has quit [Ping timeout: 240 seconds]
foofighterbar has joined #ponylang
mson has joined #ponylang
foofighterbar has quit [Ping timeout: 252 seconds]
user10032 has joined #ponylang
Praetonus has joined #ponylang
alxs has quit [Quit: Computer's gone to sleep. ZZZzzz…]
alxs has joined #ponylang
alxs has quit [Client Quit]
Praetonus has quit [Ping timeout: 268 seconds]
Praetonus has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
user10032 has quit [Quit: Leaving]
khan has quit [Client Quit]
khan has joined #ponylang
vaninwagen has joined #ponylang
vaninwagen has quit [Ping timeout: 240 seconds]
khan has quit [Quit: khan]
khan has joined #ponylang
mson has quit [Quit: Connection closed for inactivity]
khan has quit [Client Quit]
khan has joined #ponylang
alxs has joined #ponylang
alxs has quit [Quit: Computer's gone to sleep. ZZZzzz…]
alxs has joined #ponylang
alxs has quit [Quit: Computer's gone to sleep. ZZZzzz…]
codec1 has joined #ponylang
jmiven_ has joined #ponylang
jmiven has quit [Quit: co'o]
codec1 has quit [Read error: Connection reset by peer]
jmiven has joined #ponylang
jmiven has quit [Client Quit]
jmiven has joined #ponylang
jmiven_ has quit [Ping timeout: 276 seconds]