cjl said:
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.