News for hackers. Stuff that matters.
Re:Rob Pike: Notes on Programming in C by rauljara on Tuesday November 09, 2010 @03:15PM (#1887745)
I think it's helpful to have criteria like this out there, so that we can discuss them. That said, what's with the bias against capital letters? maxphysaddr is more readable than MaxPhysAddr? godisnowhere is more readable than GodIsNowHere? Or is that GodIsNowhere? I'm personally a fan of coding styles that cut down on ambiguity.
Re:Rob Pike: Notes on Programming in C by jmulho on Tuesday November 09, 2010 @05:11PM (#1888148)
I prefer god_is_nowhere. The easiest thing to read is what you are used to. To fairly compare godisnowhere, GodIsNowhere, and god_is_nowhere, you need to stick with each for several days. I bet you'll discover, as I have, that god_is_nowhere is the easiest to read.
Re:Rob Pike: Notes on Programming in C by TheNewAndy on Wednesday November 10, 2010 @04:40AM (#1889761)
It makes the distinction between god_is_no_where and god_is_nowhere much clearer than GodIsNowhere and GodIsNowHere. A slightly more subjective one is for things with acronyms in them. Compare: check_url_index, CheckURLIndex and CheckUrlIndex.
Re:Rob Pike: Notes on Programming in C by amh on Tuesday November 09, 2010 @04:06PM (#1887903)
I think "godisnowhere" is more an example of a straight-up badly chosen name (identifiers should not be complete sentences) rather than a case where caps are better than lowercase.

I'm not against camelcase and its variants, but there are a wide variety of naming standards using caps, it's quite possible to get mixed up between them and introduce ambiguity or worse (referring to the wrong variable).

Re:Rob Pike: Notes on Programming in C by TheNewAndy on Wednesday November 10, 2010 @04:41AM (#1889764)
I believe the intention of this name was the parsing ambiguity of the word "nowhere" when you don't have word delimiters, not as an example of an actual name, or a statement about the location of God :)
Re:Rob Pike: Notes on Programming in C by epo on Wednesday November 10, 2010 @07:01AM (#1890000)
Surely, that's his point, putting an ambiguity into a variable name is just asking for trouble, choose a better name.
Re:Rob Pike: Notes on Programming in C by TheNewAndy on Wednesday November 10, 2010 @07:27AM (#1890041)
The ambiguity isn't in the name on its own "God is nowhere". It is in the combination of that name, and a bad naming convention.

If you had a naming convention which prohibits vowels, then the identifier "shrt" is ambiguous because it could be "short" or "shirt". That doesn't mean that "short" is a bad name for an identifier.

Re:Rob Pike: Notes on Programming in C by antirez on Tuesday November 09, 2010 @05:21PM (#1888192)
iLoveFunctionLikeThis() but I must admit this is one of the rare case of useless tip in this article. All the rest is almost gold for C programmers.

What is funny is that reading it will hardly make me or you a better programmer because most of this things will take anyway years to be fully understood / mastered, and of course it's an endless process of refinement.

But still very useful to read what we should try to focus on when writing good C code.

Re:Rob Pike: Notes on Programming in C by georgecmu on Wednesday November 10, 2010 @09:07AM (#1890229)
We use capital letters, and so half the timestamp variables are named xxxTimestamp and the other half yyyTimeStamp, which makes it a fun guessing game.
Re:Rob Pike: Notes on Programming in C by greatfog on Thursday November 11, 2010 @07:00PM (#1895905)
The yyyTimeStamp form could be useful if the program also dealt with postage stamps, rubber stamps, and food stamps.