2
jestdotty
11d

in imperative languages spaghetti code might just be the lay of the land

Comments
  • 4
    Not really, actually the opposite to be honest
  • 3
    Every general purpose language is imperative. You have no clue what you are talking about.
  • 1
    @Lensflare Except for functional ones

    And now take a guess why you have never heard a singular product built with one...
  • 3
    @12bitfloat RAAGHHHH

    not on my machine
  • 0
    @jestdotty What langs do you typically use?
  • 3
  • 1
    @whimsical Besides rust which she is obviously whining about again :P
  • 4
    @12bitfloat yeah, then they are most likely not general purpose.

    Jesty is probably thinking that JS is not imperative.
  • 2
    @12bitfloat no no no, I mean lame products made with a functional programming language. Rust is bootstrapped with ocaml. Noob :p
  • 2
    @whimsical You have defeated me, I kneel
  • 3
    @12bitfloat there are two types of languages

    those that people complain about and those that nobody uses
  • 2
    how 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
  • 2
    @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//...
  • 2
    @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
  • 2
    @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
  • 0
    @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
  • 2
    @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)
  • 1
    @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
  • 0
    @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
  • 1
  • 1
    @12bitfloat do you say entity rather than object in rust?
  • 1
    @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
  • 1
    @whimsical Lick what o.O
  • 1
    @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.
  • 2
    @Lensflare Just mix five different words, then everybody is confused :P
  • 1
    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!
  • 0
    @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.
  • 0
    @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? 🥺
  • 0
    @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.
  • 0
    @Lensflare I was being playful
  • 0
    @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
  • 0
    @Lensflare even my German boyfriend thinks you have no sense of humour
  • 0
  • 0
    @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!
Add Comment