| Path: |  icdoc!uknet!mcsun!uunet!think.com!spdcc!iecc!compilers-sender | 
| From: |  dds@doc.imperial.ac.uk (Diomidis Spinellis) | 
| Newsgroups: |  comp.compilers | 
| Subject: |  Re: Why is compiled basic slower than C | 
| Keywords: |  Basic, C, performance | 
| Message-ID: |  <92-08-053@comp.compilers> | 
| Date: |  12 Aug 92 12:12:03 GMT | 
| References: |  <92-08-042@comp.compilers> | 
| Sender: |  compilers-sender@iecc.cambridge.ma.us | 
| Reply-To: |  Diomidis Spinellis <dds@doc.imperial.ac.uk> | 
| Organization: |  Compilers Central | 
| Lines: |  27 | 
| Approved: |  compilers@iecc.cambridge.ma.us | 
| Content-Length: |  1265 | 
BASIC has many features that are inherently slow.  Comparable programs
written in C do not rely on such features, and therefore, generate faster
code.  The most important features of BASIC that result to slow code are:
1. All numeric computations are done in floating point by default.
   One must explicitly name a variable with a special integer suffix
   code, to declare it as an integer.
2. String operations rely on the dynamic memory allocation and
   garbage collection.  Both are slower than the staticaly
   allocated string memory / programer controlled allocation and
   disposal schemes that C programmers use.
Furthermore, in PC environments, C programs often directly control the
hardware of the output devices (e.g. screen) by using pointers to the
memory associated with them (e.g. screen buffer).  The same operation can
be expressed in BASIC only in a more roundabout way (usualy through a POKE
operation) and will therefore be slower.
Diomidis
--
Diomidis Spinellis    Internet: <dds@doc.ic.ac.uk>  UUCP: ...!uknet!icdoc!dds
Department of Computing, Imperial College, London SW7
-- 
Send compilers articles to compilers@iecc.cambridge.ma.us or
{ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
Newsgroup comp.compilers contents 
Newsgroup list 
Diomidis Spinellis home page
 
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.