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
martinium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
acarrico has quit [Ping timeout: 240 seconds]
nisanharamati has quit [Quit: Connection closed for inactivity]
jemc has joined #ponylang
aturley_ has quit [Quit: aturley_]
acarrico has joined #ponylang
acarrico has quit [Ping timeout: 248 seconds]
_whitelogger has joined #ponylang
jemc has quit [Ping timeout: 240 seconds]
jemc has joined #ponylang
endformationage has quit [Quit: WeeChat 1.9.1]
dipin has quit [Quit: dipin]
user10032 has joined #ponylang
vaninwagen has joined #ponylang
samuell has joined #ponylang
jemc has quit [Ping timeout: 240 seconds]
user10032 has quit [Remote host closed the connection]
codec_ has joined #ponylang
<codec_> Hi
<vaninwagen> Ho
enilsen16 has joined #ponylang
enilsen16 has quit [Client Quit]
<codec_> I am trying to do a simple game with Pony and SDL2 on windows am I am running into a couple of issues
<codec_> some of them are design related on some them are technically
<vaninwagen> just shoot, we'll try to help
<codec_> The first is how to code the main loop
<codec_> So far I thought of 3 ways
<vaninwagen> i remember several guys having problems doing some UI because the libs they use require being called from the main thread
<codec_> 1- Do a while loop just like C/C++ would do
<codec_> yeah I seems to run into that
<vaninwagen> dammit
<codec_> it was keeping it for the next questions :)
<codec_> 2- Use a timer
<codec_> 3- Have an actor calling a behavior on itself
<codec_> The first approach seems problematic because pony use a cooperative threading model and as such the allocated memory created by the actor doing the while loop would never be garbage collected right ?
<vaninwagen> codec_, afaik yes, this would also block 1 scheduler
<codec_> So you would recommend going with the third approach?
<vaninwagen> codec_ calling a behaviour is asynchronous so you might have some performance problems, as the next execution might not be executed right away but with some indeterminate delay
<vaninwagen> i dont know if this is a problem in reality, never tried that
<codec_> do you have numbers on delay? because if it is always < ~5ms it is fine for a small game
<codec_> especially that I don't plan to use many actors so the scheduler would probably have not much actors to pick for running
<vaninwagen> i guess then it is fine
<vaninwagen> you could also do some batching and only re-execute the behaviour after each X loop iterations
<codec_> yes there is probably a way to optimize further but I aim for keeping things really simple (at least at first)
<codec_> so having dealt with the design issue, I can now bring the technicals one :)
<vaninwagen> codec_ maybe, if you run your game with --ponythreads=1 you will always run from the same one, not 100% sure
<codec_> thanks I will keep that in mind
<codec_> As a reference my up to date code is here: https://github.com/codec-abc/pony-sdl-2
<codec_> To sum up, I have a main loop running with an actor calling a behavior on it self
<codec_> When that happen I compute how much time have passed, move a square and poll the events
<codec_> In release it seems to work fines, when I click the quit button the game quit
<codec_> Yet compiling in Debug it does not work anymore
<codec_> the square keep moving but for a reason it seems that I can't get the events
<codec_> Do you have any idea of what could explain that and possibly how to fix it?
<vaninwagen> codec_, no unfortunately not. maybe doublec has, as he played with SDL2 before
enilsen16 has joined #ponylang
<codec_> It seems it was because I was using a struct instead of a class
<codec_> what are the differences between a class and a struct?
Praetonus has joined #ponylang
_andre has joined #ponylang
<vaninwagen> codec_, i'm sure Praetonus knows the differences between a pony class and a struct wrt calling C from pony
<codec_> will ash him, thanks for the tip
enilsen16 has quit [Ping timeout: 258 seconds]
<Praetonus> codec_: The difference is that a Pony struct doesn't have a type descriptor and therefore is ABI-compatible with a C struct with the same members
<Praetonus> As a result, you can't use runtime polymorphism on a Pony struct (pattern matching, interface subtyping, etc.)
codec_ has quit [Ping timeout: 260 seconds]
enilsen16 has joined #ponylang
enilsen16 has quit [Ping timeout: 258 seconds]
enilsen16 has joined #ponylang
codec_ has joined #ponylang
<codec_> Thanks Praetonus
<codec_> Yet, I didn't understand what happened and why it ran fine in release but not in debug
<codec_> Basically I have a C function that take a pointer to a C struct that is a union of different struct
<codec_> I look at the rust wrapper for SDL2 and to interface it with this function they create a byte array of the length of the maximum struct in the union that happen to be 56 bytes
<codec_> so I created a struct whose constructor created an array of such size so I can use it later on with the FFI function
<codec_> It worked nicely in release but not in debug, and when I switched to a class instead of a struct in worked in both mode
<codec_> and what confusses me in that when using a struct in debug the array seems to have a size of 0, just like the constructor was bypassed in some way
enilsen16 has quit [Read error: Connection reset by peer]
enilsen16 has joined #ponylang
<codec_> I just put some print in the code and the constructor works fine in debug. The array inside the struct misteriously lose all its element in debug mode.
<codec_> I wonder if it could be a bug in the code generation
<Praetonus> Do you have some code demonstrating the problem codec_?
<codec_> just my repo
<codec_> I try in the playground but so far I cannot
<codec_> by the way I found a fun bug. The pony compiler cannot generate an executable when the name would contains a space
<codec_> @Praetonus I managed to reproduce the bug in a simpler example
<codec_> compiling with ponyc -d with version 0.19.3-6a0dd3a [release]
<codec_> I get the following output
<codec_> in behavior - array size is 47 in behavior
<codec_> in behavior - array size is 8241904171254706025
<codec_> Hope it help
<codec_> (et sinon ton tutoriel sur zeste de savoir est tres bien)
<Praetonus> Ok, I'm seeing the same two outputs. That looks like a fun one. I'll take a look at the generated code
<Praetonus> (merci)
acarrico has joined #ponylang
<Praetonus> Apparently the problem is coming from the String concatenation
<codec_> are you sure because in my code for my sdl project I don't use strign concatenation for this part
<codec_> and I have got different behavior between debug and release mode
<Praetonus> When I remove the string concatenation I get the correct output. Maybe there are multiple bugs here
<codec_> probably as I get the wrong output too with the bug repro sample in release mode
aturley has joined #ponylang
aturley_ has joined #ponylang
aturley has quit [Read error: Connection reset by peer]
jemc has joined #ponylang
enilsen1_ has joined #ponylang
enilsen16 has quit [Ping timeout: 240 seconds]
dipin has joined #ponylang
enilsen1_ is now known as enilsen16
dipin has quit [Quit: dipin]
vaninwagen has quit [Ping timeout: 240 seconds]
nisanharamati has joined #ponylang
dougmacdoug has joined #ponylang
dougmacdoug has left #ponylang [#ponylang]
enilsen1_ has joined #ponylang
enilsen16 has quit [Ping timeout: 248 seconds]
enilsen16 has joined #ponylang
enilsen1_ has quit [Ping timeout: 240 seconds]
enilsen16 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
enilsen16 has joined #ponylang
codec_ has quit [Ping timeout: 260 seconds]
samuell has quit [Remote host closed the connection]
ponydude has joined #ponylang
samuell has joined #ponylang
ponydude has left #ponylang [#ponylang]
enilsen1_ has joined #ponylang
enilsen16 has quit [Ping timeout: 248 seconds]
kulibali has joined #ponylang
user10032 has joined #ponylang
kjiubbij has joined #ponylang
kjiubbij has quit [Client Quit]
enilsen1_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
atk is now known as oop
oop is now known as atk
vaninwagen has joined #ponylang
aturley_ has quit [Quit: aturley_]
aturley has joined #ponylang
gokr has joined #ponylang
gokr has quit [Ping timeout: 240 seconds]
krylon has joined #ponylang
gokr has joined #ponylang
gokr has quit [Ping timeout: 260 seconds]
dipin has joined #ponylang
trevorriles has joined #ponylang
mollymorphic has joined #ponylang
trevorriles has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
trevorriles has joined #ponylang
_andre has quit [Quit: leaving]
ekr has joined #ponylang
gokr has joined #ponylang
vaninwagen has quit [Ping timeout: 246 seconds]
aturley_ has joined #ponylang
aturley has quit [Ping timeout: 240 seconds]
mollymorphic has quit [Ping timeout: 255 seconds]
samuell has quit [Quit: Leaving]
trevorriles has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mollymorphic has joined #ponylang
mollymorphic has quit [Ping timeout: 248 seconds]
mollymorphic has joined #ponylang
Praetonus has quit [Quit: Leaving]
_whitelogger has joined #ponylang
nisanharamati has quit []
user10032 has quit [Quit: Leaving]
sstrickland has joined #ponylang
sstrickland has quit [Quit: Page closed]
vivus has joined #ponylang
<vivus> Hello all.
<vivus> are there any proper examples of using pony beyond basic examples?
bitcrusher has joined #ponylang
<SeanTAllen> What do you consider a proper example vivus ?
<vivus> SeanTAllen: where I can see functions and something like database interaction
<vivus> or rest API
<SeanTAllen> Im not aware of anyone doing any REST work in Pony at this time.
gokr has quit [Ping timeout: 240 seconds]
<SeanTAllen> not sure what you mean by "functions" unless you mean literally functions which doesnt seem right
<SeanTAllen> There's a small collection of Pony libraries and programs on GitHub. You can find them under https://github.com/topics/pony-language topic.
<vivus> pony is functional programming right?
<SeanTAllen> not really no.
<vivus> is it imperative?
<SeanTAllen> yes
<SeanTAllen> most pony code is imperative
<vivus> that is exactly what I am looking for. imperative without OO
<vivus> how is pony different to #nim?
<SeanTAllen> How do you define OO?
<SeanTAllen> Pony has classes for example and structural and nominal subtyping but no inheritance.
<vivus> I want to write code like C, where I don't need classes, just functions
<SeanTAllen> Well, Pony is actor based, so you have to write actors.
<SeanTAllen> The standard library is mostly classed based.
<SeanTAllen> Pony has 'primitives' that operate like a namespace, that can hold functions.
<vivus> actors and procs/functions are not the same?
<SeanTAllen> No.
<SeanTAllen> Actors are data and behaviors
<SeanTAllen> Each actor has a mailbox.
<SeanTAllen> You communicate with an actor by sending it messages, which in Pony means calling its behaviors.
<SeanTAllen> Actors encapsulate data as well as being a unit of concurrency.
<SeanTAllen> I'd suggest giving the tutorial a go: https://tutorial.ponylang.org/
<SeanTAllen> I think you'll find answers to a lot of your questions
dipin has quit [Read error: Connection reset by peer]
dipin has joined #ponylang
krylon has quit [Ping timeout: 260 seconds]