home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!ogicse!das-news.harvard.edu!spdcc!iecc!compilers-sender
- From: jch@rdg.dec.com (John Haxby)
- Newsgroups: comp.compilers,comp.lang.basic
- Subject: Re: Why is compiled basic slower than C? (Basic is the future)
- Keywords: Basic, C, performance
- Message-ID: <92-08-049@comp.compilers>
- Date: 12 Aug 92 08:43:32 GMT
- References: <92-08-042@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Reply-To: jch@rdg.dec.com (John Haxby)
- Organization: Digital Equipment Corporation
- Lines: 32
- Approved: compilers@iecc.cambridge.ma.us
-
- 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.
-
- --
- John Haxby
- Digital <jch@rdg.dec.com>
- Reading, England <...!uknet!wessex!jch>
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-