Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the heavy use of abbreviation in C/C++? [closed]

Tags:

c++

c

I've been reading up on C and C++ lately and can't help shake the feeling that C/C++ programmers use abbreviation way to excessively in variable and function names. I can't see a reason why this would be beneficial, since both are compiled languages. Practically all code I've come across uses abbreviation more than in other languages (my personal experience, of course).

So the question then becomes this; is there a reason why you'd want to use abbreviations in C/C++? Are there performance issues with using longer variable names, or is it just a convention?

EDIT: Looks like I opened a can of worms here. I was hoping for a yes/no answer, not a discussion on coding style.

like image 309
Oskar Eriksson Avatar asked Nov 21 '12 09:11

Oskar Eriksson


1 Answers

It's mainly a convention.

There was some historic need, since early C compilers didn't guarantee that identifiers were significant to more than 8 (or maybe even 6) characters in some cases (causing MyFantasticFoo and MyFantasticBar to be considered equal by the compiler). Modern compilers don't have such tight limitations, see this answer for details.

Today, I think it's more of a convention/style issue, that C code is often terse.

like image 135
unwind Avatar answered Sep 25 '22 20:09

unwind