Java to C++ Code Converter

This is a discussion on Java to C++ Code Converter within the C++ Programming forums, part of the General Programming Boards category; Does anybody knows where I can get a Java to C++ Code Converter? A help would be much appreciated guys, ...

  1. #1
    Registered User byte's Avatar
    Join Date
    Aug 2005
    Posts
    8

    Question Java to C++ Code Converter

    Does anybody knows where I can get a Java to C++ Code Converter? A help would be much appreciated guys, thanks in advance!

  2. #2
    Registered Loser nickodonnell's Avatar
    Join Date
    Sep 2005
    Location
    United States
    Posts
    33
    I only know of a Java to C converter. Would that work for you?

  3. #3
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Quote Originally Posted by nickodonnell
    I only know of a Java to C converter. Would that work for you?
    How the hell does that work? I mean how would you implement inheritance, polymorphism etc in C?
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    well it would probably be a mess but so is a disassembled .exe

  5. #5
    Registered User byte's Avatar
    Join Date
    Aug 2005
    Posts
    8

    Smile

    Quote Originally Posted by nickodonnell
    I only know of a Java to C converter. Would that work for you?
    That would be much appreciated nick. Please kindly give me a way to get it or you can send it to byteflux@yahoo.com, thanks!

  6. #6
    Registered Loser nickodonnell's Avatar
    Join Date
    Sep 2005
    Location
    United States
    Posts
    33
    I don't know if it'll work right, but I came across this about a week ago.

    http://www.ticalc.org/archives/files...315/31522.html
    ------------------------------------------------
    cout<<"Hello World!\n";
    ------------------------------------------------

  7. #7
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Quote Originally Posted by ahluka
    How the hell does that work? I mean how would you implement inheritance, polymorphism etc in C?
    it's not that hard actually.... it's painful and ugly as hell, but it can be done. In fact, all the first C++ compilers were simply preprocessors to translate C++ to C.

    you can do it using structures and arrays of function pointers (which is basically what C++ does under the hood).

    the only thing that you can't really do is templates (although you can get close with loads of evil preprocessor macros)

  8. #8
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    >>the only thing that you can't really do is templates
    basic templates can be done with macros. what you cant do is encapsulation. C has no way of specifying private data.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  9. #9
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Quote Originally Posted by Stoned_Coder
    >>the only thing that you can't really do is templates
    basic templates can be done with macros. what you cant do is encapsulation. C has no way of specifying private data.
    true, but encapsulation is a compile-time only mechanism. it has no effect on the generated code (in this case, C).

  10. #10
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    The idioms of the various languages are fairly different. For some reason I doubt any program around today could produce any code in another language you'd actually want to use.

  11. #11
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Quote Originally Posted by orbitz
    The idioms of the various languages are fairly different. For some reason I doubt any program around today could produce any code in another language you'd actually want to use.
    Readable, maintainable code? not a chance. But if you just want to compile it and use it, there are several programs that do things like that. CORBA IDL compilers, for example, generate C++ or java classes from an interface spec.

  12. #12
    Registered User
    Join Date
    Jun 2005
    Posts
    5,827
    Quote Originally Posted by Stoned_Coder
    >>the only thing that you can't really do is templates
    basic templates can be done with macros. what you cant do is encapsulation. C has no way of specifying private data.
    You're correct that C has no way of specifying access control to data, but it doesn't need to.

    The translator would actually be responsible for enforcing access control (eg preventing invalid access to private data). In other words, the translator would refuse to spit out C code if an invalid access to private data is attempted. The C code, if generated, would not attempt such invalid accesses, so the C compiler does not need to check such things.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mats, the java answers
    By Jaqui in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-22-2008, 02:12 AM
  2. Java vs C to make an OS
    By WOP in forum Tech Board
    Replies: 59
    Last Post: 05-27-2007, 03:56 AM
  3. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  4. Comparing Pascal, C, C++ and Java thru Code.
    By jozzua in forum C++ Programming
    Replies: 14
    Last Post: 07-07-2004, 12:03 AM
  5. About the Morse code Converter
    By Amber_liam in forum C Programming
    Replies: 17
    Last Post: 05-29-2002, 08:35 AM

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