Paul said:
Nownownow Jack, that's not the right attitude for a C programmer ;-)
But it's the right attitude for clc. You can introduce specific
architectures if you want to cite examples of how different
implementations will yield different results. But readers should
not be encouraged to think of C in terms writing code for one (or
two) specific architectures.
Don't you think our non-Assembly programming C brothers/sisters
have a right to know that a division is typically slower than an
addition, for example?
Yes, but I don't want to see discussions of say opcodes and actual
cycle/latency times on an x86.
Or is such a statement off topic here because the Standard doesn't
mention this? (even though it is true in the real world).
The critical point is that what the standard(s) do say in terms of
language semantics are the priority.
...
A lot of decisions made for the implementation of the compiler make
more sense (like the difference in sizeof(int) the OP experienced)
when the underlying computer architecture (which the compiler
targets) is explained.
CLC is not here to discuss implementations and their internals.
There are plenty of other groups that discus that. CLC is here to
discus C programming, i.e. writing C code that is portable to all
implementations.
It is a natural human (or at least programmer) tendancy to want to
disect C code in terms of disassemblies and working out what the
compiler actually does with source code. However, it has been my
long experience that this only coerces students of C (and other
languages) into writing architecture specific code. The consequences
of this attitude can and often does come back to haunt students.
Unlearning acquired bad habits is difficult and time consuming.
Of course, we could deny the fact that programs written in C are
actually meant to run on a computer.
Who is denying this? C's main goal was to implement Unix and
associated tools. You don't get much more practical than that.
But this would reduce discussion to a completely academical one,
interesting only to mathematicians and linguists and devoid of
practical experience.
CLC is an esoteric group in that it does focus exclusively on the
application of the language definition, without trying to motivate
readers towards specific architecture specific trends.
How does it harm students to understand the language abstraction?
We would just be quoting the Standard all the time.
And what is wrong with that? Too few C programmers sit down to
actually analyse the language they are employing. This just
promotes a 'near enough is good enough' approach. With a language
like C, this is a dangerous attitude.
Time and time again you will see people questioning why certain
code works on one machine but not on another. The reason is invariably
because they have been using (and been encouraged to use) Machine-X C,
rather than learn the portable aspects of the core C language itself.
If you want language efficiencies on specific architectures, then
there are no shortage of groups that can help. On the other hand,
discussing strictly conforming code has pretty much only one group,
namely clc (and language/moderated) derivatives.