By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,929 Members | 1,245 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,929 IT Pros & Developers. It's quick & easy.

Which is easier? Translating from C++ or from Java...

P: n/a
cjl
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

Jul 18 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
cjl wrote:
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.


Depends on what language you know best. But Java is certainly easier to
read than C++.

-pu
Jul 18 '05 #2

P: n/a

Patrick Useldinger wrote:
cjl wrote:
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.
Depends on what language you know best. But Java is certainly easier to read than C++.


There's certainly some irony in those last two sentences. However, I
agree with the former. It depends on which you know better, the style
of those who developed each and so forth. Personally, I'd prefer C++.

Jul 18 '05 #3

P: n/a
"cjl" <cj****@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.

--
ha************@boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718
Jul 18 '05 #4

P: n/a
cjl wrote:
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 haven't touched C++ in a long time, my experience porting Java to Jython is that it mostly
involves deleting stuff :-)

I hacked together a script that does a lot of the work by applying a bunch of regex replacements.

Kent
Jul 18 '05 #5

P: n/a
wo******@gmail.com wrote:
Patrick Useldinger wrote:
cjl wrote:

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.


Depends on what language you know best. But Java is certainly easier


to
read than C++.

There's certainly some irony in those last two sentences. However, I
agree with the former. It depends on which you know better, the style
of those who developed each and so forth. Personally, I'd prefer C++.


I don't think the OP was asking for personal preference, and so I happen
to agree with the reply: parsing Java is definitely *much* simpler than
parsing C++, no matter how well you know either. As far as manual translations
go, that is much less a matter of ease of parsing but instead how closely
programming idioms match between the two languages that are involved.
And that obviously also depends on the specific code that needs to
be rewritten and the style it is written in (i.e. for example OO vs. templates,
etc.).

Regards,
Stefan
Jul 18 '05 #6

P: n/a
In article <11*********************@g14g2000cwa.googlegroups. com>,
"cjl" <cj****@gmail.com> wrote:
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


My guess is you'd be better starting from the Java as a reference. So much
of C++ code tends to deal with low-level stuff like memory management and
pointers. At least in Java you won't have any of that stuff to wade
through.
Jul 18 '05 #7

P: n/a

Patrick Useldinger wrote:
cjl wrote: Depends on what language you know best. But Java is certainly easier

to read than C++.
There is a difference between theory and practice. In theory, Java is
easier to read than C++.
In practice however, the average Java programmer is MUCH less talented
than the average C++ programmer (let alone the average Python
programmer). The upshot of all this is that in practice (and my own
personal experience: we use both C++ and Java), Java code is bloated
with design patterns, obfuscated with many layers of indirection,
etc...
As a summary, Java code can most of the time be thrown away and
re-written from scratch (the fastest way). C++ code on the contrary can
easily be ported/wrapped.
Of course this is a matter of personal opinion. I love neither Java nor
C++. C is for me the purest language and there is no match when
combined with Python !

My 2 cents

Alain

Jul 18 '05 #8

P: n/a
al********@yahoo.fr wrote:
There is a difference between theory and practice.


You know the difference between theory and practice? Well, in theory,
there is no difference :-)
Jul 18 '05 #9

P: n/a
wo******@gmail.com wrote:
Patrick Useldinger wrote:
Depends on what language you know best. But Java is certainly easier


to
read than C++.

There's certainly some irony in those last two sentences. However, I
agree with the former. It depends on which you know better, the style
of those who developed each and so forth. Personally, I'd prefer C++.


Not really.

If you know none of the languages perfectly, you are less likely to miss
something in Java than in C++ (i.e. no &, * and stuff in Java).

However, if you are much more familiar with one of the two, you're less
likely to miss things there.

-pu
Jul 18 '05 #10

P: n/a
cjl
Hey all:

Thanks for the responses...

I've found a third open source implementation in pascal (delphi), and
was wondering how well that would translate to python?

-cjl

Jul 18 '05 #11

P: n/a
On 29 Mar 2005 11:02:38 -0800, cjl <cj****@gmail.com> wrote:
Hey all:

Thanks for the responses...

I've found a third open source implementation in pascal (delphi), and
was wondering how well that would translate to python?


cjl, I think that the responses on the list so far collectively point
the the correct answer: mu.

pick your favorite, or the most well written, or the clearest code, or
the one that contains the most 'e's, and try to translate it.
Whichever you choose, dig deep enough to get to the underlying meaning
of what's going on so that you don't end up writing another language
in python. If you do this, it doesn't matter which of the three you
pick.

Peace
Bill Mill
bill.mill at gmail.com
Jul 18 '05 #12

P: n/a
cjl wrote:
I've found a third open source implementation in pascal (delphi), and
was wondering how well that would translate to python?


Being old enough to have programmed in UCSD Pascal on an Apple ][ (with
a language card, of course), I'd say: go for Pascal!

;-)
Jul 18 '05 #13

P: n/a
If you have three different implementations, and can read all three of
them well enough to understand the code, use all three.

If you are going to port software from one language to another, and
want to reimplement it properly in your target language, you won't be
porting word-for-word anyway. So use all three sources to find out
what the problems were in the domain, and how they each solved them.
Using that knowledge, figure out the best way to tackle those same
problems in Python -- if those problems even exist.

Jul 18 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.