View Full Version : From C++ to Java
01-27-2010, 10:43 AM
Ok so this year i decided to program for my robotics team. Last year the code was in C++. The only problem is that i do not know C++, but luckily i know Java. So i found a C++ to Java converter. This would be wonderful if i actually had all the libraries that it needed to convert it. I asked my leader about it and he said that they had changed the names of some of the libraries. The libraries (if library is not the correct term please correct me as i am unfamiliar with C++) that i can not find are:
If anyone could help me with this it would be wonderful because i would rather not convert it manually. Or just tell me if you think it would be easier just to start from scratch.
01-27-2010, 04:46 PM
The converter tool is chasing through WPLib and the vxworks headers, and is looking for files that doen't exist even for C++ code.
I don't know the tool you are using, but try to limit it to your robot code itself. WPILib is already converted - you don't need to convert it again :-)
There will be errors, but they should be easy to fix.
01-27-2010, 05:46 PM
i dont need to convert the library im converting the code that my team used last year
01-27-2010, 11:15 PM
Good, we agree that you don't need to convert the library, but I believe that the translator tool was doing it anyway.
You didn't say what converter tool you were using, or how much robot code you have to convert, so I can't give specific advice. I can say that when WPI students ported WPILib from C++ to Java, they essentially used "cut and paste", then fixed the syntax errors. [They had to do a lot more work on FPGA interfacing, etc, that you don't need to worry about it.]
If you are interested in converting from C++ to Java on your own you need to be familiar with differences between C++ objects and Java objects (C++ objects can be on stack, static memory, or in heap, '.' vs. '->'). Also, the Java version of WPILib all method names begin with lowercase letters.
01-28-2010, 03:07 PM
The converter I was using is called Tangible Converter.
01-28-2010, 04:33 PM
C++ and Java are strikingly similar languages in terms of syntax. I would encourage you to not use a translator as they can be frequently inaccurate especially with the high sensitivity of WPILib and just translate the code by hand. It shouldn't be too difficult and if you need help just post chunks and I'm sure someone will help out :)
vBulletin® v3.6.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.