On Wednesday 15 September 2004 11:05, Jerry Feldman wrote:
Without including the quotes, let me answer a few things. First, Java is an entirely new language where C++ is specifically a derivative of C, that includes the power of C. On the same page, C++ also inherits some of the ugly features of C.
I can't speak with unquestionable authority on this, but I believe you might find Java has it's own hidden legacies. Namely Small Talk and Lisp (spelled Emacs).
Threads. I consider this a plus for Java since the programmer does not need to consider different threading models.
Until very recently, I was of the opinion that C++ was better off without standardizing threading. That allows for other threading 'standards', models, or whatever you want to call them to be created to suite specific needs, or simply to allow for more innovation. Sure with Java you pretty much know what you are dealing with in all cases. But that doesn't allow for much flexibility. The reason I say 'until recently' is because I found this: http://people.redhat.com/drepper/tls.pdf
Graphics. This is a debatable issue.
Some other things I personally prefer in Java over C++: primitive type standards, such as integer sizes. These are all defined by the Java specification so that you are guaranteed an int is 32 bits, a long is 64 bits. In C and C++, an int may be as small as 16 bits and as large as a long (although most 64 bit implementations use a 32 bit int). Longs on a 32 bit system are normally 32 bit and 64 bits on a 64 bit system, and could be 128 bits on a 128 bit system.
My understanding is that the latest C standard actually provides similar definitions. I brought this up on comp.std.c++, but can't say there were any conclusive commitments from anybody.
Character data types in Java are full unicode where they are simply a very short int (eg. 8 bits) in C and C++.
There is the wchar_t, and there are some pretty comprehensive libraries out there for C++. I've looked that this in the past: http://oss.software.ibm.com/icu/
Another debatable issues is inheritance. Java uses a single inheritance model where C++ uses multiple inheritance.
For the most part, I believe C++ has the better model in this respect. Sure there's the evil diamond, but I haven't encountered it that much. There are some costs to using pure virtual classes as interfaces which might be mitigated. I really haven't been able to evaluate this, but I do find it interesting: http://www.heron-centric.com/2004/08/c-with-interfaces-article-addendum.html
C++ also supports templates. Templates are very powerful, and allow C++ to use a single container model to contain just about anything. But, there are ways to do similar types of things in Java.
Yes. Java 1.5-beta has something called generics, but I can't say much about them other than they are advertised as being like C++ templates. Templates are significantly different from the Java brown-paper-container model. C++ templates are 'compiled away', whereas Java containers, as I understand it, are pretty much a runtime entity that doesn't lend itself to the same kinds of optimization that templates provide. I'll grant that Java's containers were much easier for me to learn. I always had a level of dislike for the requirement to pack and unpack things with pervasive castings, which templates don't require. While the portability of Java may I find some uses of the CPP utterly distasteful. I sincerely believe that many of the common uses of macros make it very difficult to create the same level of tools (IDEs) you can find with Java, and the notion of #including multiple levels of source files is simply offensive.
mitigate this, the conditional compilation in C++ allows for an implementation to comply with different standards and different platform dependent features. In a complex product, I generally use this to add debugging code that I do not want in production code.
I've noticed that C/C++ programmers moving to Java tend to take that kind of approach until they discover that exceptions work better in most cases when handling error trapping in Java.
Performance: In most cases, a C++ application will significantly outperform a Java application. However, some C++ features make optimization very difficult where a good Java compiler with a good JIT can cause a Java application to perform well.
From what I understand, the door has only been opened on what can be done with C++ regarding optimization in some situations. These mostly have to do with sophisticated mathematics.
There are many IDEs that make both C++ and Java reasonably easy to use in a graphical environment, simplifying the code.
My experience it that Java IDEs are better than C++ IDEs in providing the features I benefit most from. C++ tends to be too unstructured and unpredictable to provide the same level of error detection, resource location, and code completion that I found with JBuilder. -- Regards, Steven