Why is Serial not in camelCase?

Serial is an object of class HardwareSerial.
The convention is to use camelCase for naming variables.
Why is Serial not in camelCase? I know it's not technically needed to be, I'm just curious to see why such design choice was made.

Interesting comment but what are you referencing?

I'm referring to the Serial object instantiated in HardwareSerial.
line 143 extern HardwareSerial Serial;

As far as I know, someone on the original Arduino team decided that 15-20 years ago, and it has been that way ever since. Why should anyone care?

3 Likes

I am having a problem reading line 143 in your post. But does it really matter in the end? Why are houses different colors?

because for people who want to delve into the Arduino language more, confusion can arise to whether or not Serial is a class or an object. I thought Serial was some kind of static class like in Java.
I thank you for your effort, and I wish there is more empathy.
Sure, not everyone is interested in this topic, but just because majority doesn't care about a topic, is it not worth investigating or questioning? Isn't that what education is about? Frankly, it's always the people who doesn't know the answer to the question always deflect the question back with appeal to practicality or appeal to popularity. I understand it's a form of defense mechanism, but there is nothing wrong with not knowing the satisfactory answer and just moving on.

Do you think camelCase is a required naming convention?

1 Like

I think that's probably why. Arduino is targeted at true newbies and it's usually easier to grasp when it appears to work that way. Later on they can learn about OOP and then they can learn that Serial is an instance of a class.

I have learnt from this Forum that a mult-word identifier follows camelCase formatting style. Serial is a single word identifier (the object). For example:

byte myVariable;

camelCase doesn’t capitalize the first letter.

OP is right, in true camelCase naming convention it would be serial.

A guess: Some coders have a convention that constant should be in full capitals (like they have HIGH LOW INPUT OUTPUT INPUT_PULLUP…)

May be the original coder wanted to signify that Serial was close to being a constant - something that’s there and already customized for you to use, the only instance of a special class.

May be originally Serial was a class with just class functions and they kept it as such for compatibility reason?

May be it’s just a plain mistake …

But, class names are usually Snakecase. For example:
Snakecase

1 Like

I think the original intent was to imply that Serial was a static class. It's even possible that in the beginning it was a static class and ever after the name just stuck.

1 Like

Yes even in Arduino Land they have this convention too. HardwareSerial0 is the underlying class for the Serial instance. it has a capital H.

1 Like

The lesson for beginners is to never assume the type of an identifier based on it's name.

Even if one project uses a naming convention 100% consistently (which never happens), a different project may use different naming conventions.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.