Should we use Java?
Hello Java World,
We are seriously considering using Java on an upcoming project that must interface with a lot of legacy C/NT and eventually C/UNIX code. For a separate project we may want to redo our GUI's but they must retain a true windows look and feel.
We have strong C/UNIX/NT and VB/NT/COM backgrounds, but only academic Java. We really need some hard facts about Java:
1. How easy is it to interface to C? Via JNI? Are there issues with calling conventions (cdecl, Pascal, etc.)? Is it efficient?
2. How tough will the real life learning curve be for a small team of good developers?
3. How easy would it be to keep our C/NT/Win98 GUI's (not MFC) and call down to Java?
4. We often walk and parse strings. Will this be a speed issue? Just about everything we do must be fast.
5. Does Java or the JVM ever crash when pushed hard?
6. Our modules communicate via TCP sockets. Is Java fast and stable in this area?
Thanks so much for any advice!
Mike
Are you looking for a reason to use java? Or a reason to continue to use C++? Or are really doing a technological assement?
>1. How easy is it to interface to C? Via JNI?
>Are there issues with calling conventions (cdecl, Pascal, etc.)?
>Is it efficient?
There is only one interface: JNI. You follow it or you don't talk to java. That eliminates things like cdecl, pascal, etc.
See 3 below.
The JNI/C interface is slower than staying entirely in one language.
>2. How tough will the real life learning curve be for a >small team of good developers?
For C++ developers who understand OO it is probably very easy.
For C developers who still think of MFC as an excellent example of OO design methodogy I would guess the ride is going to be rougher. But perhaps not as much as a old school COBOL programmer.
>3. How easy would it be to keep our C/NT/Win98
>GUI's (not MFC) and call down to Java?
This seems rather messy. To go from C to java your C application has to create a JVM and then create instances and then call the methods on the instances. Not including error checking this translates into at least 3 times as many lines to do the same thing in java.
Java can be used to create server and intermediate layers. But most people usually start with the gui level. And you completely loose the portability benifit of java.
>4. We often walk and parse strings. Will this
>be a speed issue? Just about everything we do must be fast.
Everyone wants everything to be fast. But in the vast majority of cases performance has nothing to do with language. Requirements and design can affect the performance of a system easily causing orders of magnitudes in differences. Environment can also impact this. Language is dead last.
>5. Does Java or the JVM ever crash when pushed hard?
Huh?
You mean does the JVM have bugs? Yes. But you can get the source code for the Sun jdk and fix them yourselves. And you have complete access to the Sun bug database to see what bugs there are. You can't do either with MS C++ 6/5. And I know that MS VC 6/5, both have bugs including producing the wrong machine code for valid C++ code.
Not to mention that I have two simple apps running on NT and by clicking the button on one I can often cause the blue screen of death.
And do you have an automated suite to measure performance and to load test your current application? Do you run under the checked build of the OS? Do you test under multiple versions/service packs of the OS you deliver to? If not then I seriously doubt your present application is robust anyways.
>6. Our modules communicate via TCP sockets.
>Is Java fast and stable in this area?
I have seen claims that suggest that socket throughput is slower under java than C. I haven't verified this.
Of course if one was really concerned about speed one would probably be using UDP and TCP anyways, so how critical is this to you?
> Are you looking for a reason to use java? We are aiming to increase programmer productivity. Language is one part of that.Thanks for your input and observations.Mike
I agree that the Java learning curve is very minor for a reasonably competent OO C++ programmer. Java will provide very nice productivity gains as well, however JNI is a thorny solution for legacy integration. You will really need to use you noggins to define a well understood interface between c++ and java through JNI. Is it possible to use distributed computing for the bridge instead, through sockets, or whatever? If you can live with the performance hit, it will probably be a much smoother ride.
> 2. How tough will the real life learning curve be for
> a small team of good developers?
I agree with the others that it shouldn't be tough for
a good C++ developer to learn Java,
BUT (and it's a real big BUT)
if your team has hardly any experience with java
and you have serious requirements like
- performance
- network stuff
- interfacing to c/c++
stay with the languages you know.
In any new language a newbie will make mistakes.
You just can't forcefeed the java api specification to yourself and belief you are a good java developer.
You need experience. If you want/need to go with java
make sure you have at least one experienced java developer on the team who can give hints to the others
Spieler
> >6. Our modules communicate via TCP sockets.
> >Is Java fast and stable in this area?
>
> I have seen claims that suggest that socket throughput
> is slower under java than C. I haven't verified
> this.
At the level of sending/receiving bytes the performance is pretty much equal. Depending on the application (and coding skill) Java may be slower when coding/decoding data into bytes.
If you plan to maintain your product, Java will likely be easier to maintain than C++. Javadoc will make your API's easier to navigate, since the documentation is extracted from the code. Which is nothing new, C++ could have the same benefits if you get the right tools and adhere to their usage standards.
If performance is an issue, Java is close to C++ speed. A colleague benchmarked a C++ application against a Java program written to do the same thing using IBM's JVM, timing things after all objects were allocated. I seem to recall that Java only lagged by about 10%. Essentially, it was an exercise in number crunching.
I can't really offer any more advice. I used to program entirely in C++. C++ was my language of choice and I felt very effective in it. Java has since replaced C++ as my language of choice. The libraries are very rich and the community is very helpful.