From: lezz@merlin.dev.cdx.mot.com (Lezz Giles)
Subject: Re: The need for an assembler (was: Favorite CPU)
Reply-To: lezz@merlin.dev.cdx.mot.com (Lezz Giles)
Organization: Motorola Codex, Canton, MA
Date: Fri, 28 Aug 1992 22:26:16 GMT

My next $0.02 cents worth:

A programmer uses the most suitable tools for the job.  For a lot of
us, the code that we're writing will probably outlive the current
architecture that we're working on (e.g. they'll upgrade the processor
from an 80386 to an 80486, or from a 68030 to a 68040, or they
may even upgrade to a RISC processor!).  If I write any more than a tiny
amount of my code in assembler then any upgrades like these will mean
a significant amount of rework.  If I write my code in a HLL (_any_ HLL -
C is probably better than others currently because it's fashionable, which
means that you can get an ANSI C compiler for just about any target
processor, but next decade it will (hopefully) be a different language)
then, as somebody else said, I just need to tell my compiler what the new
target is and magically I have a program working on the new architecture!

For those of you who treat the last sentence with some sceptisism, just
ask yourselves what would've happened if perl or gcc had been written in
assembler:-)

Once again, I don't want to say that assembler is a Bad Thing.  Also
notice that I'm not saying anything about ease of programming, speed,
or anything else.  I'm just saying that if you program in assembler for
an 80386 then your program will run well on an 80386, sub-optimally on
an 80486 and not at all on an 80286 (and forget about a 68030).  If you
program in ANSI C then your program will run on more or less anything.
If you program in C plus standard Unix extensions (like perl) then
your program will run on more or less any Unix box and (if you can find
a friendly compiler) just about any other machine too.  If you program
in any other HLL then the same applies, though you may have to look harder
for a friendly compiler.

If on the other hand you're interested in shaving microseconds off the
execution time of your code and you are confident that it will only ever
be executed in one environment then go ahead - use assembler.

I'm also not saying that ignorance of assembler is a Good Thing.  Ignorance
is almost never a good thing, and if you're a good programmer then IMHO
you _should_ understand how a computer works - right from how a transistor
works up through gates and flip/flops, through PLAs and ULAs, through data
paths and busses, through microcode, through assembler, through high level
languages, right up to 4GLs.  Each level of understanding has something
to contribute to "good programming" (well, Ok, maybe understanding the
quantum mechanics underlying a transistor aren't too relevant :-).  You
should also have a good understanding of information theory, compiler
theory, grammars, mathematics, etc. etc.  Assembler is just one, relatively
small, part of a much larger whole.

Now for the disclaimer.  If you're writing an OS then almost certainly
there will be machine-specific parts that must be done in assembler.
Similarly if you're writing a real-time application then there probably
will be time-critical parts or parts that talk directly to the hardware
that need to be done in assembler.  In these cases, though, you should
minimize the assembler and maximise the HLL so to move to a new machine
you have only a little to recode.  Also if you're writing for a very
specific market (e.g. 8086 PC-compatibles running MS-DOS) and you know
you're not interested in other machines then assembler is one choice -
though for other reasons I'd still go for an HLL.


Lezz "bring on the flames!" Giles
Newsgroups: alt.folklore.computers,comp.unix.misc