3 ms·
"strlen" is a bad name partly because it's not immediately obvious what is meant, and partly because it contains the name if the type. One if the things I thin
by continuational 10y ago
"strlen" is a bad name partly because it's not immediately obvious what is meant, and partly because it contains the name if the type.
One if the things I think Java actually does well is to provide good namespacing facilities for methods (eg. classes). That allows you to omit the type in method names.
C: strlen(x)
Java: x.length()
- jstimpfle 10y agoBut strlen is not a method. Why are you arguing? Besides, it's a very good name for a free-standing function.
- masklinn 10y agoThat it's a free-standing function is no excuse, generic functions have been a thing for decades, likewise namespaces.
- jstimpfle 10y agoIt's a C function. C doesn't have generic functions.
- masklinn 10y agoC's a shitty language, nothing new there, that doesn't make "strlen" any good it just means you get a historical baggage obsessed with nonsensically short names (hello creat(2), fcntl(2), fgetwln(3), wcsftime(3) or strpbrk(3)) and the additional constraints of a namespace-less language with no generics.
- jstimpfle 10y agoYou are not even disagreeing with me.
- masklinn 10y ago> You are not even disagreeing with me. You apparently aren't reading my comments. The first part of the comment is specifically about that, the naming has nothing to do with C's constraint and everything to do with the community surrounding it. While I am loathe to praise WinAPI, its designers did at least demonstrate that you can use descriptive symbol names in a C API.