#ah yes. slices. the 'extensible data structure'
Explore tagged Tumblr posts
bitsow ยท 1 month ago
Text
Wow, that's incredible. The go.dev article on slices states:
...The key step was the introduction of slices, which built on fixed-size arrays to give a flexible, extensible data structure. To this day, however, programmers new to Go often stumble over the way slices work, perhaps because experience from other languages has colored their thinking.
Indeed, my thinking has been colored (perhaps), because I think a slice data type should have some basic properties, like:
be a slice of a provided array
have an immutable size
and not:
allocate private buffer arrays for itself on demand
have a modifiable size
Because then that is not a slice. That is an array list. Worse, it's trying to be both, when the two are practically opposites. The job of an array list is to dynamically grow, and the job of a slice is to exclusively shrink. If your slice data type has an append() method at all then something has gone horribly wrong.
"greed breaks peoples minds and thats why finance people are all Like That" - wrong, thinking about slicing up cashflows is actually perfectly fine for your psyche, possibly even good. however, finance brings you into constant close contact with python and thats why they go crazy
211 notes ยท View notes