2
jestdotty
24d

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)
  • 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
  • 2
    @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
  • 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
    @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
    @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
Add Comment