Java vs C++

  • Thread starter Lawrence D'Oliveiro
  • Start date
L

Lawrence D'Oliveiro

In the beginning, Java was supposed to be a much simpler language than C++,
in some sense leaving out all the unnecessary complications, while keeping
the worthwhile parts.

This PDF copy of “The Java Language Specificationâ€, 3rd Edition, that I’m
currently reading, has 684 pages. By comparison, the paper copy of “The C++
Standard†on my bookshelf has 782 numbered pages. As you can see, Java is no
longer that far off C++ in complexity.

Most of that complexity seems to be caused by the addition of generics to
Java. This was something that C++ had from the beginning. It was one of the
unnecessary complications that Java left out to start with. But now they’ve
changed their minds, and put it back in. But since they need to be backward-
compatible with existing code, they’ve had to add extra complications that
C++ never had to deal with.

Bjarne Stroustroup must be chuckling over his hot cocoa...
 
L

Lawrence D'Oliveiro

I have always missed generics concept in languages that did not have it,
and I had never worked in C++. :))

Try Python. Has no generics, and doesn’t need them.
 
S

Silvio

In the beginning, Java was supposed to be a much simpler language than C++,
in some sense leaving out all the unnecessary complications, while keeping
the worthwhile parts.

This PDF copy of “The Java Language Specificationâ€, 3rd Edition, that I’m
currently reading, has 684 pages. By comparison, the paper copy of “The C++
Standard†on my bookshelf has 782 numbered pages. As you can see, Java is no
longer that far off C++ in complexity.

Most of that complexity seems to be caused by the addition of generics to
Java. This was something that C++ had from the beginning. It was one of the
unnecessary complications that Java left out to start with. But now they’ve
changed their minds, and put it back in. But since they need to be backward-
compatible with existing code, they’ve had to add extra complications that
C++ never had to deal with.

Bjarne Stroustroup must be chuckling over his hot cocoa...

C++ did not have generics from the beginning. It was added afterwards
and initially without any proper specification of (separate) compilation
and linkage aspects.
 
L

Lew

Lawrence said:
In the beginning, Java was supposed to be a much simpler language than C++,
in some sense leaving out all the unnecessary complications, while keeping
the worthwhile parts.

This PDF copy of “The Java Language Specificationâ€, 3rd Edition, that I’m
currently reading, has 684 pages. By comparison, the paper copy of “The C++
Standard†on my bookshelf has 782 numbered pages. As you can see, Java is no
longer that far off C++ in complexity.

Most of that complexity seems to be caused by the addition of generics to
Java. This was something that C++ had from the beginning. It was one of the
unnecessary complications that Java left out to start with. But now they’ve
changed their minds, and put it back in. But since they need to be backward-
compatible with existing code, they’ve had to add extra complications that
C++ never had to deal with.

Bjarne Stroustroup must be chuckling over his hot cocoa...

Troll alert!

--
Lew
Ceci n'est pas une fenêtre.
..___________.
|###] | [###|
|##/ | *\##|
|#/ * | \#|
|#----|----#|
|| | * ||
|o * | o|
|_____|_____|
|===========|
 
L

Lew

C++ did not have generics from the beginning. It was added afterwards and
initially without any proper specification of (separate) compilation and
linkage aspects.

C++ doesn't have generics. It has templates. They aren't the same thing.

C# has generics. Java has (different) generics. C++ doesn't.

Lawrence is trolling.

--
Lew
Ceci n'est pas une fenêtre.
..___________.
|###] | [###|
|##/ | *\##|
|#/ * | \#|
|#----|----#|
|| | * ||
|o * | o|
|_____|_____|
|===========|
 
A

Arne Vajhøj

In the beginning, Java was supposed to be a much simpler language than C++,
in some sense leaving out all the unnecessary complications, while keeping
the worthwhile parts.

This PDF copy of “The Java Language Specificationâ€, 3rd Edition, that I’m
currently reading, has 684 pages. By comparison, the paper copy of “The C++
Standard†on my bookshelf has 782 numbered pages. As you can see, Java is no
longer that far off C++ in complexity.

C++ is a much more complex language than Java.

Complexity is more than the number of pages in the standard.

Java was designed to have well defined behavior for most things. That
requires rather detailed descriptions.
Most of that complexity seems to be caused by the addition of generics to
Java. This was something that C++ had from the beginning. It was one of the
> unnecessary complications that Java left out to start with.

C++ had templates before Java got generics. Java generics are obviously
very inspired by C++ templates, but are still different in many ways.

But it is correct that generics added some complexity to Java.

Every addition to a language must be carefully considered whether
the benefits outweigh the added complexity.

Arne
 
A

Arne Vajhøj

Try Python. Has no generics, and doesn’t need them.

Generics are not particular useful in dynamic typed
languages.

But since Java is static typed, then not so relevant
for Java.

Arne
 
A

Arne Vajhøj

C++ did not have generics from the beginning. It was added afterwards
and initially without any proper specification of (separate) compilation
and linkage aspects.

Not from the very beginning.

But it was added to cfront pretty early.

Arne
 
O

Owen Jacobson

This PDF copy of “The Java Language Specificationâ€, 3rd Edition, that I’m
currently reading, has 684 pages. By comparison, the paper copy of “The C++
Standard†on my bookshelf has 782 numbered pages. As you can see, Java is no
longer that far off C++ in complexity.

