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-18 18:50

>>23-26
C optimizing compilers make you write unintuitive, slow code to be able to use certain machine instructions, but the only reason you have to write that code at all is because C has a poor interface to the hardware.

They say ``C is great because it gives you the power of assembly'' but it doesn't. Assembly lets you do something in one instruction. C makes you use a complicated expression or loop. This makes assembly more powerful than C. Why would you use a so-called higher-level language that makes you write more code than assembly language?

They say ``C lets you talk to the hardware'' but it doesn't. It gives you no control over the layout of data structures. It gives you no control over I/O ports or memory. It doesn't even guarantee that malloc (or any other standard library function) is actually called. The only tool it gives you is raw pointers, which you can use in almost any non-scripting language, including BASIC, Java, and Haskell. It also forces you to use raw pointers instead of arrays, which prohibits all of the optimizations and high-level operations that are possible with arrays.

Most students have never used a non-scripting language without garbage collection besides C and C++. The makers of all these new systems languages like Rust and ATS think C flaws are fundamental to the hardware and systems programming, but they're not.

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