[PD] C++ for reusable dsp lib - or better use C?
Mathieu Bouchard
matju at artengine.ca
Wed Feb 22 17:44:20 CET 2012
Le 2012-02-22 à 09:37:00, Hans-Christoph Steiner a écrit :
> STL, Qt, and Boost are all only used in C++.
Qt is also available for Ada, C#, D, Haskell, Harbour, Java, Lisp, Lua,
Pascal, Perl, PHP, Python, QML, R, Ruby, Scheme, ... and even Tcl.
See http://en.wikipedia.org/wiki/Qt_%28framework%29#Bindings
now for the others...
STL and Boost are different. While Qt's interface (API) consists of
features that are in many languages (or have very close equivalents), STL
uses several features that are quite C++-specific and at odds with how
other programming languages work. Other languages have already their own
library covering the same ground as the STL, though usually in a quite
different way and usually not that efficiently. Boost goes further in the
direction of using all the C++ features that exist and it's at least as
impossible to port.
This shows a rift between libraries with least-common-denominator
interfaces that are somewhet easy to port to many languages (incl Qt), and
libraries that are deeply entrenched in a language to get the best of it.
The latter is more common in C++, because least-common-denominator tend to
be a same small set of data types (int,float,string,array), basic OOP
features, and that's all, while C++ has long expanded beyond « C with
Classes » to include templates and stuff.
Templates can't be easily wrapped because their point is to generate code
on-the-fly as the programmer is programming. Wrapping that kind of library
means reducing the flexibility and/or efficiency, by precompiling some
use-cases of templates, and forbidding the rest. Otherwise, you'd need
something that can recompile C++ templates on-the-fly in another language,
and I haven't seen that yet.
Actually, one can do similar tricks in plain C with macros, but those same
caveats appear as with templates.
______________________________________________________________________
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
More information about the Pd-list
mailing list