This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GSL API design flaws


Brian Gough wrote:

> Thanks for your comments.
> There is a short design document for the library
>
>     doc/gsl-design.texi,
>
> which addresses some of these issues,
> although it is a bit old now.

It wasn't in the gsl-0.6 distribution.

> The goal of the project is really just to provide a free library
> equivalent to existing proprietary libraries
> such as IMSL, NAG and Numerical Recipes.
> So we just follow the existing conventions
> from these libraries with some minor improvements.

That's a disappointment.

> There are a couple of other Free Numerical Library projects,
> SL++ and COLT, which go beyond what we're doing
> in terms of design, vector/matrix representations and linear algebra.

I don't think it is a good idea to use IMSL, NAG or NR
as a model for your Application Programmers' Interface (API).
The IMSL, NAG and NR APIs were designed around deficiencies
in the Fortran 77 computer programming language.

Fortran 77 doesn't support encapsulation
much less object oriented programming.
For example, the Fortran 77 application programmer
is obliged to pass a reference to each attribute of each object
in order to call a Fortran 77 function or subroutine.
At least the C computer programming language
permits the application programmer to encapsulate
all of the attributes of an object in a struct
and pass a pointer to them as a single object.
The reduced overhead of C function calls compensates
for the overhead of creating and initializing objects
and may even result in an overall reduction in overhead
if the a reference to an object is passed
to more than one function.

Fortran 77 doesn't support dynamic allocation of memory.
Fortran 77 application programmers are obliged
to reserve and pass a reference to Fortran 77 functions
and subroutines for any extra work space
which may be required to complete the computation
but C application programmers expect C functions
to allocate any required work space dynamically
from free storage (the heap) for themselves.

The ANSI C computer programming language
together with an object oriented programming style
offers opportunities that really weren't practical with Fortran 77.
For example, if all the attributes of a vector are encapsulated
in a single object and a pointer to each vector is passed
to a C library function, that function can compare
the lengths of two vectors to determine
whether they are conformant or not.

But, to realize the full potential of ANSI C
and object oriented programming,
you must hide the actual data representation
and prohibit access to data members
except through GSL library functions.
Hiding the actual data representation
permits GSL library developers to change
the data representation and the implementation
of the GSL without requiring any changes
to any application programs that depend upon the GSL.








Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]