[vtk-developers] Data structures in VTK

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Wed Jan 2 23:02:57 EST 2002


>>>>> "WS" == Will Schroeder <will.schroeder at kitware.com> writes:

    WS> Some other thoughts about templates. A lot of it comes from
    WS> working with Insight (ITK) which is a very heavily templated
    WS> code base over the last two years.

    WS> + Wrapping: wrapping templated code/classes into Tcl/Python
    WS> etc. is nasty.  Just ask Brad King at Kitware who has a tool
    WS> to do it (CABLE). While it works, there are several problems.

Absolutely, although boost.python makes it easy to deal with templates
it still is a pain exposing the right interface.  I guess wrapping to
other languages must be far, far worse.

Personally, after working for quite a while with Python I am pretty
much convinced that the best approach is to prototype in a scripting
language and code the compute intensive parts in C/C++.  The
complexity of using some of C++'s new features is very high and
nowhere near as flexible as using a typeless language that allows for
very generic programming.  Given this I'd think Dylan would be an
awesome programming language.  Unfortunately, it isnt as mature as the
other programming languages.

Its true that c++ deals with type safety issues better than C but if
wrapping is what is desired I think C is superior.  Look at gtk+
vs. Qt for example.  Gtk+ has about 30(?) different language wrappers
where as Qt is currently only C++/Python/Perl(?).  I think that proves
the point you are making that wrapping c++ in general is hard.

    WS> + Complexity: the code becomes very complex. C++ programmers
    WS> with modest skills struggle with the stuff.  - Compilers still

Even those with somewhat decent C++ skills will find some things hard.
Look at blitz++ for instance.

Another important problem with (highly) templated code is that
compilation time is usually *much* longer.  Equivalent C code is much
faster to compile.

    WS> In summary, here's what I'd like to see with templates: - A
    WS> small number of templated VTK classes, maybe DataArray and
    WS> Collection.  A typeless layer (for wrapping) above may be
    WS> required.  - The use of STL within classes, only as an
    WS> implementation tool.  - No inheritance from STL classes

All that said, templates make for *very* nice container classes and I
agree with what you say about making Collection and DataArray classes
templated.  However, I'm not sure that wrapping them to
Tcl/Python/Java is going to be easy.  Could you please elaborate on
the "typeless layer" -- it sounds very interesting.

prabhu



More information about the vtk-developers mailing list