From: mykes@amiga0.SF-Bay.ORG (Mike Schwartz)
Newsgroups: comp.os.os2.advocacy
Subject: Re: Is portability more important than performance?
Distribution: world
X-NewsSoftware: GRn 1.16f (9/19/92) by Mike Schwartz & Michael B. Smith
Date: 30 Sep 92 00:53:11 PST
Organization: Amiga makes it possible

In article <717465106snx@noyles.pha.pa.us> juan@noyles.pha.pa.us (Juan J. E. T. Noyles) writes:
> petesk@microsoft.com writes in article <1992Sep25.102940.28208@microsoft.com>:
>
> >
> > In article <1992Sep24.173731.29601@news.iastate.edu> TW.FY4@isumvs.iastate.edu wrote:
>
> > >	On the subject of portability (hate to bring up an old thread
> > > but...), I understand that most of NT is in C, and a lot of OS/2 is
> > > also in C.  Wouldn't the programs be shorter and quicker if they
> > > were in assembly, or something?
> >
> > This is a popular discussion between me and some of my friends.  I generally
> > take the "C is a good thing" point of view.
> >
> > Things that are absolutely time critical, and can't be portable at all
> > should be written in assembly.  This includes things to do with low
> > level hardware, the task switcher of the os, etc.  The BitBlt function
> > of your graphics engine is also a good place to use assembly, maybe.
> >
> > However, due to the law of diminishing returns, the work usually stops there.
> > It becomes very difficult to keep portability between systems when they
> > are in a machine dependent language.
> >
> > The code is also sometimes hard to manage.
> >
> > Also, take a look at the output of a good C compiler.  In many cases, it's
> > output is as good as most assembly code written by humans.	It usually takes
> > time to really trim things down in assembly, so stock code is average
> > when compared to a good compiler.
> >
>
> First, I'd like to applaud Pete for giving his unbiased opinion.  Straight talk
> is sorely missed in this forum, making it usually sound like a politicians
> convention.
>

Yeah, me too.

> I branched this conversation off onto this subject because I'd like to know
> what factors make performance inversely proportional to portability.	As far
> as I know, the manual use of assembly language is generally reserved for
> optimization.  What do you gain from the tweaking that would apply to OS
> optimization?
>

Well, as you can tell from my .sig, I am into the amiga (and for a long
time).	I am now bigtime into OS/2 and like it a lot.  That aside, with
a multitasking operating system, the more cpu cycles your app gets before
getting swapped out or the CPU given to another task, the more your app
gets done in real time terms.

This argument went on for months in the Amiga groups.  Then some assembly
hacker coded up LHArc in assembly, and the speed difference is night and
day.  The assembly version really zips, and the 'C' version really crawls.
And the 'C' version was compiled with the best compiler technology around.
And to top it off, the author says he has a 30% faster version for you if
you pay the shareware fee.

To answer a direct question about tweaking the OS - even if all
apps aren't written in assembly, every single one that calls the OS benefits
from the tighter and faster human generated machine code.  If IBM can do
those kind of speedups in the once centralized place (OS), then we developers
don't have to reinvent the wheel to optimize our applications for performance.
And each of us are redundantly doing this :)

For CISC CPUs, the statement that a compiler generates code as good
as a human being is simply false.  Not even close.  A compiler is not likely
to use the CPU instruction set to its fullest, or track register usage across
multiple functions and files as well as a human being can.  And a compiler
can only have a predefined and fixed number/set of assembly programming
tricks built-in, while humans have the ingenuity to invent new such tricks
all the time.  The maintainability issue is equally dubious, IMO, because
those that claim assembly isn't maintainable are either very used to using
high level languages, or haven't had the experience of writing significant
programs in assembly language.

Let me conclude by saying that I am not suggesting that everything be coded
in assembly language and the high level languages be damned.  What I do
believe is that a program like LHA in assembly that runs 10x faster than
the one in 'C' is a good example of when to use assembly.  You have a program
that you might use a LOT, and downloading the assembly version is cheaper
than buying a 10x faster motherboard.  The Amiga programmer who writes
his C++ compiler in assembly language is likely to make a fortune :)


> --
> Has anyone seen your sanity?				Juan@Noyles.pha.pa.us

--
Amiga programmer of: GRn, MailMinder, Budokan, Beyond Dark Castle, Dark Castle
Sega Genesis programmer of: Dick Tracy and Marble Madness.
Mike Schwartz  (ames!zorch!amiga0!mykes or mykes@amiga0.sf-bay.org)
1124 Fremont Ave.
Los Altos, CA 94024

Newsgroups: comp.os.os2.advocacy