Glenn_Johansson@f313.n203.z2.fidonet.cd.chalmers.se writes:
|> [How much slower is compiled Basic than C, and why?]

There has been a lot of work put into optimizing C compilers: the efforts
of FSF, Sun and MIPSCO to mention but three. There hasn't been a great
deal of work put into optimizing BASIC compilers, at least not that I know
of.

There seems to be a more general problem though: compilers of high-level
languages tends to produce optimal machine code, whereas compilers of
low-level languages tend to produce sub-optimal machine code.

Some time ago, code produced by an Algol68S compiler was compared to code
produced by an optimizing Fortran compiler on an ICL1906. The program
compiled from Algol68 ran 30% faster than that produced from the Fortran
compiler. The reason for this seems to be that the high-level language
compiler has a better idea of what the programmer is trying to do and can
make appropriate optimizations-- such optimizations frequently show up as
doing nothing at all where another programming language would require code
to be executed, or use a single machine instruction for coping where (C
for example), would use a loop. This form of optimization, of course, is
largely wasted on RISC machines, although the compiler can still exercise
the right to copy, say, 4 bytes at a time whereas the C program forces a
byte by byte copy.