Simson Garfinkel wrote: > Dear Francesco, > > I'm sorry --- it is hard not to read your message and laugh. You > really think that the static type checking of C++ is protecting you? > Well, it may be, but C++ is unsafe in so many other ways that you are > not doing yourself a favor by working in it. > > If you want to use a typesafe language, you really should be using > Java or Python. Java will give you both static and dynamic type > checking. Python will give you runtime type checking. C++ gives you a > good feeling until something goes wrong and it crashes. >
It is certainly possible to shoot yourself in the foot with C++ if you use it like it were plain C (i.e., unsafe casts, casts to void *, pointers to functions, etc.). However the C++ programming style which is sometimes referred to as "modern" C++ (cfr. Alexandrescu's book), which makes heavy use of template (meta)programming facilities, shields you very effectively from such problems. For example, you can use functors in place of pointers to functions, and if you do something wrong the compiler will error out (in place of random crashes at runtime). If I write a generic template function which requires that its argument supports a certain method, and if I use it with an argument type that does not provide such method, a compilation error will be emitted. You can use the static_cast operator to make sure at compile time that you are not performing a "dangerous" cast. And so on... Frankly, the only cases in which I usually have to resort to the pains of plain C programming are when fiddling with lower level stuff like memory allocators, SIMD programming, etc. But usually you just have to encapsulate a small amount of dangerous code into a class and provide some abstraction to interact with it and you are done. I write mostly scientific software, so abandoning C++ tout-court is not an option. Thanks to all who replied, and best regards. Francesco. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users