Mail Archives: djgpp/1997/09/14/14:57:18
Paul Derbyshire writes:
>I suspect the need now is for Allegro to go OO. Yep, Object-oriented, C++.
I beg to differ. You are equating a design methodology with a
programming language, but the two are really quite different things. You
can write object oriented code in any language, just as you can write
straight procedural code in C++...
I think that object based design is usually a good thing, and I tend to
think along those lines no matter what language I am using, but it isn't
a magic wand that you can wave about to cure all your problems :-)
Making something good is a lot more complicated than that, and getting
too enthusiastic about one particular way of thinking tends to blind you
to all the other interesting possibilities...
In the case of Allegro, while I agree that C++ is in many ways a better
language than C, I think that changing language would be big mistake.
For one thing, it would cause a good three or four months of
concentrated work, when the whole goal of this exercise is to _reduce_
my workload. For another, we would end up with a new API that was
totally incompatible with all the existing Allegro programs, and we
would remove the possibility of Allegro being used with any language
other than C++ (it is easy to call C functions from asm, Pascal,
Fortran, etc, and Peter Monks even wrote a wrapper for using Allegro in
Eiffel programs: that would be almost impossible if it was all written
in C++). Designing a good library is very different to writing
application code: I think one of the most important goals is to make it
useable for the widest possible number of different tasks, which means
always aiming at the lowest common denominator. In the case of
programming language, that is C, not C++...
But maybe most importantly, is Allegro not already quite object oriented
enough? Just compare a typical bit of code:
BITMAP *bmp = create_bitmap(320, 200);
clear(bmp);
putpixel(bmp, 10, 10, 2);
destroy_bitmap(bmp);
with a C++ implementation of the same:
BITMAP *bmp = new BITMAP(320, 200);
bmp->clear();
bmp->putpixel(10, 10, 2);
delete bmp;
To me, it seems that the change is just a matter of syntactic sugar, and
in fact the BITMAP object is being used in identical ways in both
languages. Allegro already has objects, constructors, destructors, etc,
so why go to all the trouble of a complete rewrite just to change the
way in which they are called?
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -