Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Coding Standard Nazis

Name: Anonymous 2015-02-15 10:59

http://wiki.wesnoth.org/CodingStandards

Do not use #define for constants
#define foo X is not a typesafe approach to define constants. Instead, you can something like the following (in an anonymous namespace) to achieve the same goal in a typesafe fashion.

Do not use C-style casts
The following code,
if(i->second.side() == (size_t)player_number_) {
is considered bad practice in C++ since a C-style cast is overpowered -- if types change around it could end up casting away constness, or performing an implementation-defined data reinterpretation (basically a C-style cast is a compiler-generated combination of static_cast, reinterpret_cast, and const_cast).

Name: Anonymous 2017-01-17 1:00

Thanks to strong typing and optimizing compilers, nowadays it's possible to get better performance with C++ than C without even trying. C code has to be fine tuned by someone who used to write assembly to catch up to the magic that some optimizing C++ compilers do. There's no pride in, as a human, knowing how to make tiny insignificant operations fast. What matters is higher level algorithms nowadays, which is harder. Just as automation/good algorithms is taking away the jobs of toilet scrubbers, so will it replace ASM-worshipping, bit-licking, imperative skiddies like Cudder.

Name: Anonymous 2017-01-17 2:17

>>19
Except C compilers optimize too, and they usually do it better than C++ compilers do. The best ``optimization" you can do as a C++ coder is to write in an idiomatic C style, because that's easier for compilers to optimize. A C compiler is smart enough to optimize away some of the common function calls, but a C++ compiler can't figure out the programmer's intent, if you tell it to use a big bloated class, it will use the whole thing, it's not smart enough to figure out which specific features of that class you need. The programmer thinks they're asking for an array on the heap that can be resized at runtime, but the compiler gives you some bloated exception-throwing monstrosity instead.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List