www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/12/03:07:30

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro future
Date: Wed, 11 Dec 1996 21:00:12 +0000
Organization: None
Lines: 42
Distribution: inet
Message-ID: <csRE8PAcDyryEwpr@talula.demon.co.uk>
References: <32ACC368 DOT FA3 AT nlc DOT net DOT au> <58k7bo$rov AT news DOT csus DOT edu>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

GEORGE ARUGAY MONTEMAYOR <gmontem AT mercury DOT sfsu DOT edu> writes:
>shaman AT nlc DOT net DOT au wrote:
>:      Another question: Why is allegro pure C? Why not C++? Some of the
>: things in allegro are just crying out for proper OO. Take the bitmaps
>: for example. Now we have "create_bitmap" and "destroy_bitmap". Why not
>
>One word: speed.  OO is slow.

<enter holy war mode>

I don't believe that, as long as you know what you are doing and only
use OO features where they are appropriate. Most of the things that
cause overhead (passing the 'this' pointer to member functions, calling
virtual functions, etc), should only be used if they are needed, in
which case they replace another construct which would have produced
exactly the same overhead in C. Of course, it's easy to write bad, slow
C++ code, but that is true of any language.

<end holy war mode>

But that isn't the point. The reason I wrote Allegro in C is that
because people do disagree about this issue, and C code can be used from
both C and C++. If you want to write wrappers for things like the bitmap
structure I'd encourage you to do so, and release it as an add-on
package. Uusing inline member functions it should be possible to add
wrapper classes to the existing code with pretty much zero overhead.

I did provide one C++ class, the 'fix' object which encapsulates the
fixed point math functions. I didn't do any others, because I didn't
think they were really neccessary.

In fact, a lot of object oriented techniques are already used
internally. In particuar, all the drawing functions are vectored through
a set of pointers, to handle drawing onto different types of bitmap
(mode-X, linear, and at some point in the future probably truecolor as
well). So every time you call rectfill() or blit(), the resulting code
will be identical to a virtual function call in C++...

/*
 *  Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
 *  Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in nation'.
 */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019