Hacker News new | ask | show | jobs
by ajanuary 1266 days ago
> There’s no need for adding say, len, to every object that needs a len function.

fwiw, Ruby does the same thing, but using the Enumerable mixin rather than a free floating function.

> I’d argue that is consistent.

I don’t understand this argument. It’s convenient and more efficient to write, yes. But how is it more consistent to have two different calling conventions?

The claim that there’s one way to do something irks me as well. There’s one way to find the length of something, but that introduces two ways of querying an object. It’s a good guiding principle, but when people use it to make stronger claims, it ends up superficial.

1 comments

By which I mean that you can consistently use `len` etc on any iterable and they will always behave in the same way. You learn them on day one and they work consistently in every place you see them forever.