The use of capitals ... curious about the logic (if there is any)

I was wondering ... what is the logic with the use of (non)capitals?

We see statements like:
pinMode(pushButton, INPUT);
int buttonState = digitalRead(pushButton);

These suggest a consensus to have a non-capital at the start and a capital in the middle.

Then we also come across library function calls like Serial.println(buttonState); These have just the opposite, while given the above serial.Println or serial.printLn would have made more sense?

Why is it not 'pinmode' or 'PinMode'? Is there logic behind it? Or was it 'just a choice' once made?

check out camelCase

Thx for that link, it was an interesting read.

It tells that capitals are used merely to avoid the use of _ underscores and still be able to distinguish the separate words. Unclear is why the first letter is a non-capital, that was merely a grown consensus, possibly out of lazyness, not having to type a capital :slight_smile:

Still unclear why Serial.println then is not quote what I'd expect using camelCase.

That's the problem with open source. Different contributors will have their own quirks. Hence, the inconsistency of naming conventions.

Generally the name of a class is capitalized. That is why Serial.print as serial is a class, whereas digitalWrite is a function and is camel case.

camelCase originated at Xerox PARC I think on workstations that had no underscore
key. Something I came across reading about the language Mesa after researching
different monitor types (Hoare, Mesa). But that's another interesting story.

camelCase is horrible to read, underscores are hard to type (shift key needed), in some
languages you can have '-' in identifiers which-is-a-lot-better-to-type. Algol68 was a
language where spaces were allowed in identifiers, which was the best solution IMO.

When I saw your subject line I thought you meant capitals as in:

HELP ME WITH MY PROJECT TO BUILD A MARS ROVER BY LUNCHTIME TOMORROW I'M STUCK PLEASE SEND CODES.

It is a code naming convention which is quite well known and industry adopted:

ALL_CAPITALS_WITH_UNDERSCORES_AS_SEPARATORS to identify constant values
CamelCaseWithInitialCapitalLetter to identify classes or user defined data types
camelCaseWithLowercaseInitial to identify methods and functions, variables and member variable, all non constant

Debates have been rushing the developers community if a method like"print URL" should be named printUrl or printURL and so forth: how should you call a variable to identify a laser pin? lASERPin? laserPin? I know the latter sounds much better :smiley:

Regarding the println it should be named printLine, but if you look at many languages you'll find they all use the contract all lowercase form so if 90% of your users are used to use that why change and introduce confusion?

There are other naming conventions, another very popular one was the hungarian notation: something I did never like, but I had to learn nonetheless.

OK, so, as it seems camelCase, with a few additional agreements, became sort of an 'unwritten standard' for reasons of a missing underscore on a certain workstation. That's an interesting history.

I wonder what key we have to disable on our keyboards in order for camelToe to become the the new standard ?

RudyB:
OK, so, as it seems camelCase, with a few additional agreements, became sort of an 'unwritten standard' for reasons of a missing underscore on a certain workstation. That's an interesting history.

I wonder what key we have to disable on our keyboards in order for camelToe to become the the new standard ?

That would be the XXX key :wink: