<moony>
(i'm making a manager that keeps track of Entity classes, Entitys are rather special, as such they are stored with the iso access capability)
<moony>
Ok, so apparently using iso with array is nigh impossible :V
<moony>
any tips?
<moony>
it's getting tempting just to share the entire entity list, but i cant do that.
<moony>
Ok, it's impossible.
<doublec>
moony: yes, it's difficult to use an iso in an array
<doublec>
moony: one approach is to exchange the value out of it, use it, then put it back
<moony>
Honestly, which would be better: One, massive, sync handler for all entities that calls all entities async, or multiple async handlers that call their child entities syncronously
<moony>
doublec, i thought of that. Couldn't think of a non hacky way.
<doublec>
moony: probably the latter
<moony>
well, thats what i need the Array[Entity iso] for :P
<doublec>
moony: does the array really need the iso object? Can it hold actors where those actors hold the iso object, then call behaviours on the actors.
<moony>
...hmm.
<moony>
(Also, i got the compiler to crash with my shitty code. Do i win a medal?)
<doublec>
moony: No medal, but an issue with a cut down code example on github would be appreciated by the dev team I'm sure
<moony>
(I've done the same to practically every compiler i've ever used. Rust hated the way i structured modules, Pony hated what apparently was very bad context abuse that i can't seem to reproduce)
<moony>
i'll try and try some more to reproduce it.
<moony>
all i can offer for now is the stack trace.
<moony>
doublec, any advice on how i should actually structure this? (This is really my first foray into actor based programming, and i need all the advice i can get to learn.)
<moony>
Entities are already quite simple, but i dont want them passed about or duplicated as they could store data that shouldn't be duped.
<doublec>
moony: Make entities actors, with behaviours for their functionality. That way they won't be copied. They can be passed about but no one can access their internal state except via behaviours.
<doublec>
moony: and then it's asynchronous by design
<moony>
Neat. What about, say, needing to access a entity's position, tho? (I'm still learning the ropes)
<doublec>
moony: if the entity needs to return state via a behaviour, pass a callback or promise to that behaviour call so that the caller gets called back with the result
<moony>
Wel then i have some experience. *node.js ftw*
<doublec>
moony: alternatively, examine why you need the entity to pass its state to someone and see if you can work out how the entity can do it themselves.
<moony>
doublec, from my perspective, a callback is a little overkill for a class that only contains 2 numbers
<moony>
but ok :P
jemc has quit [Ping timeout: 268 seconds]
<moony>
and sending an entire status object (pos rotation acceleration sleeping etc) also seems a bit overkill.
<moony>
sending a Bool makes it seem so much more so :P
<SeanTAllen>
moony... what is an entity doing in your system and what do its values get sent to?
<moony>
SeanTAllen, Dead set on trying to make a ECS, but it's becoming dead clear that it wont work very well.
<moony>
*parallel ECS
<SeanTAllen>
that doesn't really help me understand.
<SeanTAllen>
what is an entity and why do you need to send them someplace else?
<moony>
Mk. Will try and explain in 3.. 2.. 1..
<moony>
an Entity is basically just a ID with a few diffrent Behaviors attached (In this case, just traits). Sending it around is done when another entity needs to interact with it, in the form of, say, causing it damage.
aturley has quit [Quit: aturley]
<SeanTAllen>
so an entity is something like
<SeanTAllen>
Asteroid
<SeanTAllen>
or
<SeanTAllen>
Spaceship
<SeanTAllen>
yes
<SeanTAllen>
?
<moony>
Yup.
<SeanTAllen>
And each has its own data
<moony>
Mhm
<SeanTAllen>
and the interaction of 2 entities with one another causes state changes to both, yes?
<moony>
Almost always.
<moony>
(Edgecases are possible, like a entity bashing a wall, and the wall not doing anything in return)
<SeanTAllen>
interesting
<SeanTAllen>
how do you determine what the interaction is?
<SeanTAllen>
Generic methods in CLOS are great for this
<SeanTAllen>
Smalltalk style OO like Java, pony and many others have is... not so great for this
<SeanTAllen>
So, a rock and a spaceship, they have different methods?
<SeanTAllen>
or are there standard methods that are called as entry points on all entities
aturley has joined #ponylang
<moony>
Interaction is based on the interactee's space. And almost always yes in that case. a rock might have 'smash' and 'pos', a spaceship might have 'fire' and 'pos'
<SeanTAllen>
so if a rock and spaceship interact, in pseudo code, how do you imagine that would look?
<SeanTAllen>
how do you decide if a rock collides with a spaceship or vice-versa ie...
<SeanTAllen>
rock.collide(spaceship)
<SeanTAllen>
spaceship.collide(rock)
<moony>
both are called if avaliable.
<SeanTAllen>
right but one thing initiates an action
<SeanTAllen>
which is it?
<SeanTAllen>
how do you decide?
<SeanTAllen>
or does the order not matter
<SeanTAllen>
in the end, its the same result...
<moony>
the physics System. Systems are factor too. Systems handle tasks that shouldn't be handled by any one entity. Order is generally variable.
<moony>
(Systems fire most events)
<moony>
(In this case, it fires collide() for the two)
<SeanTAllen>
im not sure you want actors for entities
<SeanTAllen>
another question
<moony>
I don't want actors for entities at all. I wanted classes, and was considering doublec's idea. Sure, ask away.
<SeanTAllen>
parallelism. if entities are classes, what happens concurrenctly, what are the actors in the system that can be run concurrently?
<moony>
That's the tricky part i'm trying to approach solving.
jemc has joined #ponylang
<moony>
wb jem
<moony>
because, i have no idea :P
<SeanTAllen>
so entities as actors certainly makes the parallelism part easy
<moony>
but makes the communication part hard
<moony>
other way around is the reverse, indeed.
<SeanTAllen>
but i agree that from a simple modeling standpoint, as classes is much easier
<SeanTAllen>
i dont have any good advice for you, ive never solved this problem
<SeanTAllen>
but i have a better idea now when you ask questions what the background is
<SeanTAllen>
i think the "array of iso entities" is going to get to be really rough
<SeanTAllen>
because you can only "loan out" the entity once until its "returned".
<SeanTAllen>
and that is going to create some interesting parallelism scenario where you need to wait for an entity to be "returned"
<SeanTAllen>
entities as actors makes that much easier.
<moony>
Yup, you do. Here's a slightly better backround, in the form of a Creative Projects post on bay12: http://www.bay12forums.com/smf/index.php?topic=168188.0 (Of course, this isn't the first thing im doing, i'm practicing the language and figuring out how it would work in Pony)
<SeanTAllen>
ah
<SeanTAllen>
i had a thought
<moony>
mhm?
<SeanTAllen>
what about treating interactions like you would if this was a networked multiplayer game?
<moony>
also, note the ECSB i mentioned. It worked, until i tried to actually use it :P
<SeanTAllen>
so in that case, you could have each entity is an actor
<SeanTAllen>
but rather than a callback
<SeanTAllen>
you send a representation of an entity to another entity
<moony>
SeanTAllen, it IS a networked multiplayer game. Just, rather complex and large.
<moony>
but i'm listening.
<SeanTAllen>
act on it and send back the changes
<SeanTAllen>
so i think if that is the case
<SeanTAllen>
then how to represent interactions in one process is probably best solved by doing it the same way that it happens across processes
aturley has quit [Quit: aturley]
<SeanTAllen>
im not sure if that is helpful or not
<SeanTAllen>
and again, ive never solved this problem
<moony>
what would the 'representation' be? And i know.
<SeanTAllen>
whatever info is needed to for the other entity to know what the state change should be
<SeanTAllen>
so my assumption would be
<SeanTAllen>
something like
<SeanTAllen>
machine A has a rock that needs to smash a spaceship that is on machine B
<SeanTAllen>
so information about the rock is sent to machine B
<SeanTAllen>
where it changes the state of the spaceship (an actor) and the change to rock is sent back to machine A and rock (an actor) applies that change
<moony>
<moony> and sending an entire status object (pos rotation acceleration sleeping etc) also seems a bit overkill. Already thought of this. the way you explained it makes it seem less overkill :P
<SeanTAllen>
but the same thing can happen in a process
<SeanTAllen>
it could be overkill
<SeanTAllen>
im not sure how big a "representation" would be
<moony>
SeanTAllen, really depends, but, estimating on the fact my end goal is a Space Station 13 clone attempt, up to 10s KB, so it's probably overkill
<SeanTAllen>
seems like you need to though in some fashion
<moony>
But it looks like i need to.
<SeanTAllen>
so i think you have to decide where your bottleneck is going to be
<moony>
Yup.
<SeanTAllen>
its either in parallelism and need to have exclusive access to an entity
<SeanTAllen>
or its in "data interchange"
<SeanTAllen>
and the amount of representation that gets shuttled around
<SeanTAllen>
im fond of saying that all programming is just moving your hard problem from one place to another until you put it somewhere that you are familiar with and comfortable and feels "better".
<moony>
With the sily number of entities that could be around at all times (thousands, literally.), i guess a bit of parallelism is a fair sacrafice. I can offload a fair bit of work onto the systems, which would help a lot.
<SeanTAllen>
not an entirely true statement, also not entirely false
<moony>
and i can probably just use a specialized callback to prevent having to pass a entity around all the time.
<moony>
(Removing the 'waiting for self to be returned' problem)
<moony>
finding something similar brings you closer to the goal, so thanks! :D
<SeanTAllen>
you're welcome
dipin has quit [Quit: dipin]
<moony>
Just how much overhead does basic type checking have? (Checking if Foo implements Bar and/or Baz, for example
<SeanTAllen>
what do you mean by "overhead"?
<SeanTAllen>
and what do you mean by "type checking"?
<SeanTAllen>
are you referring to doing a match based on a type?
<moony>
Match based on a type, yes.
<SeanTAllen>
roughly, its basically a branch prediction
<SeanTAllen>
so
<SeanTAllen>
the answer for impact depends on how often the match is the same
<SeanTAllen>
if you have match against say 3 types
<SeanTAllen>
and they are evenly distributed
<SeanTAllen>
that will be slower than 99% of them are one type
<SeanTAllen>
because that's how modern cpus work
<SeanTAllen>
for the most part, think of it like an `if` for each possible match, even if it isn't exactly the same
<moony>
SeanTAllen, so, it has to check all possible types even if you only want to know if its a implementor of a single specific trait type?
<SeanTAllen>
no, thats not what i meant
<SeanTAllen>
if you match has 3 cases
<SeanTAllen>
and your data ends up matching each case evenly
<SeanTAllen>
that is slower than if it matches one case 99% of the time
nisanharamati has quit []
<moony>
..oh. Derp. Misunderstanding on my part. How would this kind of thing be done in Pony, and should it be avoided (checking for trait implementations)?
<SeanTAllen>
are you familiar with branch prediction in modern cpus?
<moony>
I.. No. I'll google it :P
<SeanTAllen>
so here is the basics
<SeanTAllen>
to go faster
<SeanTAllen>
cpus try to predict which branch will happen
<SeanTAllen>
the more often it can predict correctly, the faster your code will go
<moony>
Yea, i pulled up wikipedia. I can see. Thanks thought :P
<SeanTAllen>
cliff click has a great talk on this
<SeanTAllen>
i'd recommend it
<SeanTAllen>
so
<SeanTAllen>
the cost is a "branch prediction"
<SeanTAllen>
i say that because the cost is highly variable based on your data
<moony>
I'd assume typechecking in pony may be done with 'as'? It's all i can think of (checking for the resulting error if not a match)
<SeanTAllen>
no
<SeanTAllen>
`as` is a cast
<moony>
So how would it properly be done at runtime?
<SeanTAllen>
how would what be properly done? check to see if its a Foo or a Bar?
<moony>
Hey look, i reproduced the crash bug in a VERY minimal env.
<jemc>
nice
<SeanTAllen>
nice
<SeanTAllen>
jinx
<moony>
Isssue is... It doesnt reproduce if i make a copy of the file without the EXACT file structure.
<moony>
Hrm. src/libponyc/pass/scope.c:19: set_scope: Assertion `ast_id(name) == TK_ID` failed. Looks like it wants an identifier
<moony>
Will upload.
<moony>
Issue filed with upload.
<SeanTAllen>
what do you mean by "exact file structure"?
<moony>
as in, i couldn't get it to trigger in any other way besides with what's in the tar.
<SeanTAllen>
well there's invalid code in that
<moony>
I know. Was me not quite understanding how to use functions as args.
<moony>
But hey, it causes the compiler to freak out and dump a trace.
<moony>
so invalid code doesn't matter.
aturley has joined #ponylang
aturley has quit [Quit: aturley]
dipin has quit [Quit: dipin]
notsgnik has quit [Ping timeout: 276 seconds]
Pyrrh has quit [Remote host closed the connection]
johshoff has joined #ponylang
user10032 has joined #ponylang
jemc has quit [Ping timeout: 255 seconds]
gokr has joined #ponylang
moony has quit [Ping timeout: 268 seconds]
codec1 has joined #ponylang
kjekac has quit [Ping timeout: 258 seconds]
user10032 has quit [Remote host closed the connection]
vaninwagen has joined #ponylang
_andre has joined #ponylang
SirRolin has joined #ponylang
<SirRolin>
"A return in a behaviour must not have an expression", what does it mean by expression. I have been searching for it, and I got to a github discussion that behaviors always return None. so is it really like that or is there a way to read a return from it?
<doublec>
SirRolin: behaviours can't return anything as they run asynchronously
<doublec>
SirRolin: you can pass a behaviour an object/callback/promise or similar for the behaviour to notify the caller of a result though
codec2 has joined #ponylang
<SirRolin>
thx :)
aturley has joined #ponylang
codec1 has quit [Quit: Leaving.]
cjfeng has joined #ponylang
cjfeng has quit [Client Quit]
codec2 has quit [Read error: Connection reset by peer]
bimawa2 has joined #ponylang
bimawa1 has quit [Ping timeout: 240 seconds]
codec1 has joined #ponylang
codec1 has quit [Read error: Connection reset by peer]
codec1 has joined #ponylang
<SirRolin>
I have a program that connects to the database, but apperently before it is setup completely I can make it send a notify command which puts the notify in the query, but the program doesn't get a notification that the query has been updated, so the value is stuck until next notify, which shows the notify from before.
<SirRolin>
is there any good way to check if it is setup correctly?
vaninwagen has quit [Ping timeout: 268 seconds]
<SeanTAllen>
SirRolin: I don't have enough context to answer that. I'm not sure how one "puts a notify in the query" or how one would normally get "a notification that the query has been updated", or what it means to have "the value stuck until the next notify"
<SirRolin>
I think I found the way, right after posting. sorry to bother
dipin has joined #ponylang
<SeanTAllen>
quite alright.
<SeanTAllen>
in the future, if you need help, providing more of that background would help us help you.
samuell has joined #ponylang
alxs has joined #ponylang
<SirRolin>
I have created a file that's ment to be a package, how do I link it via the 'use "package: <name>" ' before it has been put in the builtin packages?
<SirRolin>
or extansion package
Praetonus has joined #ponylang
<codec1>
you mean, how to get a Pony file compiled ?
gokr has quit [Ping timeout: 248 seconds]
<SirRolin>
no, I mean that I have 2 files, 1 which is the package, and 1 that is a example of using said package, but I don't seem to be able to find the right coding for linking (with use "package: <name>") to the package I created which is in a folder beneath the example
<SeanTAllen>
SirRolin: What does your directory structure look like? where are the various pony files and where are you running ponyc from within that directory structure. and lastly where in the directory structure is your file that has your Main actor?
jemc has joined #ponylang
<SirRolin>
package/examples/main.pony <- structure with main and where I run ponyc | package/DBConnector.pony <- package
<SirRolin>
ofc I am in the directory when I run ponyc
<codec1>
and what do you want to achieve ? compile an executable that is made of examples/main.pony and package/DBConnector.pony?
<SeanTAllen>
what is "the directory"?
<SeanTAllen>
o i see
<SirRolin>
package/example
<SeanTAllen>
you can either use stable
<SeanTAllen>
to manage your ponypath to make it so you can do
<SeanTAllen>
well
<SeanTAllen>
no
<SeanTAllen>
you layout is a little odd
<SeanTAllen>
i would have examples/foo/main.pony
<SirRolin>
would you normally just have the examples in the same dirrectory as the package?
<SeanTAllen>
src/my_package_name/DBConnector.pony
<SirRolin>
ah
<SeanTAllen>
then use stable to manage the location of src/my_package_name/
<SeanTAllen>
at which point you can "use my_package_name"
<SeanTAllen>
and you could compile example with
<SeanTAllen>
stable env ponyc
<SeanTAllen>
stable can handle local file paths like that for you
<SeanTAllen>
we added it for how Wallaroo finds libraries
<SirRolin>
can't create a folder in usr/src
<SirRolin>
okay wrong src
<SirRolin>
but think I found it
<SirRolin>
now what do you mean by "stable"
<SirRolin>
?
<codec1>
it's the Pony dependency manager
<codec1>
the name is a joke ( because a stable is the place where you put horses, in case you are not a native english speaker) that can be confusing though
<codec2>
Hi, just to be sure to get the timezone right, the next Pony sync call is in 3 hours right?
<slfritchie>
Hm, I think it's 4 hours from now, lemme check.
<Praetonus>
4 hours codec2
<SeanTAllen>
4
<slfritchie>
Yup
<codec2>
thanks, I guess I cannot make a simple substraction
<codec2>
By the way, I will try to attempt to this one (just as an observer)
<codec2>
so don't be surprise to have one more person
noby has joined #ponylang
noby has quit [Client Quit]
<ehooper[m]>
Hello. Love the goals of Pony! I would like to start helping as I learn. What is the process for contributing? (apologize if there are better channels for this, haven't worked on an open source project before).
nisanharamati has joined #ponylang
<jemc>
ehooper[m]: welcome, and thanks for your interest!
<ehooper[m]>
ah, thanks! didn't think to look in the github repo. I will definitely check these out
<ehooper[m]>
So if I wanted to work on a issue, do I need to claim it first or just work on it independently and submit a PR?
<jemc>
it's generally good to leave a comment on the ticket to say that you're working on it, so that others don't pick up the same issue
<jemc>
and if you like, I can invite you to be a "member" of the Pony organization on GitHub, so that I can mark the ticket as "assigned" to you, but that's not a requirement
<ehooper[m]>
makes sense, thank you. I have some time over the next several days, so I'll try to pick one up later today or tomorrow
<SeanTAllen>
Candle: because your return type is T
<SeanTAllen>
and T is U16 or U32
<SeanTAllen>
go look at the return type of from on U16, U8, U32 etc
<SeanTAllen>
they have different types that arent T
<Candle>
SeanTAllen: trait val Real[A: ...] defines the c'tor "new val from[B: ...](a: B)" and (e.g.) U8 implements it as "new from[B: ...)](a: B) => a.u8()". The return type from a c'tor is the type, no?
<jemc>
Candle: the usual pattern for this case from the stdlib and elsewhere is to use `[T: (Integer[T] val & Unsigned val)]`