This is an extremely dubious measure of complexity. The Common Lisp
specification is over a thousand pages long in some editions*, but Lisp
is generally considered a much simpler language than either C++ or Java.

You've posted extensively about things you see in Java that you don't
like, and there's a strong "C++ is better" undercurrent to your posts.
While I disagree with the undercurrent, I will defend to the death your
right to program in C++ instead. Just, please, go away.

-o

* <http://www.cs.cmu.edu/Groups/AI/html/cltl/cltl2.html>, which
predates the ANSI spec.
 
J

Joshua Cranmer

In the beginning, Java was supposed to be a much simpler language than C++,
in some sense leaving out all the unnecessary complications, while keeping
the worthwhile parts.

This PDF copy of “The Java Language Specificationâ€, 3rd Edition, that I’m
currently reading, has 684 pages. By comparison, the paper copy of “The C++
Standard†on my bookshelf has 782 numbered pages. As you can see, Java is no
longer that far off C++ in complexity.

My copy of the C++0x draft reference standard, i.e. the copy sent out
for a ballot by national bodies, consisted of no fewer than 1300
numbered pages. Also take into consideration the fact that the C++
standard does not try to pin stuff down into unambiguous interoperable
statements, e.g., a precise size definition for size_t. Java, on the
other hand, goes so far as to fully define the language character set, a
longish, detailed, accessible expose on the threading memory model that
takes up 30 pages, while C++ spends 3 pages on it and still leaves me
wondering what memory is guaranteed to be visible after certain operations.

So 684 pages of well-written, easily-understood text is not nearly as
complex as 1300 pages of dense, example-lacking specification text.
Maybe that's why popular C++ compilers have many more compatibility
problems than popular Java compilers?

Your statement is not up to date.
Most of that complexity seems to be caused by the addition of generics to
Java. This was something that C++ had from the beginning. It was one of the
unnecessary complications that Java left out to start with. But now they’ve
changed their minds, and put it back in. But since they need to be backward-
compatible with existing code, they’ve had to add extra complications that
C++ never had to deal with.

You sir have probably never met the full pain of template
metaprogramming. Indeed, templates is probably the single least
well-supported thing in C++.
 
S

Silvio

Not from the very beginning.

But it was added to cfront pretty early.

Arne

That just depends on what you call early. I used C-with-classes before
it was named C++ and my cfront did not know of templates...

The first "The C++ programming language" book Stroustrup published made
no mention of templates. Stroustrup described templates in his Design
and Evolution of C++ book and later in his second edition of TCPPPL.

And Lew is correct: templates and genercis are completely different beasts.
 
S

Silvio

C++ doesn't have generics. It has templates. They aren't the same thing.

C# has generics. Java has (different) generics. C++ doesn't.

Lawrence is trolling.

Hello Lew,

You are correct, templates are a completely different thing. However,
since they try to achieve a similar goal (albeit in very different ways)
they are often compared and spoken of in combination.

I suspected he is trolling also but could not resist correcting a false
statement.

Silvio
 
A

Arne Vajhøj

That just depends on what you call early. I used C-with-classes before
it was named C++ and my cfront did not know of templates...

The first "The C++ programming language" book Stroustrup published made
no mention of templates. Stroustrup described templates in his Design
and Evolution of C++ book and later in his second edition of TCPPPL.

I am pretty sure that templates were introduced before 1990, which would
place them in the first 1/5 of C++ lifespan.
And Lew is correct: templates and genercis are completely different beasts.

Yep.

Arne
 
S

Silvio

I am pretty sure that templates were introduced before 1990, which would
place them in the first 1/5 of C++ lifespan.


Pretty close. Stroustrups Annotated C++ Reference Manual was published
in 1990 and introduced templates (and exceptions). This was five years
after the first TCPPPL book.
 
L

Lawrence D'Oliveiro

This is an extremely dubious measure of complexity. The Common Lisp
specification is over a thousand pages long in some editions*, but Lisp
is generally considered a much simpler language than either C++ or Java.

Really? By whom?

There seem to be an awful lot of language mechanisms in current LISP
dialects, e.g. multiple-value returns as distinct from lists of values,
which is a distinction that has no analogue in other languages. Add in all
that, and the resulting language cannot be described as “simpleâ€.
 
L

Lawrence D'Oliveiro

Generics are not particular useful in dynamic typed
languages.

But since Java is static typed, then not so relevant
for Java.

Java starts out with static typing, then devotes an awful lot of effort to
wiggling its way out of that. Look at “unchecked conversionsâ€, for example.

Wouldn’t it be simpler not to pretend in the first place?
 
L

Lawrence D'Oliveiro

And Lew is correct: templates and genercis are completely different
beasts.

“Completely†as in “having nothing in common� Or is this some usage of
“completely†that I wasn’t aware of?

Please explain.
 
J

Joshua Cranmer

“Completely†as in “having nothing in common� Or is this some usage of
“completely†that I wasn’t aware of?

Please explain.

Templates in C++ are basically advanced macros--each invocation of a
template type regenerates the class, so a Foo<int> and a Foo<double> are
two completely different things.

Generics in Java are basically compile-time syntactic sugar to ensure
type-safety of container types at compile time instead of waiting until
you hit the code at runtime to get that dreaded ClassCastException.

About the only thing they share in common is the syntax, and even then,
C++ didn't allow A<B<C>> until C++0x (which, according to Bjarne
Stroustroup, took a bit of work to convince compiler vendors to accept).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top