by lprthx · 3y ago · 0 comments
In Python, they invent a weird, slow concept and discuss it for a decade, probably while writing 10 PEPs in the process. Through conferences, Stackoverflow, etc. people are slowly convinced that the concept is natural.
I’m always astonished by ignorant people feigning knowledge of their areas of ignorance.
For structs you have to remember that in python everything is reference passed, so some of the differences between structs and classes that you see in other languages do not apply.
But I suspect the real practical reason is that python already has structs, which are used for interoperability with C structs. Or any structured binary format really.
In haskell, structs are defined with the keyword data. Maybe that is where the inspiration comes from.
https://lotz84.github.io/haskellbyexample/ex/structs
In any case, it seems each language chooses equally confusing keywords. Syntax is not a big deal IMO if the concept is clear.
In Haskell, Rust and Python you can also just have tuples, if you want to. In Haskell you can use `newtype` or `type` to name your tuples and use them as records.
Of course, as you say, you can also use the `data` keyword in Haskell. Or you can use church encoding to use functions as records..
Lots of (confusing) possibilities.