Java bytecode backend for gcc?

This is a discussion on Java bytecode backend for gcc? within the C++ Programming forums, part of the General Programming Boards category; Hi, This idea just struck me - Is it possible to write a Java bytecode backend for gcc? It would ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183

    Java bytecode backend for gcc?

    Hi,
    This idea just struck me -
    Is it possible to write a Java bytecode backend for gcc? It would certainly be pretty cool to be able to compile C/C++ code into Java bytecode =).

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    C++ into Java bytecode? That could be ugly.

    I believe it might have been done already, though, I don't know of it being done for GCC.
    Last edited by MacGyver; 05-08-2008 at 12:13 AM.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    Actually it would be gcc's language-independent intermediate code (where gcc does all its optimizations) to Java bytecode, (IIRC) instead of x86 or SPARC code.

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    How would this be useful? One time another compiler developer thought something like this would be useful and even developed a back end for other language. They even made their own languages specifically for this intermediate code. Many thought it would be a fad that would disappear... But alas it stayed. And it was not and still is not a good system.

    Meanwhile, gcj?
    Last edited by master5001; 05-08-2008 at 05:28 AM.

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    IIRC gcj is a frontend. It translates java into the intermediate code.

    Why is intermediate code not a good idea? IMHO it simplifies gcc quite a bit? Eg, without the intermediate code, every frontend will need to have their own optimizer, and their own set of binary code generators?

    How else would you achieve this kind of modularity without intermediate code?
    Last edited by cyberfish; 05-08-2008 at 12:38 AM.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by cyberfish View Post
    IIRC gcj is a frontend. It translates java into the intermediate code.

    Why is intermediate code not a good idea? IMHO it simplifies gcc quite a bit? Eg, without the intermediate code, every frontend will need to have their own optimizer, and their own set of binary code generators?
    Which Java version do you propose supporting? Will updates to gcc keep up with changes and remain backward compatible?

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    The reason I say this is because language like JAVA are exactly what you are asking to have. I am not saying its a horrible idea in practical use, I am just considering the development time of this framework, the development time of applications, the efforts in porting code, etc. For what? A JAVA clone. Unless you are M$ trying to skirt patent issues, there is no need to develop your own JAVA equivalent.

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    OK, let's get some facts straight.

    1) The effort of developing the framework is being done. It's called GNU Classpath.
    2) The effort of developing the frontend is being done. It's called gcj.
    3) Gcj can output Java bytecode.
    4) General GCC cannot output Java bytecode. Gcj bypasses the GCC backend for generating bytecode.

    GCC's intermediate representation is register-based. It is very unsuitable for the generation of stack-based code like Java bytecode. That's why nobody wants to write a bytecode backend.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,243
    Doing this would be non-trivial but certainly possible. The hardest part is mapping the pseudo-registers of the intermediate code to the Java stack.

    And I'm baffled by the criticism of intermediate code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Java for real-time applications
    By zacs7 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 08-26-2008, 06:34 AM
  2. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 02:06 PM
  3. The Java language is being expanded
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 06-11-2004, 09:07 PM
  4. Java woes
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-06-2003, 12:37 AM
  5. C/C++ Vs Java
    By Spectrum48k in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 10-21-2002, 09:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21