[Tutor] Const on Python

Alan Gauld alan.gauld at btinternet.com
Fri Mar 7 01:10:37 CET 2008


"Kent Johnson" <kent37 at tds.net> wrote

> My experience, moving from C++ to Java to Python as the language I 
> use
> every day at work:

I did much the same journey but decided I hated Java so much
I kind of bypassed it and only once used it on a real project. Instead
I became an architect/designer(;-), learned Python, and now hand
prototypes over to the development teams to build in Java...

> C++ is extremely complex.

It was relatively straightforward in v1 and even in v2. But once
they started the ANSI standardisation process they started
throwing every feature under the sun into it! At that point I
lost interest.

> Java is less complex and flexible than C++. At first I missed the
> control of C++, then I realized that it wasn't really buying me much 
> and
> that the cost was too high - coding Java is much less work than 
> coding C++.

I didn't find that, in the few real tests I did I often found the C++
code shorter and never significantly longer(10% ?). This is because
Java removed so many of the features that can really reduce C++
code size - like multiple inheritance and operator overloading and
templates. (although the latest Java has a kind of templates with
generics). When you add to that the fundamentally broken type
system in Java (mix of primitive and object) you often wind up
with code that effectively does:

if x is primitive type
    func(x)
else
   x.func()

or

if y is primitive
    y += z
else
    y.incrementBy(z)

And of course interfaces as an alternative to MI simply
mean cut n paste code in every sub class or a complex
delegation/dispatch scheme being devised by the developer

> Then Python. Python takes away even more low-level control. And I 
> don't
> miss it at all. My Python programs work just fine without static 
> typing,
> constants, etc.

And all the missing featires of Java are fixed - all objects are
true objects, MI is allowed, and duck typing plus generic containers
removes the need for most templates

> Python is simple and flexible and just does what I want with no 
> fuss.
> Java is a heavy straightjacket. C++ is inconceivably complex.

I agree. Although I do still dabble in Delphi, SmallTalk, Haskell
and Lisp from time to time :-)

Alan G.




More information about the Tutor mailing list