c++ for python programmers

Neil Cerutti horpner at yahoo.com
Wed Feb 14 08:41:53 EST 2007


On 2007-02-13, Sam <free.condiments at gmail.com> wrote:
> On 13 Feb 2007 17:51:00 GMT, Jorgen Grahn
><grahn+nntp at snipabacken.dyndns.org> wrote:
>> Well, C++ is a better language than C in many ways. So, if he
>> needs to learn one of them, why does it have to be C?
>>
>> Another reason some people choose C++ over Python for some
>> tasks is that they feel that larger programs benefit from
>> strong, static type checking. I like both ways, but depending
>> on the task, one or the other is better.
>
> C++ is -not- strongly typed. You can cast anything to void *,
> and manipulate it in ways unimaginable. Plus there's the whole
> mess that is pointer arithmetic and a weak typesystem...

Don't forget the lack of standard garbage collection. 

Also there's the hell known as exception safety.

Python conceptually has many of the same issues with exception
safety, but at least memory leaks aren't one of the consequences.
I imagine most Python programmers don't even think about
exception safety, but probably should be. We just happily raise
exceptions willy-nilly, without worrying about our objects
remaining in a reasonable state. Or do we? Maybe it's better not
to think about it. ;-)

> Disclaimer: I am unashamedly in the "C++ Is Evil" camp, and
> wholly believe that if you want proper strong, static type
> checking, use Haskell, or if you want proper, complete
> object-orientation (C++'s primitive types compromise its object
> system's integrity, and I believe I've already discussed
> casting and pointers), use Python, and if you want
> under-the-hood pointer-fu, use C.

C++'s standard library seems such a huge win over the C library,
that I'd hate to switch back. Of course it has its warts and
cancers, but it's an awesome accomplishment. And you *can* get
harder-to-use C versions that are basically portable.

-- 
Neil Cerutti
A billion here, a billion there, sooner or later it adds up to real money.
--Everett Dirksen



More information about the Python-list mailing list