(no subject)


Mon Mar 28 16:45:01 EST 2005


#! rnews 2354
Newsgroups: comp.lang.python
Path: news.xs4all.nl!newsspool.news.xs4all.nl!transit.news.xs4all.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!in.100proofnews.com!in.100proofnews.com!newsread.com!news-xfer.newsread.com!nntp.abs.net!attws2!ip.att.net!NetNews1!xyzzy!nntp
From: Harry George <harry.g.george at boeing.com>
Subject: Re: Which is easier? Translating from C++ or from Java...
X-Nntp-Posting-Host: cola2.ca.boeing.com
Content-Type: text/plain; charset=us-ascii
Message-ID: <xqx3bufihui.fsf at cola2.ca.boeing.com>
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3
Lines: 47
Sender: hgg9140 at cola2.ca.boeing.com
Organization: The Boeing Company
References: <1112043435.991699.11460 at g14g2000cwa.googlegroups.com>
Mime-Version: 1.0
Date: Mon, 28 Mar 2005 21:24:53 GMT
Xref: news.xs4all.nl comp.lang.python:369571

"cjl" <cjlesh at gmail.com> writes:

> Hey all:
> 
> I'm working on a 'pure' python port of some existing software.
> 
> Implementations of what I'm trying to accomplish are available (open
> source) in C++ and in Java.
> 
> Which would be easier for me to use as a reference?
> 
> I'm not looking for automated tools, just trying to gather opinions on
> which language is easier to understand / rewrite as python.
> 
> -cjl
> 

I've done a bit of manual porting from C++ and from Java, but never
for the same algorithm.  Here are some points to consider:

1. Java is already garbage collected, object oriented, and generally
   "safe".  So an algorithm could be copied almost verbatim into
   Python.  In C++ you might get pointers, casts, etc. which would
   leave you stumped.

2. Java as a community is trying to reinvent the wheel for everything
   you might already have in a library.  So whereas in C++ you might
   just bind to the same library, in Java you might have to fight your
   way through layer after layer of java-isms.  You could end up doing
   more work replicating the java-esque libraries than in doing the
   actual code of interest.

Thus there is a tradeoff.  For pure algorithms and
computer-science-ish programs, java may be easier.  For anything that
uses libraries and API's, C++ may be easier.

As a practical matter, I have found I need to read the code and
understand it in the original language.  Then, inspired by this
insight, I write a wholly new python program, using python-esque
idioms.  So it comes down to which particular piece of code is easier
to understand, and that in turn depends more on the original author's
style than on the language.

-- 
harry.g.george at boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718



More information about the Python-list mailing list