curl-users
Re: is there a need for a better libcurl?
Date: Mon, 27 Mar 2000 19:34:56 +0000
Wham Bang wrote:
> Would you want to make it a C lib or are you open to the idea
> of a C++ library? I really like perl's LWP model with User-Agent,
> HTTP-Request and HTTP-Response objects. It'd be really nice
> to have a C++ lib with a simillar interface.
Publicly available libraries should always have a C API.
Building libraries in C++ imposes a lot of unnecessary restrictions
on the application developers.
1) You limit their choice of language. Many languages support C
linkage, but (almost) none supports C++ linkage.
2) You limit their choice of development tool. Because there is no
standard way to mangle/demangle names in C++, and because it
therefore has been implemented in incompatible ways in various
compilers/linkers, you have to use the same compiler to build
the library and to build the application (which may not be an
option on systems where several projects share libraries -- it
is fairly common to have at least two compilers on Unix systems).
3) Depending on how the library is implemented, you may impose
design decisions. First, you force the object-oriented paradigm
(not every problem in the world is best solved by an OO design).
Second, if you use exceptions rather than error codes, then you
force the application developers to use exceptions as well.
Third, your data encapsulation may not be suitable for any given
application (ever needed that private attribute which the authors
forgot or refused to add access methods for?)
To sum it up, building C++ libraries is walking a mine field.
The proper way to provide a C++ interface/design for your application
is to build a C++ wrapper around the C library.
Received on 2000-03-29