Java to C++

  • Thread starter Martin Demberger
  • Start date
M

Martin Demberger

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
 
J

John Harrison

Martin Demberger said:
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
 
M

Martin Demberger

Am Fri, 2 Jul 2004 12:56:39 +0100 schrieb John Harrison:
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.
 
G

Gernot Frisch

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
 
J

John Harrison

Martin Demberger said:
Am Fri, 2 Jul 2004 12:56:39 +0100 schrieb John Harrison:


I'm working on it. And its in german. But if I'm allowed I will put it in
the net.


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
 
J

JKop

Martin Demberger posted:
Am Fri, 2 Jul 2004 12:56:39 +0100 schrieb John Harrison:

Any compiled language will do.


C++ -> Assembly -> Machine Code.

Pascal -> Assembly -> Machine Code.


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
 
K

Karl Heinz Buchegger

Martin said:
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
 
E

Evan Carew

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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-----
 
?

=?ISO-8859-1?Q?Gon=E7alo_Ferreira?=

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.
 
A

Andreas Schmidt

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++.
 
T

tom_usenet

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
 
M

Martin Demberger

Am Fri, 2 Jul 2004 13:26:40 +0100 schrieb John Harrison:
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.
 
M

Martin Demberger

What do you have against java?
Java and C++ are languages. Both of them have positiv and negative things.
 
H

Howard

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
 
S

Steven T. Hatton

Evan said:
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.
 
S

Steven T. Hatton

JKop said:
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?....????
 
J

James Moughan

Martin Demberger said:
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...
 
J

JKop

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
 
K

Karl Heinz Buchegger

JKop said:
Steven T. Hatton posted:


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


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.
 
T

tom_usenet

Steven T. Hatton posted:


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



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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,933
Members
47,472
Latest member
blackwatermelon

Latest Threads

Top