5

snake_case seem to be the convention in most of the C sources I've come across. camelCase is more comfy to type. Is there a good reason not use camelCase instead of snake_case?

I think a source of problems might be that identifiers tend to "leak" onto the filesystem (like when you name a file after an identifier), and some filesystem might not handle case-sensitive names well. But is that still a thing on platforms of 2015 worth porting to?

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142
  • 1
    Possible duplicate of http://stackoverflow.com/questions/5414511/why-does-the-standard-c-library-use-all-lower-case – Marco A. Sep 07 '15 at 08:36
  • I have never seen anyone deliberately name a file after an identifier in a program outside "Introduction to programming" classes. – molbdnilo Sep 07 '15 at 09:12

1 Answers1

26

There are papers about readability, e.g. [1].

Although, no difference was found between identifier styles with respect to accuracy, results indicate a significant improvement in time and lower visual effort with the underscore style" [1]

[1] "An Eye Tracking Study on camelCase and under_score Identifier Styles ", Bonita Sharif and Jonathan I. Maletic, http://www.cs.kent.edu/~jmaletic/papers/ICPC2010-CamelCaseUnderScoreClouds.pdf

damg
  • 629
  • 4
  • 7
  • 7
    Very interesting paper! I just love it when there's actual scientific studies about things like this, instead of subjective opinions by random programmers. – Lundin Sep 07 '15 at 09:34