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) -
retoor7722d@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.
-
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. -
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). -
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 -
Because the world isn't black and white
Sometimes a little nuance goes a long way -
@12bitfloat *autistically presses the same button / strategy and speedboats* booyah!
-
@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