30

Just curious why the C++ standard library uses all lower case and underscores instead of camelCase or PascalCase naming convention.

Personally, I find the latter much easier to deal with when typing out code, but is there some kind of legitimate reason to use the former?

Spikatrix
  • 20,225
  • 7
  • 37
  • 83
CuriousGeorge
  • 7,120
  • 6
  • 42
  • 74

2 Answers2

25

Main reason : To keep compatibility with the existing code, since they have done it with C also.

Also have a look at these C++ Coding standards, which presents some generic reasoning regarding the importance of convention.


These links discusses about the naming conventions of C/C++ Standard Library.

Sebastian Mach
  • 38,570
  • 8
  • 95
  • 130
Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164
  • Useful link. Thanks! Here's another set of guidelines I've used in the past http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml – Ade Miller Mar 24 '11 at 03:56
  • That's what I thought, and I do agree with the reasoning...but I think Microsoft would do well to agree as well XD – CuriousGeorge Mar 24 '11 at 04:56
  • 24
    *"go through the C++ Coding standards"* - they're not *the* standards, they're one person's attempt to write up what they consider best practice, and at odds with many other peoples' equally-valid preferences. The way you've phrased it implies the linked suggestions have more credibility than they do. A quick google would turn up dozens of alternative standards - they best idea is to read over a few to flesh out some background knowledge of the pros and cons on any specific issue, then look at what practices the code base you're working in is already using - see whether it's worth changing. – Tony Delroy Sep 07 '15 at 09:05
  • 1
    I have rewritten the section talking about "the" coding standard. As it was, the message possibly implied was simply wrong. – Sebastian Mach Nov 06 '18 at 09:01
8

Convention. They've done it that way all along, since the C days and before...and didn't see a good reason to break from that convention (not to mention potentially break compatibility with tons of existing code) just to add caps to a bunch of function names.

cHao
  • 84,970
  • 20
  • 145
  • 172