C++ or Java To be or not to be??


I have been playing around with Java and C++ for a little while (Visual Studio 6).

In general terms, if I wanted to write a simple dialog based win app, is there any benefit using c++ over Java (or visa versa).

I know its a bit vauge but i'm only really looking for thoughts / opinions on this.
Who is Participating?
matth012098Connect With a Mentor Commented:

   Ive programmed in VisualC++ for many years and find that writing software for windows based applications takes a lot of reading the docs, especially using MFC. It can also be quite difficult getting to frips with the way the messaging system works. I have just recently over the last couple of months started to learn Java and I find it much easier to manage. I am a computer games programmer and have written many games in many languages and I must say that I find Java the best for its simplicity and portability. Java could probably never be as fast as something like C++, because C++ compiles straight to native assembly, however companies are now working on hardware implementations of the Java Virtual Machine (JVM), which does come with Windows 98 and can be upgraded from Suns site. These hardware JVM's will allow software that is as competitive if not as good as software for todays native systems. Here are list of advantages and disadvantages of using Java:

Java - Advantages
1. Java can call native code written in C++ via COM
2. Cross platform support, including mobile phones, digital set top boxes, Unix, Windows, DOS, Linux etc.... The code you write will work on any machine that has a JVM and you will not have to rewrite whole lilbraries of code to get it to work.
3. Hardware JVM's in development, bye bye software interpreters
4. Versatile and very very easy to use
5. Excellent support on the net
6. Applications can be written to run in a web browser (ActievX can , but it is generally not as trusted due to its client side access to your information)
7. When your software crashes it doesnt generally take the OS down with it.
8. Fun to write in
9. Windows functionality is part of the huge Java library that comes with it
10. The IDE for VisualJ++ is the same as for VisualC++
11. Free compilers and tools from sun
12. Syntax is very similar to C++, so you could learn both at the same time

Java - Disadvantages
1. Bytecodes (Java assembly) must be interpreted by the JVM so it can be slow for doing things such as advanced calculations, however performing tasks such as blitting images to the screen are implemented in native platform code inside the JVM so they are as fast as C++
2. More work in C++ at the moment, but theres even more work in VB

The above lists are by no means complete, they are simply off the top of my head

C++ and many other languages that compile to native code absolutely faster but they are harder to write in and will fade out in years to come.

Hope this helps



  Heres a small example in Java

class Example
  public static void main(String[] args)
    System.out.println("Hello World");

and in C++ (Well C)

#include <stdio.h>

void main(int argc, char *argv[])
  printf("Hello World\n");

Although noted the above is not encapsulated into any class. If I did this as with the Java implementation then the source would be much longer and complicated.

java is much easier to program and just about as powerful as c++, some may disagree here, but it's also slower to run and requires the computer that's running the app to have a java runtime environment installed

I think C++ is easier! Of course, the language sometimes is difficult, but the IDEs are better, I think!
Look at www.borland.com! Order a Demo-CD and you'll see, the C++Builder is very easy to use!!!
(and creates standalone exes, too)
Ginger_EdAuthor Commented:
I've got Visual C++ so I'll be using that.

But is there any noticable difference in speed in a small app.  

Also am I right in thinking that the only java runtime they need already comes with win98 / nt / 2000??

Ginger_EdAuthor Commented:
cheers,  I have been playing around and I find Java a hell of a lot easier.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.