logoalt Hacker News

pansa2yesterday at 2:05 PM1 replyview on HN

The reason many languages prefer `length` to `count`, I think, is that the former is clearly a noun and the latter could be a verb. `length` feels like a simple property of a container whereas `count` could be an algorithm.

`countof` removes the verb possibility - but that means that a preference for `countof` over `lengthof` isn't necessarily a preference for `count` over `length`.


Replies

ncrucesyesterday at 2:16 PM

But count is more clearly a dimensionless number of elements, and not a size measured in some unit (e.g. bytes).

show 2 replies