Re: OT: programming languages (was: More pens (was Re: Phoneme winnowing continues))
From: | Henrik Theiling <theiling@...> |
Date: | Tuesday, June 10, 2003, 21:49 |
Hi!
Stone Gordonssen <stonegordonssen@...> writes:
> But how many bytes does this instruction occupy after it is compiled?
Source code in C:
for(;;)
compiled with gcc -O2: Assembly:
.L5:
jmp .L5
In machine code (disassembly):
0x80483e3 <main+3>: jmp 0x80483e3 <main+3>
0x80483e5 <main+5>:
Two bytes. As you requested. :-)
(I just checked, the -O2 is not necessary, it even produces only two
bytes without any optimisations, thus with -O0).
> >Well, but, definitely is not anymore. The aim is to have a good
> >compiler and a programmer who tries to feed it with code it
> >understands well.
>
> Perhaps. I've seen some functional but really cryptic C code which
> was extremely hard to maintain.
It's very easy to write cryptic code, of course (especially in
Perl... :-) ). That's usually the programmers' fault. The
programming language can only aid them to produce good code, but
usually not *force* them to do. Modern languages usually try to force
a bit: by a layout rule which most programmers hate when they begin,
but love after they once fail to recognize that the following code
does not do what they might think it does:
b= correct_value;
if (some condition < that they suppose (is false));
b= wrong_value;
**Henrik