Re:Have Tracing JIT Compilers Won?
by andrewcooke on Wednesday March 10, 2010 @08:12AM
(#1180810)
not arguing with your general point, but the difference between pre and post increment is very useful when writing things like stacks and queues with pointers. these days maybe people use libraries or templates, but i suspect they were introduced for ease of programming, not ease of translation.
[edit: really, it's two sides of the same coin. it's useful, so both c and cisc chips have it, so the two match up...]
> not arguing with your general point, but the difference between pre and post increment is very useful when writing things like stacks and queues with pointers.
Of course this only applies to ephemeral variants of those data structures.
For example, the pre and post increment operators are expressions with side effects, can be confusing and can provoke undefined behaviour with ease. Having two variants also seems redundant. But the two variants may have different optimal translations to underlying CPU addressing modes, while leaving the pre or post modified value in a register is often a side-effect of the CPU translation. If the language only permitted ++ as a statement, the usefulness of side-effect would be lost.
It's a cliche that C is little more than portable assembler, but at a design level there's a lot of truth to it. The length of the assembly translation of C code is usually pretty directly proportional to the source code token length. In more expressive languages with more powerful abstractions, that's frequently not the case.