bewing wrote:Generally, I disagree with the above. I am an inventor, not an engineer. I scoff at engineers.
...
No, I won't go there.
But I'll poke at the rest. (Sorry, this will get warm.)
If you always follow the standards, you will never ever discover a significantly better way of doing anything.
In a programming language, there are only two ways to do anything: The correct one, and all the others.
(Next paragraph goes to Shrek, too.)
We're not talking at
what you implement. Fire away, be imaginative, find new techniques. But if you're writing C, then
write C. There's no language called "GCC". Code not adhering to the standard is
broken.
Edit: That might be in excusably little ways, or in blatantly obvious ones, but the code is still, and clearly,
wrong. There is nothing you can do with broken code which you could not do with correct code as well. I challenge you to show me otherwise.
I find that strict adherence to "the rules" will, in fact, often add unneccessary complexity to code and make it less readable.
You mean, less readable
for you...
Not following all the rules is also extremely helpful during development of code. For example, using // for comments EVERYWHERE, and then still being able to comment out large sections of code using /* */ effortlessly is mighty handy.
- C99 does support //.
- If you want to support C89, use #if 0 / #endif (which even nests correctly).
That is exactly what I meant with "negligence". Because you scoff at the standard and don't think twice about taking your shortcut, you're not as good in what you do as you could be.
The reason the shortcuts exist in the first place is that programmers who are willing to experiment a little have found those shortcuts to be a significant improvement to the code, in some way.
And because they were good, they were accepted into the standard (like // was). Until it's in the standard, using it limits you to a
specific toolchain, probably even a
specific version of that toolchain. Toolchains change, and suddenly your code doesn't work anymore. (It's not the toolchain, it's your code, which was broken all the time, only now the toolchain doesn't let you take that shortcut anymore.)
If enough coders are negligent enough, such an illegal shortcut becomes a "historic legacy", and time, effort, and money is
wasted because toolchains have to maintain
compatibility with the bad practices of yesterday. Time, effort, and money that could have been invested in
improving those toolchains instead.
Not even talking about the pains you have brought onto those who had to think around your shortcuts. Chances are, a smart piece of non-standard code that saved you a minute in coding will cost others many times as much in productivity as they have to think around or refactor your shortcut.
Edit: Reading quok below, I realize I should say that I am talking
language standards here. Like, C, C++. I wouldn't touch POSIX with a stick, for example -
there is an example of a "post-mortem" standard that doesn't make
sense to follow to the letter.