Re: C# very optimisation



"Helge Jensen" <helge.jensen@xxxxxxx> wrote in message
news:#haw$47WFHA.3584@xxxxxxxxxxxxxxxxxxxxxxx

> but since the dawn of time C-programmers have preferred the (1 character
> shorter) "i++" to "i+=1". There have *never* *ever* been *any*
> performance-reason for this.

No, actually there was. Remember that the original C compiler was
written for a very small machine -- one which measured memory in KB, not MB
(and probably measure it with only 2 digits or fewer)

Nothing about it the language is superflious. If the syntax was
different, the code produced would be different. The best way to see this
is to consider what you can't do with a particular syntax:

The most basic form is
A = B + C;
This would translate into assembler to basically:

ld temp, B ; load B into temp
add temp, C ; add C to temp;
ld A, temp ; Load temp into A

Since the compiler was very stupid with no optimizations, ANY statement
written in that form would be translated the same way.

But, sometimes, you wanted to write:
A = A + C;
This could be translated the same way, but there's a faster way:
add A, C; ; add C to A
But a different translation required a different syntax, hence:
A +=C;

But, sometimes, you wanted to to write:
A = A + 1;
This could be translated the same way, but there's a faster way:
inc A ; increment A
But a different translation required a different syntax, hence:
A++;
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com



.



Relevant Pages

  • Re: syntax directed translation
    ... > Are syntax directed translation and syntax directed definition ... appearing in that production. ... and the semantic rules as separate items that are paired with each ...
    (comp.compilers)
  • Re: Aspects of programming languages in common
    ... A lot of language suites consist of front ends for C, ... They undergo a syntax evaluation before being ... > My understanding of the proposal is to perform the translation to ... There would then be a consistent base upon which to build the parse tree, ...
    (comp.programming)
  • Re: General Compiler question
    ... This is general compiler questio, ... Lets say I have to read in a file in.txt, reformat its content and ... syntax in in.txt into stanndatd C syntax. ... translation dictionary as followes: ...
    (comp.compilers.lcc)
  • Re: Emacs in ANSI CL
    ... A lot of translation is just syntax. ... The bigger problem, I believe, is translating the large body of ... > conversion effort of this kind already as to whether any of the ...
    (comp.lang.lisp)
  • Re: Aspects of programming languages in common
    ... A lot of language suites consist of front ends for C, ... My understanding of the proposal is to perform the translation to ... a "neutral" language before performing any syntax checks. ... number in the original source code? ...
    (comp.programming)