On 17 Jun 2005 06:26:50 -0700, George Sakkis <[EMAIL PROTECTED]> wrote:
> During the last 18 months or so I have indulged in the joy of learning
> and using python for almost everything, but I may have to go back to
> C/C++ at work. Suddenly I found myself transliterating (or translating
> at least) common python idioms and patterns, looking for libraries to
> replace python's "included batteries" or writing my own from scratch,
> (over)using templates in an attempt to mimic duck typing, and so on.
> Still, I am not sure if this is a good idea in general since every
> language has its own idiosyncrasies, and this is obvious when one sees
> python code looking like C or Java.
>
> So, I wonder what have others who have gone the same path done and
> learned in similar situations.

I feel exactly like you described, both when I move from C++ to Python, and
when I move from Python to C++.  I think most multi-language programmers
feel like this, and I don't think there's anything wrong with it.

What I do?  I try to keep calm and resist the temptation to write C++ code
in Python and the other way around. Why? Because I know how much I hate C++
code written as if it was Java, or C, or Smalltalk.

(rearranged from above)
> OTOH, bringing python's higher
> level of expressiveness to C/C++ might actually be a good thing,
> leading to cleaner, safer code.

Maybe. On the other hand, you risk messing up the things that make idiomatic
C++ clean and safe: static typing, const correctness, conservative use of
inheritance and polymorphism, ... And in the end: will other C++ programmers
hate your code?  Will they modify it without butchering your original
design?

> How one can avoid the frustration of
> having to work with a low level language once he has seen the Light ?

I wouldn't call the modern C++ you (since you don't seem to be afraid of
templated) use a "low level language". It does different choices compared to
Python when it comes to run-time efficiency versus usability, and so on.

But yes, programming in C++ is usually more tedious and frustrating -- and
less fun.

/Jorgen

-- 
  // Jorgen Grahn <jgrahn@       Ph'nglui mglw'nafh Cthulhu
\X/                algonet.se>   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to