February 27th, 2003, 09:22 PM
C++ vs. Java compatibility
It seems that it is a big hassle in programming C++ across different platforms. As I understand, in Java, "one code practically fits all." Why do developers continue to write there applications in C++ if they can get an all-in-one solution with Java? I understand Java is slower than C++..what is the rest of the story?
February 27th, 2003, 10:08 PM
"As I understand, in Java, "one code practically fits all."
I've read where that is not necessarily true, but on the whole I think programmers consider Java more portable than C++.
"Why do developers continue to write there applications in C++"
What you know is what you tend to use. It's very hard to initiate a shift away from a dominant language.
"I understand Java is slower than C++."
That is a huge reason. In some industries, speed is everything.
I tried to work my way through Wrox's Beginning Java 2, but I gave up when I got to stream input and output. It was so convoluted and confusing, and you needed so many classes to do anything. Heck just setting up the free software and trying to compile programs was difficult. Personally, I think if it's difficult to compile programs, the language has some major problems
Last edited by 7stud; February 27th, 2003 at 10:19 PM.
February 27th, 2003, 10:24 PM
Speaking from a Windows perspective, you can't beat C++. As you mentioned, C++ is faster, but another big aspect that is very important is the dev environment as a whole: Visual Studio and the MSDN library simply can't be beat! The integrated debugger is bitchin', and the F1 help is an absolute time-saver. Since I'm not a Java programmer, I don't know much about their dev environments, but I challenge you to find one that is as complete as Visual Studio.
From a general dev point of view, IMHO speed is the biggest reason not to switch. The application I work on would not work written in Java - the UI components are just too slow, and I wouldn't even attempt to write the engine in Java. Likewise, whenever I come upon a Web page with a Java applet in it, I usually don't even bother. I hate waiting for the applet to load (I usually do the same for big flash movies, too, so it's not a bias against Java).
Also, the notion that Java is a "write once, run anywhere" language is just a theory. Again, I haven't really looked, but off the top of my head I can't think of one mainstream app that was written once and will run anywhere (excluding Java applets, but I hear even those can have problems). When the language is truly portable, then they will have something to brag about. (If you know of such an app, please point it out to me.)
When someone produces a Java IDE that rivals Visual Studio, and when Java runs at the same speed as C++, and when Java is truly portable, then it will be worth it to me to consider Java as a viable alternative. But until then, I don't have a use for it.
"Me fail English? That's unpossible!"
February 27th, 2003, 10:58 PM
Lucky I'm here. So far this discussion has been pretty one sided in a friendly sort of way.
Java is a tool. It allows programmers to build safe, large programs, and large small safe programs.
C++ is a tool that allows programmers to build large fast and very unsafe programs, but small fast safe programs.
The biggest problem with java is that it must be implemented on an operating system. Java has no file copy function but has built in network support! Which do you do more of in an ordinary desktop application? Surf the web or access files. So if you want to copy a file you have to stream it accross or call the os. So Java is half os/environment and half language.
Java could have been a language without the environment half.
Maybe the step was too big for people to take all at once.
Also the number of standard packages takes some time to get used to. But thats what javadoc is for! Without the proper tools any language is hard. 'C' is hard if you don't have a compiler!
Java as and environment is as annoying as any OS. Eg. compiled class files have to be placed in directories of the same structure as their package names? Why? Not because the java language wouldn't work if it was done a different way, but just because sun thought that was the easiest and made it the standard. Until you use jar files of course.
Java as a language is small consise, safe and sufficient for most tasks. The runtime part seems to be the main problem. Not because its bad but because its visible. Oh no I have to download another virtual machine version.
As to the applet thing. There are only approximately 3 versions of java applets. 1.0, 1.1 and 1.2 (these are sdk versions) or 1.0 1.1 and 2.0 (I think thats the java version translation) If you don't have the correct version it don't work, same as dos, 16 bit windows and win32 (same sort of comparison).
C++ on the other hand is language and ruintime library, but everybody has their own version of the standard library or preprocessor which makes code port 99.9% but hard to find the other .1% by hand.
As we start to reuse code java becomes more valuable because you can't reuse code with bugs over and over. Eventually you just have to start again. With java if you squish the bugs faster you code will live and get reused more often.
I have worked on a very large project in java compiled on a window NT machine then the compiled classes were copied to a multi processor mainframe. And it worked first time every time!
The only issue we had was with getting the latest jdbc drivers for the mainframe to talk to the database. But that was when java was new!
One final note on where java is well used is web servers. They may not be totally java they may be half C++, and half Java but the java half is as important as part that are not.
Last edited by ngibsonau; February 27th, 2003 at 11:02 PM.
February 28th, 2003, 02:55 AM
I am happy that the moderate view had been provided by ngibsonau
Right tool for the right job is usually the ticket.
I have only recently discovered devshed, and I really like this place, but the focus is on web development and more on inviduals working on smaller projects, from what I can tell.
Java is a language and an system-level environment (as .NET is as well if you consider C#), which sees most of its action in middle-ware and system-level server-side development. For the areas that Java shines in, it SHINES! Honestly, the whole .NET thing is a direct reaction on Mircosoft's part to Java.
The problems that 7Stud describes are very common for many Java newbs and it can be difficult to first get past Java's nuances. There are some good IDE and development platforms for Java (JBuilder, VisualAge, TogetherSoft, Eclipse), but Visual Studio's tight integration with the OS will always make it a tough act to follow for sure.
If there is one reason to continue to support and learn about Java it is this:
Java IS very cross-platform, "write once run anywhere" capable and if you are AT ALL interested in non-MS platforms, Java should continue to be considered. Now, if you believe the sun rises and sets over MS, then learning C# and .NET (or even sticking to C++/MFC) are valid choices. I am not so sure I would bother with Java if I knew that my world would never expand past MS. However, since I DO believe in alternate and OpenSource platforms, I respect Java and find its API to be powerfully net-oriented and forward thinking.
February 28th, 2003, 07:13 AM
What are some platforms that C++ can't touch that java can?
February 28th, 2003, 12:27 PM
I think the real issue is portability. I believe that many platforms have a C/C++ compiler for them.
However, there was mention of a desire for something that allowed programs to be easily written for MAC/Windows/Unix and Java is a good candidate for that.