Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Lensflare2033511dEvery general purpose language is imperative. You have no clue what you are talking about.
-
12bitfloat1065711d@Lensflare Except for functional ones
And now take a guess why you have never heard a singular product built with one... -
Lensflare2033511d@12bitfloat yeah, then they are most likely not general purpose.
Jesty is probably thinking that JS is not imperative. -
whimsical79411d@12bitfloat no no no, I mean lame products made with a functional programming language. Rust is bootstrapped with ocaml. Noob :p
-
jestdotty649310d@12bitfloat there are two types of languages
those that people complain about and those that nobody uses -
jestdotty649310dhow readable is this redundant 102-120 loop: https://play.rust-lang.org//...
and to say nothing about this idea of passing enums between processes: https://play.rust-lang.org//...
it's like opcodes. such a mess. you never know if one is handled in the appropriate place or what -
12bitfloat1065710d@jestdotty Looks pretty good honestly. I don't really know what in that code you're complaining about
I guess if you're complaining about having to "flip-flop" messages with new_messages: Instead of the .drain you could use a VecDeque: https://play.rust-lang.org//... -
jestdotty649310d@12bitfloat RAAGHHH SPAGHETTI
I might go back to rc refcell, then do downcasts to concrete types and do direct calls. the events seem like a nightmare
control flow all over the place. have fun trying to find where the enum is used without querying the IDE -
12bitfloat1065710d@jestdotty Rc vs HashMap is orthogonal to events vs direct functions
You can just replace the message system with function calls (change_energy(), change_body()) and pass in the context and the entity id
That's how I would do it, I think that's pretty clean -
12bitfloat1065710d@jestdotty Yeah I get you
Then for what I said you would emulate downcasting yourself with an enum that stores an id for one of the different entity kinds. Then have a downcast_as_entity or whatever that you pass the context and the generic id and it'll check if its the right enum variant and then give you the reference or something like that -
12bitfloat1065710d@jestdotty This is how I would do it:
https://play.rust-lang.org//...
I think this pattern is pretty damn ergonomic and flexible without having to fight the borrow checker
(actually quite proud of this one... probably gonna start using this pattern myself from now on :P) -
jestdotty649310d@12bitfloat I half understood that but then I didn't
I'm just gonna nod along and rethink my life decisions for a bit until some epiphany comes to me
SLOTMAP -
12bitfloat1065710d@jestdotty You don't have to do the insert_with_key and me stuff (normal insert is fine), then its a bit more obvious. I just like that all entities know their own key, just in case you pass an entity by ref to a function, you can still figure out its id
-
12bitfloat1065710d@Lensflare No i was more thinking about games (which creeps is)
I don't actually know what "objects" are called in Rust... I know C++ has objects and subobjects as real concepts -
Lensflare2033510d@12bitfloat ah, got it.
I don’t like "object" either, because IMO it implies OOP, even if you don’t use OOP. Also, people don’t typically think of "primitives" such as int and bool as "objects". (Thanks, Java and fuck you!)
"Instance of a type" is too wordy and just "instance" is too vague.
Sometimes I also say "value" but that is often associated with just numbers.
And "entity" is for games and databases. -
you define them as structs so it's a struct
but there needs to be a word for enum and struct. then you get just data I guess
entity is a catchall for "thing" that other things are attached to. they even call humans entities! -
@jestdotty
> entity is a catchall for "thing" that other things are attached to.
No, it‘s not. An entity doesn’t need to have other things attached to it to be called entity. -
@Lensflare why do you walk into these kinds of conversations
> In programming, an entity typically refers to a distinct object or concept that can be identified and represented within a system. The meaning can vary slightly depending on the context—whether you're working with databases, object-oriented programming, or game development—but the core idea remains consistent: an entity is something with a unique identity and associated data
you want me to lose and you can't take an L. so what's the point? next up you're gonna say I'm smart and a worthy person, yes? 🥺 -
@jestdotty nothing that you quoted supports your claim of "other things attached to it".
You are just wrong and I told you so in the most neutral way possible.
You seem to be insulted or pissed about that.
Now ask yourself the questions that you are asking me: Why? What‘s the point? Are you desperately trying to win?
Your ego is really something special. -
@jestdotty Kinda offtopic but did you try slotmaps yet?
Even better, I was nerdsniped by you and have spend the last two days writing a really fucking cool container lib in Rust. Its like slotmap but you can insert and delete items even without a &mut reference! Even EVEN better you can also iterate over the collection WHILE adding or deleting items down the callstack
AND its pretty damn efficient -
@12bitfloat yeah I already have that but I don't call them by those names
I wrote an operating system and it does it
slotmap is like thread_local but I don't utilize it as a slotmap
I might end up making meta for a process contain a tag (like process name and id, like creeps have names and that can be their id) and then doing some kind of fuzzy search in my operating system to look up a process / executable and downcast and stuff
my operating system will (untested currently but pretty sure it'll work because it did in the past) add new "slot map entries" / processes (meta, executable) while running processes / executables... so run, then add. after running everything it will delete. delete isn't that urgent. kind of like your idea I guess
---
I didn't straight up try slotmaps though. they just seem like a global object. thread_local!
in imperative languages spaghetti code might just be the lay of the land
rant