Python is just as good as C++ for real apps

Kragen Sitaker kragen at pobox.com
Fri Jan 25 05:33:28 EST 2002


weeks at vitus.scs.agilent.com (Greg Weeks) writes:
> Jason Orendorff (jason at jorendorff.com) wrote:
> : I think this is, at least, a misunderstanding of Bjarne Stroustrup's
> : point of view.  Stroustrup sees support for "concrete types" - that is,
> : classes with value semantics, not intended to be subclassed - as an
> : important feature of C++.
> 
> I'm a bit lost here.  I don't see why "value semantics" -- which I
> interpret to refer to immutables, like complex numbers or geometric points
> or immutable strings -- precludes subclassing.

Value semantics means you pass it around by copying, not by passing
references, which means that if someone else modifies their copy, you
don't see the change.  Passing around references to immutable objects
looks the same if you have garbage collection.

It precludes subclassing (in C++) because you need to know the size of
something in order to copy it, or at least a maximal size, and if some
value could be a member of any subclass of Foo, you can't copy it just
by copying sizeof(Foo) bytes' worth.  (You can try, and C++ systems
won't stop you, but your program will eventually get wrong answers or
crash.)




More information about the Python-list mailing list