camelCase: ugly or evil? Embrace the healing power of "and"!

K&R style vs camel case

There are two main approaches to dealing with variable names consisting of multiple words.

One approach – the right one – we will call K&R style. It has been around since the 1960s but was widely popularized by its use in the extremely influential book The C Programming Language by Brian Kernighan and Dennis Ritchie (K&R) in the 70s and 80s.

K&R style looks like this:

	i_am_a_variable = 3.14
	left_margin = 42
       
Words are not capitalized and are separated by underscores.

The alternative convention for multi-word variable names is called camelCase or CamelCase. You have encountered this style in such "words" as PowerPoint, FedEx, and iPhone. In camelCase the first letter is not capitalized, but the initial letters of subsequent words are:

	iAmAVariable = 3.14
	leftMargin = 42
      
In CamelCase all initial letters are capitalized:
	IAmAVariable = 3.14
	LeftMargin = 42
      

You should use K&R style because: