3

why structs/objects when can tuples everything

Comments
  • 4
    Well, probably for the names I assume.
    {name: "dog", age: 7, weight: 26} is clearer/easier to work with than ("dog", 7, 26)
  • 1
    @SoldierOfCode Named tuples exist but have as property to be immutable in size afaik. So that's prolly why. In python only benefit of a tuple is a slightly better performance and unique values.
  • 3
    Depends on the language but normally structs are named. Tuples are anonymous.
    If you want to refer to the same type in multiple places, you probably want to use a struct and refer to its name instead of repeating the tuple definition.

    Also, structs can have more stuff like methods/functions, nested types, static properties, etc. Tuples can not have this.
  • 0
    One more thing to consider:
    Tuples have either value or reference semantics, it depends on the language.

    So for example if the tuples in your language have reference semantics and you want value semantics, you probably want to use struct (which has value semantics in most languages).
  • 0
    I just wanna write stuff fast

    idk what architecture looks like until I write things out

    would be nice if things are named cuz then they're more readable but that's not possible here

    *misses JavaScript and its ability to make objects on the fly* but tuples basically allow that, just less readably
  • 1
    Because the world isn't black and white

    Sometimes a little nuance goes a long way
  • 1
    @12bitfloat *autistically presses the same button / strategy and speedboats* booyah!
  • 2
    Idgaf.
    You can do it any way you like, it doesn't matter. It's a stupid debate.
  • 1
    @Ranchonyx yup.

    I prefer whatever way is the most readable/understandable. And you could argue one over another in all sorts of situations.
Add Comment