2 ms·
Interesting. I didn’t know you could do that in python with a list. It would be trivial for Go to support the delete keyword on slices (mapping to the statemen
by amscanne 6y ago
Interesting. I didn’t know you could do that in python with a list.
It would be trivial for Go to support the delete keyword on slices (mapping to the statement you noted), but I think it would be a bad idea. Sometimes you want an operation to be awkward intentionally because it’s fundamentally costly. Hiding that cost by making everything look the same doesn’t always help the programmer. Languages should be powerful, but there should be an intuitive relationship between the code the computational complexity (not exact, but intuitive).
I’m sure there are counter examples, but I think Go generally does a good job at this. Plain loops are standard, make, append, new, delete, etc. have obvious costs. Error handling is explicit.