<n24bst$m9f$
1...@dont-email.me> thusly:
>Note that I am not arguing against the use of enum for constants. What I
>really do not like is the implicit pejorative use of the "C programmer"
>here.
If you're programming in C++, you should use C++ idioms, not C idioms.
You can program in C if you want to, I don't care.
Every time some Java programmer or C# programmer tells me how shitty
C++ code is, I ask them to show me the code.
THEY SHOW ME C CODE.
It will be full of buggy C-style string manipulation, control flow that
is a giant mess because of the obsession with avoiding exceptions in
the name of "efficiency" but instead causing the main path of the code
to be completely obscured by all the manual checking of error codes
and in-line error handling (exceptions are considered de jure in Java/C#),
and many other horrible habits.
Yes, it can be argued that some of these habits appear in programmers
working in any language. Bad control flow structure and long methods
or classes is certainly something I've seen often in C# and Java code.
However, there is no denying that there is something about the
profusion of examples of C code on the net and "C++" code on the net
that is really C-style programming masquerading as C++ programming
that gives some credence to the point made by C#/Java advocates.
Programming in C is demonstrably error-prone and verbose compared to
doing the same thing in C++. Yet there are certain aspects of C that are
desirable: its execution model maps directly to the actual hardware that
we use and it being the defacto binary API for most operating systems.
C++ is really different from other languages with it's philosophy of
"you don't pay for what you don't use". In Java or C# you don't
really have that option. There's a price for admission to the
language that C++ or C just doesn't have.
When you bring your C coding habits to C++, you bring with you all the
same problems that people have with C. No wonder people bitch that
C++ is a horrible language and they prefer Java/C# over it when every
time some "C++ programmer" creates some code on their team, they
create it with C style programming habits and all the weaknesses that
brings along with it.
I don't care if you want to program in C.
If you want to program in C++, embrace C++ and the mechanisms it has
that were created based on the experience of the shortcomings of C.
Using const and enum are just two tiny examples of where C++ took
advantage of the weakness of C based on actual usage of C and
improved upon it. These improvements are so universally acknowledged
that C itself incorporated those ideas back into the C standard from
C++.
The very fact that modern C includes enum and const is proving my
point and making you look silly by railing against me for objecting to
using #define for named integral constants.