Results 1 to 14 of 14

Thread: Translating/converting/compiling from C++ to C, and from C# to Java

  1. #1
    HEXUS.social member finlay666's Avatar
    Join Date
    Aug 2006
    Location
    Newcastle
    Posts
    8,546
    Thanks
    297
    Thanked
    894 times in 535 posts
    • finlay666's system
      • CPU:
      • 3570k
      • Memory:
      • 16gb
      • Graphics card(s):
      • 6950 2gb
      • Case:
      • Fractal R3
      • Operating System:
      • Windows 8
      • Monitor(s):
      • U2713HM and V222H
      • Internet:
      • cable

    Translating/converting/compiling from C++ to C, and from C# to Java

    Long story short I'm looking to port some of my apps across format (Windows Mobile to Android and another side project potentially to another platform)

    Are there compilers that will compile/translate C# and output a java file? I dont care on the readability for this one, as it's a straight port I plan to do then change the important calls... it's mostly refactored nicely already

    Other one is a cross platform port from C++ to C for linux, most of the work has been done already (it was badly written in Java!) but still interested if there is something that can save the work
    H3XU5 Social FAQ
    Quote Originally Posted by tiggerai View Post
    I do like a bit of hot crumpet

  2. #2
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,231
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Can't see C# to Java working as the Libraries and interfaces are completely different: unless you haven't used a single object in your script you'll need to rewrite it to use the Java equivalents of the .NET classes. Depending on what your app does that could be a pain the rear, frankly - for some tasks there is no direct .NET - java translation and you have to (slightly) rework the implementation. Also AFAIK Android uses a number of non-standard libraries so you'd need a special C# -> Android interpreter.

    tbh I think you'll be much better off just rewriting in Java. Is this a personal project or proper paid work?

  3. #3
    Late Night Ninja! CrazyMonkey's Avatar
    Join Date
    Oct 2006
    Location
    Bristol
    Posts
    1,510
    Thanks
    29
    Thanked
    44 times in 43 posts
    • CrazyMonkey's system
      • Motherboard:
      • Asus M4N98TD Evo
      • CPU:
      • Phenom II X6 1055T @ 4.1ghz
      • Memory:
      • 8GB DDR3 Dominator @ 1700mhz
      • Storage:
      • 120GB OCZ Vertex 2E - 1TB Hitatchi
      • Graphics card(s):
      • 2x 460 1GB
      • PSU:
      • 850W
      • Case:
      • Silverstone Fortress FT02R-WRI Ltd.Edition
      • Operating System:
      • Win 7, XP, Server2008 RC1, Gentoo
      • Monitor(s):
      • 24" Acer LED - 22" Belinea - 19" Samsung - 19" IIyama
      • Internet:
      • 50 MB Virgin Media Cable

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Quote Originally Posted by scaryjim View Post
    tbh I think you'll be much better off just rewriting in Java.
    Agreed.

  4. #4
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    C++ is 'C with classes', the problem isn't with the C++ working on Linux, that'll work fine, the problem is whatever libraries you may use, and as far as I know, there is no MFC->Qt converter because it requires intelligence to understand the difference between the two environments to make the changes.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  5. #5
    Senior Member
    Join Date
    Jul 2004
    Location
    London
    Posts
    2,456
    Thanks
    100
    Thanked
    75 times in 51 posts
    • Mblaster's system
      • Motherboard:
      • ASUS PK5 Premium
      • CPU:
      • Intel i5 2500K
      • Memory:
      • 8gb DDR3
      • Storage:
      • Intel X25 SSD + WD 2TB HDD
      • Graphics card(s):
      • Nvidia GeForce GTX 570
      • PSU:
      • Corsair HX520
      • Case:
      • Antec P180
      • Operating System:
      • Windows 7 Professional x64
      • Monitor(s):
      • HP w2207 (22" wide)
      • Internet:
      • Rubbish ADSL

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Quote Originally Posted by scaryjim View Post
    Can't see C# to Java working as the Libraries and interfaces are completely different: unless you haven't used a single object in your script you'll need to rewrite it to use the Java equivalents of the .NET classes. Depending on what your app does that could be a pain the rear, frankly - for some tasks there is no direct .NET - java translation and you have to (slightly) rework the implementation. Also AFAIK Android uses a number of non-standard libraries so you'd need a special C# -> Android interpreter.

    tbh I think you'll be much better off just rewriting in Java. Is this a personal project or proper paid work?
    Pretty much what he said

    Even if you could find a C# to Java translation tool, there are lots of domain specific classes/interfaces used so translating that couldn't be done automatically. Things like GUIs and any system calls would be too different for any simple translation between the two platforms.

    Since C# and Java are pretty similar in syntax you may find sections of the code can just be copied over and given minor edits, but you're still going to have to restructure and rewrite a significant amounts of the program.
    I don't mean to sound cold, or cruel, or vicious, but I am so that's the way it comes out.

  6. #6
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    I imagine writing a piece of software which could corralate suggestions for the difference in types between the C# and Java libraries would be difficult enough, without a converting the code as well. I mean take C#.NET IComparable interface for example, a commonly used interface. How would you cleanly convert implementors to Java's Comparable<T> type? It would require a lot of rigourous code to do that cleanly, and that is just one extremely simple interface from thousands of types. A C++ to C converter makes even less sense.
    To err is human. To really foul things up ... you need a computer.

  7. #7
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Quote Originally Posted by yamangman View Post
    I imagine writing a piece of software which could corralate suggestions for the difference in types between the C# and Java libraries would be difficult enough, without a converting the code as well. I mean take C#.NET IComparable interface for example, a commonly used interface. How would you cleanly convert implementors to Java's Comparable<T> type? It would require a lot of rigourous code to do that cleanly, and that is just one extremely simple interface from thousands of types. A C++ to C converter makes even less sense.
    Actually that one would be easy (What with IComparable<T> n all........).

    Is it possible to use mono on the target device?
    throw new ArgumentException (String, String, Exception)

  8. #8
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Quote Originally Posted by TheAnimus View Post
    Actually that one would be easy (What with IComparable<T> n all........).

    Is it possible to use mono on the target device?
    Java has no 'comparable' non-generic Comparable interface as far as I'm aware. Object could be its type but that defeats its' purpose. Like you say it's a 'easy' example, but one of many thousands in total and probably many hundreds where there is no corollary whatsoever.
    Last edited by yamangman; 09-01-2010 at 01:58 AM.
    To err is human. To really foul things up ... you need a computer.

  9. #9
    HEXUS.social member finlay666's Avatar
    Join Date
    Aug 2006
    Location
    Newcastle
    Posts
    8,546
    Thanks
    297
    Thanked
    894 times in 535 posts
    • finlay666's system
      • CPU:
      • 3570k
      • Memory:
      • 16gb
      • Graphics card(s):
      • 6950 2gb
      • Case:
      • Fractal R3
      • Operating System:
      • Windows 8
      • Monitor(s):
      • U2713HM and V222H
      • Internet:
      • cable

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Quote Originally Posted by TheAnimus View Post
    Is it possible to use mono on the target device?
    I don't think Android supports Mono, the WM app used .Net CF 3.0 (or 3.5) for the xml which should already be present

    The C++ one is fairly straightforward, I have already translated from java to C++ (there is a translator available for it)

    Personal projects, I wrote the app in my sig for a competition and wanted to get some experience with android so figured (as I have done a bit of java already and it's another OO language) to port my app to. Benefit is dev tools are free (like Windows Mobile but unlike iFail) and I don't have to release to the app store so save money there
    H3XU5 Social FAQ
    Quote Originally Posted by tiggerai View Post
    I do like a bit of hot crumpet

  10. #10
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,231
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Quote Originally Posted by finlay666 View Post
    ... and wanted to get some experience with android ...
    Fair enough - I was considering offering assistance in porting it, but if you want experience that's probably not going to interest you!

  11. #11
    HEXUS.social member finlay666's Avatar
    Join Date
    Aug 2006
    Location
    Newcastle
    Posts
    8,546
    Thanks
    297
    Thanked
    894 times in 535 posts
    • finlay666's system
      • CPU:
      • 3570k
      • Memory:
      • 16gb
      • Graphics card(s):
      • 6950 2gb
      • Case:
      • Fractal R3
      • Operating System:
      • Windows 8
      • Monitor(s):
      • U2713HM and V222H
      • Internet:
      • cable

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Quote Originally Posted by scaryjim View Post
    Fair enough - I was considering offering assistance in porting it, but if you want experience that's probably not going to interest you!
    Nah it's ok, it'll be for a contest no doubt anyway, good way to get visibility it seems (won a Samsung NC10 netbook with the other entry)

    Working with ARM stuff in C atm, that isnt too nice dealing with radio transmitters for communication etc
    H3XU5 Social FAQ
    Quote Originally Posted by tiggerai View Post
    I do like a bit of hot crumpet

  12. #12
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,231
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Quote Originally Posted by finlay666 View Post
    ... won a Samsung NC10 netbook with the other entry ...
    Nice one! Maybe I should look into doing some of these competitions...

  13. #13
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    Quote Originally Posted by finlay666 View Post
    I don't think Android supports Mono
    http://www.koushikdutta.com/2009/11/...n-android.html

    the problem is tools & polish. actually, try doing a search on the google market for "mono" for a proof-of-concept.

  14. #14
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,231
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Translating/converting/compiling from C++ to C, and from C# to Java

    I don't think I'm going to bother learning new programming languages anymore - if I wait long enough someone'll make the ones I do know work on everything anyway...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •