Converting Python app to C++ completely

Alan James Salmoni salmonia.nospam.please at cardiff.ac.uk
Fri Aug 30 08:07:09 EDT 2002


Joseph A. Knapka wrote:
> Alan James Salmoni wrote:
> 
>>Hi all,
<SNIP>
> 
> Hey guys, open up the dungeon, we've got another one! Now where
> did I put that white-hot pair of pliers? ..

lol! I heard some people pay good money for that kind of thing, and here 
I am getting it for free!

> Yes, that's what enables us to write 1-line C++ programs that
> do absolutely anything :-) I assume you meant "each line of
> Python". I'd say an 8:1 ratio is actually a little low for
> short programs, but the larger the project, the better the
> ratio will get in favor of C++, if you do your abstraction
> properly. You will *always* write more lines of C++ than
> of Python to accomplish a given task, however.

My mistake!

> I would say it is not a mechanical transformation. It will require
> a lot of thought, and a lot of code. You'll be amazed at all the
> stuff Python does for you that you'll have to handle yourself
> in C++.

I am getting the impression that I have lived in a cossetted world when 
programming with Python.

> Memory management is, I'm sure, the single biggest source of fatal
> errors in C++ code. Of course, in Python you don't have to deal
> with it at all :-) In C++, every bit of dynamic memory you use is
> pretty much your responsibility to clean up, and of course you
> must be careful not to overwrite the bounds of memory blocks,
> free a memory block twice, forget to free a memory block, use
> a memory block after it's been freed, use memory that you haven't
> explicitly allocated, etc., etc. We C++ programmers have developed
> tricks to help us deal with this sort of thing, in much the same
> way that people who suffer severe childhood trauma develop
> psychological mechanisms to insulate themselves from those
> experiences :-) You should get a copy of Scott Meyers's books
> "Effective C++" and "More Effective C++", along with the
> latest edition of Stroustrup's "The C++ Programming Language"
> that you can find. Unlike Python books, C++ books are almost
> universally crap (they will lead you down hellbound paths
> by "forgetting" to tell you about really important corners of
> the language); the Meyers and Stroustrup books are among the
> exceptions. I suspect Eckel's "Thinking in C++" would be good
> too, but I haven't read it.

Recommendations noted!

> Yes. The Standard Template Library will help you here. But
> you're buying yourself quite a steep learning curve.

That's okay - there's no time frame - the main aim is to learn, and I 
enjoy a challenge!

>>5) Is there a free C++ compiler for Mac OS8/9? I am going to use GCC for
>>every other platform (the Python version is currently multi-platform -
>>even OSX, but not OS8 or 9 sadly).
> 
> 
> No comment. Well, "Use a real OS", maybe? :-)

Heh - I know what you mean - the problem is that my package is aimed at 
a market where old Macs are still being used quite a lot. Currently, the 
Python code doesn't run on OS8/9 which is a shame. If I could, it would 
be nice to have it running on these systems. Personally, I use Linux for 
all my development (with the obligatory Windows partition for testing of 
course!) Don't even own a Mac (though OSX does look nice).

> s/Python/C++/ ?
> 
> C++ is a dinosaur. If I were you, I'd spend time learning a
> trendy language like Java (gag, spit, retch).

A dinosaur? Maybe I should concentrate upon something more up to date 
(like Cobol?) >;)

> 
> Cheers,
> 
> -- Joe
>   "I'd rather chew my leg off than maintain Java code, which
>    sucks, 'cause I have a lot of Java code to maintain and
>    the leg surgery is starting to get expensive." - Me
Thanks for the advice!

Alan




More information about the Python-list mailing list