C is not a low level language
On Mon, 25 Feb 2019 13:05:32 -0500, nospam
wrote:
In article , NY
wrote:
but I know that the Z80 routine was
several orders of magnitude faster than the same algorithm in interpreted
BASIC and several times faster than a compiled Pascal program with the
same
algorithm.
that just means the compiler wasn't any good.
yep, and it's *really* hard to beat a modern compiler
The compiler in question was Turbo Pascal of mid- to late-1980s vintage,
running on a Z80 under CP/M 3. I'm not sure how efficient that was.
that's not a modern compiler nor a modern processor either.
As you
say, modern compilers may well be more efficient - but they may also bloat
the code with code that was never actually called but was compiled in
nevertheless ;-)
they don't, but even if that were true, code that is not called can't
slow anything down.
I should have tried to code a more efficient sort algorithm than bubble
sort, to see how much improvement there was, but bubble is simple to
remember (*) and to code, and I was doing it as a programming exercise
rather than with a real-life application that needed the fastest sort
available.
(*) I can remember it without needing to look it up every time, and I can
visualise exactly what it's doing, whereas shell sorts start to make my
brain hurt working out what they are doing ;-)
bubble sort is very easy to write, it's just not fast.
Insertion sort is even easier to write. And it's usually twice as
fast as bubble sort.
|