jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes Another Q for Herbert Schildt ... pure java apps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Another Q for Herbert Schildt ... pure java apps" Watch "Another Q for Herbert Schildt ... pure java apps" New topic
Author

Another Q for Herbert Schildt ... pure java apps

Michael Sullivan
Ranch Hand

Joined: Dec 26, 2003
Posts: 235
Herbert Schildt,
I'm a recent (one year) newcomer to the Java language. Recently I've begun more in depth programming with Java as a server side language, and targeting some Java certifications. Referencing many books and websites while preparing for exams have led me to some interesting information.
The most curious to me is that many of the texts claim that C++ will run faster and with less resources than a pure Java application. Additionally, I've found that some Java servlet containers are written in C++, but opertate Java-like. Though I believe that Java as a server side technology has proven itself, are pure Java applications a real contender in desktop computing (when compared to C++ apps)?
Thanks for your response!
Michael Sullivan
Herb Schildt
Author
Ranch Hand

Joined: Oct 01, 2003
Posts: 239
Michael:
Thanks for your question. It raises an interesting point. A full discussion of these issues would involve a very long discussion -- longer than is possible here. However, I will offer a few thoughts.
First, your question about runtime performance: As things currently stand, given two identical programs, one Java, one C++, the C++ program will typically run quicker because C++ is typically compiled to native code that the CPU executes directly. Java code is compiled to an intermediate code (called bytecode) which is executed under the control of the Java Virtual Machine (JVM). Thus, the typical Java environment incurs an overhead that is not present with C++.
In the preceding paragraph, I repeatedly use the word "typically' because I am sure that exceptions can be found. Furthermore, it is now possible to write "managed C++", which executes in a managed environment in much the same way as Java does.
One other point: Because of advances to the JVM over the years, (such as on-the-fly compilation), the runtime differences between Java and C++ are less pronounced today than they were years ago. Frankly, I think that Java is a good choice for many, many different types of programs. In fact, this is one of the main themes in my book The Art of Java. Java is a powerful, full-featured language that is up to nearly any task!
In general, when thinking about Java and C++ it is important to remember that both were invented to solve different sets of problems. In the case of C++ (which grew out of C), it was to facilitate the creation of high-performance, system-level software. For Java, it was to enable the creation of cross-platorm, portable, safe, and secure code. Thus, both languages have their uses, and their strong points. Fortunately, because of their similarities, most programmers eventually become fluent in both.
To a larger point: Today, the world of professional programming revolves around a core syntax that is shared by C/C++/Java/C#. This is the mainstream. Its where the action is. Its where the next advance in programming will flow from.
Its really an exciting time to be a programmer!


For my latest books on Java, including my Java Programming Cookbook, see HerbSchildt.com
 
Don't get me started about those stupid light bulbs.
 
subject: Another Q for Herbert Schildt ... pure java apps
 
Similar Threads
How to insert using hibernate?
* Welcome Herb Schildt
Try Catch and Finally!
Info on Collections needed
New To Java