473,503 Members | 1,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
13 1796
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

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
"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
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
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
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

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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3395
by: Rob | last post by:
i know javascript, vbscript, asp css and alot more and im only 14 i was wondering which is easier to learn php or cgi. any help?
73
7900
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
15
7634
by: Herman | last post by:
Hi everyone, I'm currently studying for my Master's in Computer Science, and I will be working on my thesis this summer. I've been thinking about constructing a web services application for my...
3
2357
by: Alexander Fillips | last post by:
Hi, my short question: is there a python object which can interpret java-script? the whole story ;-) I wrote some streaming-scripts for the xbox mediaplayer which supports python. for a...
9
4204
by: CY FOK | last post by:
Hi I am planning to open a software company to develop client-server apps and web applications for my client. Now, i am in a difficult situation to determine what is the best platform i should use...
106
5119
by: cfmortgagepro | last post by:
Hi, I know that I'm an extreme newb by asking this overly beaten question, but I am leaning toward C#, becuase the perception is that it is better to learn than VB.Net. I guess it makes you...
9
1295
by: Daniel Gee | last post by:
A while ago I wrote a class in Java for all kinds of dice rolling methods, as many sides as you want, as many dice as you want, only count values above or below some number in the total, things...
84
3873
by: Patient Guy | last post by:
Which is the better approach in working with Javascript? 1. Server side processing: Web server gets form input, runs it into the Javascript module, and PHP collects the output for document prep....
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.