3 ms·
If I were to compare complexity C++ and Java, I would say that the former is much more complex and intricate than latter. Complexity of both of course keeps inc
by wuch 11y ago
If I were to compare complexity C++ and Java, I would say that the former is
much more complex and intricate than latter. Complexity of both of course keeps
increasing. But, that does not necessarily mean that programming in any of them
is getting more complicated. Argument is often made, for example by Stroustrup
himself, that while language is getting more complicated, using it is getting
easier and more intuitive. This argument seems to have some merit.
Going back to C++ / Java comparison, lets have a look at some objective and
subjective metrics. I am analyzing "The Java Language Specification - Java SE 8
Edition" and "Working Draft, Standard for Programming Language C++ N4527", in
case someone would like to repeat this exercise.
The Java specification has 780 pages, C++ standard has 1367 pages. Of course
there are quite a few objections to be made about this comparison. First, if
you open both standards side by side it is quite clear that typesetting and
margins are quite different. Java has wider margins and a bigger font. So as a
next step lets have a look at number of words. I converted both PDFs to text
using pdftotext and counted number of words using 'wc -w'. This gives 227958
words for Java specification, and 477719 words for C++ standard.
But that is still hardly fair. C++ standard contains description of standard
library, Java specification in general does not (partially it does specify
Object, Class, Thread, and some of exceptions, but lets ignore this issue). How
many pages of C++ standard constitute description of standard library? I would
say that all from "17. Library Introduction" up to "30. Thread support
library", additionally including "Index of library names". Those constitute 777
pages, leaving only 590 for description of C++ language itself. That would be
less than Java specification, but if we go back to word metric, this gives us
249186 words for C++ standard, a little bit more than Java, but not much.
From more subjective perspective, I would say that Java specification is
written using much simpler language, but that does mean that it is less
precise. Moreover it seems to me that Java specification contains more
non-normative text than C++ standard does. I would also say that reading Java
standard from front to back doesn't seem to be very challenging (with small
exceptions like overloading, which seems to be one of most complex parts of
Java). And when I write 'reading', what I am really mean is reading and
understanding. On the other hand I would never said similar thing about C++
standard. Understanding C++ just by reading standard seems almost impossible,
as most of commentary and useful discussion is contained elsewhere: in
proposals and defect reports.