473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Java to C++

Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java (and
the good IDE's available for java) and convert this to C++ to get the
advantages and speed of this language.

mfg
Martin Demberger
Jul 22 '05 #1
21 2960

"Martin Demberger" <Ma******@gmx.de> wrote in message
news:1c*****************************@40tude.net...
Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java (and
the good IDE's available for java) and convert this to C++ to get the
advantages and speed of this language.


Ha ha! I'd love to read that article, do you have a link?

Even if you could get this to work (it sounds like several man/years of
effort) who would want to write in Java and end up with inferior C++ just so
that they could use a particular IDE.

john
Jul 22 '05 #2
Am Fri, 2 Jul 2004 12:56:39 +0100 schrieb John Harrison:
"Martin Demberger" <Ma******@gmx.de> wrote in message
news:1c*****************************@40tude.net...
Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java (and
the good IDE's available for java) and convert this to C++ to get the
advantages and speed of this language.

Ha ha! I'd love to read that article, do you have a link?


I'm working on it. And its in german. But if I'm allowed I will put it in
the net.
Even if you could get this to work (it sounds like several man/years of
effort) who would want to write in Java and end up with inferior C++ just so
that they could use a particular IDE.


Java is in my opinion one of the fastest Language for the programmer. (But
not for the resulting program) And this is very good for making money.
Jul 22 '05 #3
> I'm working on it. And its in german. But if I'm allowed I will put
it in
the net.
Sure.
Java is in my opinion one of the fastest Language for the programmer. (But not for the resulting program) And this is very good for making

money.

Er... What's better on Java than C++? I think you can do everything
you do in Java wihtout even changing a thing in C++, but it won't be
much faster then, because the Java architecture makes it slow. About
the IDE - I doublt you'll find a better one than the MS Vsiual Studio
IDEs. (Which version is a different question).

But, do go on. Maybe there's need for your java2cpp precompiler.

Gernot
Jul 22 '05 #4

"Martin Demberger" <Ma******@gmx.de> wrote in message
news:12*****************************@40tude.net...
Am Fri, 2 Jul 2004 12:56:39 +0100 schrieb John Harrison:
"Martin Demberger" <Ma******@gmx.de> wrote in message
news:1c*****************************@40tude.net...
Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java (and the good IDE's available for java) and convert this to C++ to get the
advantages and speed of this language.


Ha ha! I'd love to read that article, do you have a link?


I'm working on it. And its in german. But if I'm allowed I will put it in
the net.
Even if you could get this to work (it sounds like several man/years of
effort) who would want to write in Java and end up with inferior C++ just so that they could use a particular IDE.


Java is in my opinion one of the fastest Language for the programmer. (But
not for the resulting program) And this is very good for making money.


Your biggest task would be to port the java platform to C++.

How do you propose to deal with garbage collection?

How about other features of Java that don't translate easily to C++,
reflection for instance.

john
Jul 22 '05 #5
Martin Demberger posted:
Am Fri, 2 Jul 2004 12:56:39 +0100 schrieb John Harrison:
"Martin Demberger" <Ma******@gmx.de> wrote in message
news:1c*****************************@40tude.net...
Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java
(and the good IDE's available for java) and convert this to C++ to
get the advantages and speed of this language.

Any compiled language will do.
C++ -> Assembly -> Machine Code.

Pascal -> Assembly -> Machine Code.
Ha ha! I'd love to read that article, do you have a link?
I'm working on it. And its in german. But if I'm allowed I will put it
in the net.


As soon as you do, we can go to www.google.com/language_tools and get it
translated on-the-fly.

Java is in my opinion one of the fastest Language for the programmer.
(But not for the resulting program) And this is very good for making
money.


Is that a typo? Should it be?:

Java is in my opinion one of the shittest Language for the programmer
Java is not a compiled language. Java is an interpreted language. Here's how
it goes:

C++ -> Assembly -> Machine Code
Java -> Crappy Java Code

Then when you run your Java program:

Crappy Java Code ---(Through Interpreter, time goes by)---> Assembly -->
Machine Code.
Eventually all code becomes machine code, so you can't say that one language
is faster than the other, except ofcourse when it comes to crappy
interpreted languages.
-JKop
Jul 22 '05 #6
Martin Demberger wrote:

Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java (and
the good IDE's available for java) and convert this to C++ to get the
advantages and speed of this language.


Java isn't 'just a language'
Java is a whole platform. In order to be able to translate
Java to C++, you also need to port the whole platform.

And if you ask: would you use my translator?
No

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #7
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Karl Heinz Buchegger wrote:
Martin Demberger wrote:
Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java (and
the good IDE's available for java) and convert this to C++ to get the
advantages and speed of this language.

Java isn't 'just a language'
Java is a whole platform. In order to be able to translate
Java to C++, you also need to port the whole platform.

The platform has already been translated, its called gcj & is a gcc tool
chain full fledged member now. It was used to compile the Eclips IDE
into native code. As it happens, in order to get this to work, the
developers had to get their JAVA implementation to work with other
languages, & the one it works best with is C++.

This is not strictly speaking a translator (into other languages),
however, it is a pretty good cross language integration tool. The
expressed purpose of this tool was to compile the JAVA code in such a
fashon as it could actually be used without having to wait 120 sec for
some operations to complete. For full info on their efforts, see the
following link:

http://www.linuxjournal.com/article.php?sid=4860

With tools such as these, converting your legacy JAVA code to all C++
can be done at your leasure, a class at a time.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFA5V4goo/Prlj9GScRAoZ9AJ4xw9QgEQKmiICaZft0945wHfPHdACdEUZh
AnaLgAycsKDIVPfxRCab9ZA=
=WYko
-----END PGP SIGNATURE-----
Jul 22 '05 #8
The platform has already been translated, its called gcj & is a gcc tool
chain full fledged member now. It was used to compile the Eclips IDE
into native code. As it happens, in order to get this to work, the
developers had to get their JAVA implementation to work with other
languages, & the one it works best with is C++.


Eclipse was not compiled into native code -- the executable is just a
wrapper to call the java runtime.
Jul 22 '05 #9
On Fri, 2 Jul 2004 14:22:24 +0200, Gernot Frisch <Me@Privacy.net> wrote:
Java is in my opinion one of the fastest Language for the

programmer. (But
not for the resulting program) And this is very good for making

money.

Er... What's better on Java than C++? I think you can do everything
you do in Java wihtout even changing a thing in C++


How well do you know Java? C++ is actually missing some stuff that Java
has: dynamic class loading, RMI, reflection, for example. It's also very
easy to work with zip streams, network streams, the file system etc. How
do you create a directory in C++ "without even changing a thing" from the
Java program? C++ is a great language, but it's not the case that Java is
just a subset of C++. It has it's own merits, like C++.
Jul 22 '05 #10
On Fri, 2 Jul 2004 12:56:39 +0100, "John Harrison"
<jo*************@hotmail.com> wrote:

"Martin Demberger" <Ma******@gmx.de> wrote in message
news:1c*****************************@40tude.net.. .
Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java (and
the good IDE's available for java) and convert this to C++ to get the
advantages and speed of this language.


Ha ha! I'd love to read that article, do you have a link?

Even if you could get this to work (it sounds like several man/years of
effort) who would want to write in Java and end up with inferior C++ just so
that they could use a particular IDE.


EDG's Java front end can compile to C source.

Tom
--
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Jul 22 '05 #11
Am Fri, 2 Jul 2004 13:26:40 +0100 schrieb John Harrison:
"Martin Demberger" <Ma******@gmx.de> wrote in message
news:12*****************************@40tude.net...
Am Fri, 2 Jul 2004 12:56:39 +0100 schrieb John Harrison:
"Martin Demberger" <Ma******@gmx.de> wrote in message
news:1c*****************************@40tude.net...
Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java (and the good IDE's available for java) and convert this to C++ to get the
advantages and speed of this language.
Ha ha! I'd love to read that article, do you have a link?
I'm working on it. And its in german. But if I'm allowed I will put it in
the net.
Even if you could get this to work (it sounds like several man/years of
effort) who would want to write in Java and end up with inferior C++ just so that they could use a particular IDE.


Java is in my opinion one of the fastest Language for the programmer. (But
not for the resulting program) And this is very good for making money.


Your biggest task would be to port the java platform to C++.


A lot of the platform can also be converted automatically. Thats not the
ultimate solution, but for a first Version this should be enough. Later on
parts of it can be writen by hand to get a better performance.
How do you propose to deal with garbage collection?
First of all, its theoretically. So I have different solutions for the
different problems.
First of all I only use the garbage collection of Boehm. But later on this
can also be changed to reference counting or if possible (its not a part of
my article) the delete can be inserted by the converter.
How about other features of Java that don't translate easily to C++,
reflection for instance.


In the first version reflection isn't converted. But I can generate this
static into the classes. And a part of it can be handled by RTTI.
Jul 22 '05 #12
What do you have against java?
Java and C++ are languages. Both of them have positiv and negative things.
Jul 22 '05 #13
Java is in my opinion one of the fastest Language for the programmer.
(But not for the resulting program) And this is very good for making
money.
Is that a typo? Should it be?:

Java is in my opinion one of the shittest Language for the programmer


Tsk, tsk. At least, if you're going to swear, do it right. The term is
"shittiest". :-O

Java is not a compiled language. Java is an interpreted language. Here's how it goes:

C++ -> Assembly -> Machine Code
Java -> Crappy Java Code

Then when you run your Java program:

Crappy Java Code ---(Through Interpreter, time goes by)---> Assembly -->
Machine Code.
Eventually all code becomes machine code, so you can't say that one language is faster than the other, except ofcourse when it comes to crappy
interpreted languages.
-JKop


He was (I am fairly certain) talking about the speed with which you can
create a program, not the speed of the prgram itself. That was what the
"for the programmer" qualifier was there for, and why he said "not for the
resulting program". That makes it good for making money (at least in his
opinion), because you can churn out more code in a shorter period of time
(again, in his opinion). (Now, as to the quality and applicability of such
code....... :-))

-Howard

Jul 22 '05 #14
Evan Carew wrote:
The platform has already been translated, its called gcj & is a gcc tool
chain full fledged member now. It was used to compile the Eclips IDE
into native code. As it happens, in order to get this to work, the
developers had to get their JAVA implementation to work with other
languages, & the one it works best with is C++.


There's more to performance than simply compiling Java to native bits. Yes,
you can compile Java source to native bits. I don't know why people on
this newsgroup have such a hard time understanding that. But there are
some aspects of C++ which allow the programmer to tweak performance in way
you simply cannot with Java. The C++ Standard Library's value based
semantics are designed to provide maximum performance whereas Java's
pointer based libraries provide maximum flexibility.
--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org
Jul 22 '05 #15
JKop wrote:
Any compiled language will do.
C++ -> Assembly -> Machine Code.

Pascal -> Assembly -> Machine Code. Is that a typo? Should it be?:

Java is in my opinion one of the shittest Language for the programmer
No. Java has many advantages over C++ when it comes to provideing coherent
APIs to the programmer. C++'s design is fairly ad hoc as regards the
support of thrid party libraries. As a result there is a great deal of
incongruence between the structure of libraries and the code that uses
them.
Java is not a compiled language. Java is an interpreted language. Here's
how it goes:

C++ -> Assembly -> Machine Code

Not all compilers have an assembly stage. Some go directly from the parsed
source to machine code.
Java -> Crappy Java Code

Then when you run your Java program:

Crappy Java Code ---(Through Interpreter, time goes by)---> Assembly -->
Machine Code.
You can compile Java to machine specific binaries.
Eventually all code becomes machine code, so you can't say that one
language is faster than the other,
This really is a more complex issue than simply converting source to machine
code.
except ofcourse when it comes to crappy
interpreted languages.


So any language that is interpreted is "crappy"? Mathematica? Lisp? Icon?
Bash?....????

--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org
Jul 22 '05 #16
Martin Demberger <Ma******@gmx.de> wrote in message news:<1c*****************************@40tude.net>. ..
Hi,
I'm working on an article about compiling java-sources to c++.
I'm interessted if someone would use this to write a program in java (and
the good IDE's available for java) and convert this to C++ to get the
advantages and speed of this language.

mfg
Martin Demberger


As mentioned, this is already effectively implemented in gcj.
Unfortunately the resulting code frequently executes slower than on
one of the better JVMs, e.g. the IBM JVM or Sun's 1.5 beta. (Memory
usage is better, though.) It seems the overhead of Java has mostly to
do with language features rather than the virtual machine.

So, no, I would be unlikely to bother. Now if someone were to
translate the Java *library* to C++, that might be useful...
Jul 22 '05 #17
Steven T. Hatton posted:
Not all compilers have an assembly stage. Some go directly from the
parsed source to machine code.
But machine code can be converted to assembly code and vice versa.

You can compile Java to machine specific binaries.
Are you saying that you can compile your Java program directly to machine
code, ie. CPU instructions? But doesn't the interpreter have to take a look
at your homework first give it the all-clear, and then send the intructions
to the CPU on your behalf?

So any language that is interpreted is "crappy"? Mathematica? Lisp?
Icon? Bash?....????

Never heard of any of them. But Yes.
-JKop
Jul 22 '05 #18
JKop wrote:

Steven T. Hatton posted:
Not all compilers have an assembly stage. Some go directly from the
parsed source to machine code.


But machine code can be converted to assembly code and vice versa.
You can compile Java to machine specific binaries.


Are you saying that you can compile your Java program directly to machine
code, ie. CPU instructions?


Why should this not be possible?
Sure one can do that.

But it would be against the 'spirit' of Java, which is:
You program on your computer and hand out the program. No
matter what computer your customer uses, the program runs.

With programs compiled to native code, this is no longer
possible.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #19
On Sat, 03 Jul 2004 09:51:01 GMT, JKop <NU**@NULL.NULL> wrote:
Steven T. Hatton posted:
Not all compilers have an assembly stage. Some go directly from the
parsed source to machine code.


But machine code can be converted to assembly code and vice versa.

You can compile Java to machine specific binaries.


Are you saying that you can compile your Java program directly to machine
code, ie. CPU instructions? But doesn't the interpreter have to take a look
at your homework first give it the all-clear, and then send the intructions
to the CPU on your behalf?


There are a number of to-machine-code java compilers, such as GCJ. The
output is machine code, not .class files.

Tom
--
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Jul 22 '05 #20
Karl Heinz Buchegger wrote:
But it would be against the 'spirit' of Java, which is:
You program on your computer and hand out the program. No
matter what computer your customer uses, the program runs.

With programs compiled to native code, this is no longer
possible.


Unless the customer has an emulator that can run that code on his/her
platform of choice.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 22 '05 #21
"Karl Heinz Buchegger" <kb******@gascad.at> wrote in message
news:40***************@gascad.at...
JKop wrote:

Steven T. Hatton posted:
Not all compilers have an assembly stage. Some go directly from the
parsed source to machine code.


But machine code can be converted to assembly code and vice versa.
You can compile Java to machine specific binaries.


Are you saying that you can compile your Java program directly to machine code, ie. CPU instructions?


Why should this not be possible?
Sure one can do that.

But it would be against the 'spirit' of Java, which is:
You program on your computer and hand out the program. No
matter what computer your customer uses, the program runs.

With programs compiled to native code, this is no longer
possible.


That was also the 'spirit' of UCSD Pascal. Except that they failed
to deal with the NUXI problem, so the P-code wasn't really portable.
And Borland went on to make Pascal a *real* programming language by
giving people a truly useful development environment centered on
an extended dialect of Pascal.

Moral: maybe Java still has a second life as a compiled language,
once the 'spirit' of "write once, test everywhere" runs its course.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 22 '05 #22

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

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
12
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it...
0
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build...
1
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.