I'm taking some java classes right now, and was wondering if I would be able to integrate applications from both languages?
I'm taking some java classes right now, and was wondering if I would be able to integrate applications from both languages?
Yes. Use JNI to call C / C++.
Mainframe assembler programmer by trade. C coder when I can.
You can but I would not have any clue why you would want to. If you want to make a game in Java then use Java. If you want to make one in C++ then use C++. I have no idea how using both and will help you.
Yes except it's probably going to end up faster to have a C/C++ "rendering" library, that calls OpenGL. Since there is probably more calls to OpenGL than the rendering library. Because calls through the JNI adds HUGE overhead.
You may want to check out Jake2, a Java port of the Quake2 engine. Most of the 40% slowdown is caused by allocations and calling the OpenGL bindings through JNI.
Either way, I agree with the others. Use C++ or Java, not both . Although it'd probably be cool to write the map editor in Java.
Last edited by zacs7; 10-18-2008 at 05:24 PM.
As long as you use native controls... just please boycott java controls.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
SWT all the way. Native widgets, platform independent, and if a platform doesn't support the widget you want to use it's emulated.
> As long as you use native controls... just please boycott java controls.
Second.
Howbout the best way to communicate c++ and java program,is it rpc-xml???
yeah so nobody accuse me of going off topic,hmmm let say i want to create game A in C++ and game B in java..what library should I use so they both talk to each other???
it's rpc-xml the way to go?
No, that'd be extremely slow. Depends on how much, and how frequently you need to send data between A and B.
The fastest option is still JNI, but it is slow compared to native calls. For example C++ calling a C library function.
JNI i guess is the way to go then...
thanks.
I agree with zacs7 in that you want to be making as few calls through the JNI as possible. Although, unlike everyone else, I don't see why you should not use both C++ and Java.
For anyone wanting to play around with the JNI this Netbeans tutorial got me going with it:
http://cnd.netbeans.org/docs/jni/beginning-jni-win.html
Normally you would choose a language based on how it is going to help you reach your long term goals. I don't see what Java brings to the table in the context of a game that you could not do just as well and faster in C++. Java would certainly bring a lot of GUI functionality, however, most in-game GUIs are either using pure Direct3D or they are using some type of flash API. It may actually take more time to streamline and stabilize a C++/Java game than it would just to do it either in pure Java or pure C++.I agree with zacs7 in that you want to be making as few calls through the JNI as possible. Although, unlike everyone else, I don't see why you should not use both C++ and Java.
So my question to the OP is what is Java bringing to the table that C++ isn't bringing you. Or on the other hand what is C++ bringing to the table that Java isn't?
Before you start some mixed language program it might be a good idea to research the pros and cons of doing so. It could save you tons of dev time and a lot of headaches in the long run.
Yeah, you have a point there. It may not be suitable for the project.