4 ms·
"Thus I say maxphysaddr (not MaximumPhysicalAddress) for a global variable, but np not NodePointer for a pointer locally defined and used." Yes, because "maxph
by wtracy 16y ago
"Thus I say maxphysaddr (not MaximumPhysicalAddress) for a global variable, but np not NodePointer for a pointer locally defined and used."
Yes, because "maxphysaddr" is extremely readable for people who are not native English speakers.
Wait, was that "maxiphysadd" or "maxmphyaddrss"? Better stop coding (breaking up my train of thought) and scroll back up to the variable declaration to double-check how I spelled it.
(Yes, I know that modern IDEs can remember variable names for you, but there's always those emergency situations where you wind up trying to debug something with VIM over SSH via a slow-as-molasses hotel wifi service.)
- tedunangst 16y agoIf you can't remember maxphysaddr vs maxiphysadd, I doubt you'll do much better remembering MaxPhysAddr vs MaxiPhysAdd.
- chc 16y agoMaxPhysicalAddress is more readable than all the above. Pike simply had it wrong, IMO, probably from having been immersed in a culture of poor readability for so long that he had become blind to some of it.
- tedunangst 16y agoIn 1989, external symbols were (possibly) only unique wrt the first 6 letters. Trying to guess if anybody else would name a variable MaxPhy* isn't a fun game...
- chc 16y agoThat's true, but Pike didn't explain it that way. He wasn't talking about compatibility, but readability. That part of the article was explaining that longer and more complicated is not necessarily better in terms of readability, and there is a sweet spot where something is concise but not overabbreviated. That's all obviously true. Then he suggested that "maxphysaddr" is in this sweet spot for the idea of the highest point in physical memory that can be addressed, which I think is wrong.
- caf 16y agoI agree with Pike on this one - and I think it's likely true what he says about being used to reading prose. For those of us who do a lot of non-programming reading, Funny Out-Of-Place Capitals interrupt the smooth flow when reading variable names. I do_tend_to_use underscores, though - I find that they don't have the semiotic noise value as WeirdCapitals.
- chc 16y agoI find the opposite — underscores are hard to read, but innercaps are almost effortless. At any rate, they're equivalent — you can mechanically transform from one to the other without data loss. I would say that either is preferable to not delimiting your words at all. It sounds to me like you agree with me more than Pike, modulo an insignificant matter of taste.
- drv 16y agoI don't have any first-hand experience with the non-native English aspect, but I doubt such a person can remember how to spell MaximumPhysicalAddress without looking either. If you stick with a consistent mapping of terms to shortened version ("maximum" always becomes "max") throughout a code base, these names read (and can be typed) much more smoothly than the 30-character monstrosities common in big frameworks.
- cma 16y agoctrl-x p
- greyman 16y agoI program in C++ and not C, but in my opinion, unless we are talking about a very small project, it is even wrong to have a global variable, not to mention naming it maxphysaddr! If it is some utility with 50 lines of code, then ok, but otherwise it's a maintenance nightmare to have such names. As a local variable, it is ok to have "ii" for loops or "p" for pointers, though.
- eru 16y agoGlobal variables are semi-OK as long as you don't mutate them. Lots of project have global functions and global classes, and nobody cares.