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
-
Well, probably for the names I assume.
{name: "dog", age: 7, weight: 26} is clearer/easier to work with than ("dog", 7, 26) -
retoor199521d@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.
-
Lensflare1772421dDepends 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. -
Lensflare1772421dOne 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). -
12bitfloat968521dBecause the world isn't black and white
Sometimes a little nuance goes a long way -
lungdart346621d@Ranchonyx yup.
I prefer whatever way is the most readable/understandable. And you could argue one over another in all sorts of situations.
why structs/objects when can tuples everything
random
tuples