473,804 Members | 3,018 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 1830
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.c om> 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:

Implementati ons 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************ *********@g14g2 000cwa.googlegr oups.com>,
"cjl" <cj****@gmail.c om> 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********@yaho o.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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3435
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
8088
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 as a standard portable part of the core language, the LISP package, and the java.lang package, respectively. Both have big integers, although only LISP has rationals as far as I can tell. Because CL supports keyword arguments, it has a wider range...
15
7701
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 thesis, as I've been interested in this technology, and I haven't had a chance to work with it in my last job. The issue is what platform to use: ..NET or J2EE? Prior to starting my MSc course, I worked for a software developer for five years...
3
2372
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 new script i tried to filter the stream-url from an
9
4250
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 to develop the application for my end users. Should I use Java or MS.Net technology or should I mix both of them ? Basically, I have these criteria in mind before I decide which platform I should adopt : 1. Ease of use - which one is easy to...
106
5250
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 cooler.:-) Anyhow, I am a novice programmer, and I will remain one as well...I have no plans to make programming my life ambition, but I think that it would be fun to make my databases do some cool tricks and maybe write a simplistic client to...
9
1310
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 like that. Now I'm writing a project in Python that needs to be able to make use of that kind of a class. The Java version has static methods for common roll styles (XdY and XdY +Z) for classes that just want a result but don't want to bother...
84
3987
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. 2. Client side processing: Web server gets form input and passes it to PHP which includes the Javascript written in a way to make the form input processed on the client side and rendered (probably using DOM function calls) on that side as...
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10578
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9152
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4300
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 we have to send another system
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.