[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

why no camelCase in PEP 8?


We have now moved into a pros/cons discussion of snake vs camel-case,
which wasn't the original question. But discussions about coding styles
are always fun, so why not... :-)

I agree with Eli's reasoning about the grep-ability. It's something
that people don't often pay attention to, but that is actually really

One more note about the readability:

A good friend of mine is a great developer, but has incredibly poor
eye-sight. For him it's very important that the code has easily
recognizable patterns. Imagine you'd have to try to make sense of code
when you could only squint at the screen and see everything fuzzy and
you get the idea. For what are now immediately obvious reasons he
prefers snake-case.

His concerns about reading code and recognizable patterns have been a
guide in the development of my own coding style for more than 20 years
now and it has served me well.


On Mon, 2020-05-18 at 21:07 +0000, Eli the Bearded wrote:
> In comp.lang.python, Paul Rubin  <no.email at nospam.invalid> wrote:
> > I don't know if this was the explicit motivation for PEP 8, but it
> > has always seemed valid to me:
> > 
> > https://en.wikipedia.org/wiki/Camel_case#Readability_studies
> There are three things cited there. One is a NYTimes story from 2009
> "Against Camel Case" starting out with criticism of "iPhone" which
> the author describes but won't use as it it too difiguring. That's
> not a
> programmer talking about program identifiers.
> The other two are more relevant, two studies one from 2009 and one
> from
> 2010, each of which seems to reach a conclusion at odds with the
> other.
> The 2009 one finds camelCase easier to read than snake_case, and the
> 2010 one finds people recognize snake_case identifiers faster than
> camelCase ones. I don't think that Wikipedia page helps your case.
> I personally abhor the use of inappropriate mid-word caps in English,
> which fits the NYT piece, but am only mildly against them in code. I
> had
> some bad expierences with code that forced use of capital letters in
> college and that has tainted me against excess capitals ever since.
> This
> is a highly personal reason that I don't expect anyone else to share.
> Here's a simple argument against camel case: when it becomes
> necessary
> to join identifiers, camel case requires modification of the original
> unit while snake case just adds stuff to beginning and/or end. One
> noteworthy example is when a negated version is needed.
> 	camelCase	->	 noCamelCase
> 	snake_case	->	 no_snake_case
> One of those is easier to "grep" for than the other.
> Elijah
> ------
> grep-ability of code should on everyone's mond