Java vs C++

Discussion in 'Java' started by Lawrence D'Oliveiro, Feb 5, 2011.

  1. 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...
    Lawrence D'Oliveiro, Feb 5, 2011
    #1
    1. Advertising

  2. Lawrence D'Oliveiro

    Pitch Guest

    In article <iijbfr$pb2$>, _zealand
    says...

    > Most of that complexity seems to be caused by the addition of generics to
    > Java.


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



    --
    score: 40.59041%
    Pitch, Feb 5, 2011
    #2
    1. Advertising

  3. In message <-com.hr>, Pitch wrote:

    > 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.
    Lawrence D'Oliveiro, Feb 5, 2011
    #3
  4. Lawrence D'Oliveiro

    Silvio Guest

    On 02/05/2011 12:15 PM, Lawrence D'Oliveiro wrote:
    > 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.
    Silvio, Feb 5, 2011
    #4
  5. Lawrence D'Oliveiro

    Lew Guest

    Lawrence D'Oliveiro wrote:
    > 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|
    |_____|_____|
    |===========|
    Lew, Feb 5, 2011
    #5
  6. Lawrence D'Oliveiro

    Lew Guest

    Lawrence D'Oliveiro wrote:
    >> 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...


    Silvio wrote:
    > 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|
    |_____|_____|
    |===========|
    Lew, Feb 5, 2011
    #6
  7. On 05-02-2011 06:15, Lawrence D'Oliveiro wrote:
    > 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
    Arne Vajhøj, Feb 5, 2011
    #7
  8. On 05-02-2011 07:24, Lawrence D'Oliveiro wrote:
    > In message<-com.hr>, Pitch wrote:
    >> 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.


    Generics are not particular useful in dynamic typed
    languages.

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

    Arne
    Arne Vajhøj, Feb 5, 2011
    #8
  9. On 05-02-2011 09:02, Silvio wrote:
    > On 02/05/2011 12:15 PM, Lawrence D'Oliveiro wrote:
    >> 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.


    Not from the very beginning.

    But it was added to cfront pretty early.

    Arne
    Arne Vajhøj, Feb 5, 2011
    #9
  10. On 2011-02-05 06:15:07 -0500, Lawrence D'Oliveiro said:

    > 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.
    Owen Jacobson, Feb 5, 2011
    #10
  11. On 02/05/2011 06:15 AM, Lawrence D'Oliveiro wrote:
    > 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++.

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
    Joshua Cranmer, Feb 5, 2011
    #11
  12. Lawrence D'Oliveiro

    Silvio Guest

    On 02/05/2011 03:38 PM, Arne Vajhøj wrote:
    > On 05-02-2011 09:02, Silvio wrote:
    >> On 02/05/2011 12:15 PM, Lawrence D'Oliveiro wrote:
    >>> 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.

    >
    > 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.
    Silvio, Feb 5, 2011
    #12
  13. Lawrence D'Oliveiro

    Silvio Guest

    On 02/05/2011 03:26 PM, Lew wrote:
    > Lawrence D'Oliveiro wrote:
    >>> 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...

    >
    > Silvio wrote:
    >> 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.
    >


    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
    Silvio, Feb 5, 2011
    #13
  14. Lawrence D'Oliveiro

    Pitch Guest

    In article <iijfh1$rk1$>, _zealand
    says...
    >
    > In message <-com.hr>, Pitch wrote:
    >
    > > 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.


    That's like comparing Bon Jovi with Slayer. :)


    --
    score: 40.59041%
    Pitch, Feb 5, 2011
    #14
  15. On 05-02-2011 12:04, Silvio wrote:
    > On 02/05/2011 03:38 PM, Arne Vajhøj wrote:
    >> On 05-02-2011 09:02, Silvio wrote:
    >>> On 02/05/2011 12:15 PM, Lawrence D'Oliveiro wrote:
    >>>> 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.

    >>
    >> Not from the very beginning.
    >>
    >> But it was added to cfront pretty early.

    >
    > 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
    Arne Vajhøj, Feb 5, 2011
    #15
  16. Lawrence D'Oliveiro

    Silvio Guest

    On 02/05/2011 08:42 PM, Arne Vajhøj wrote:
    > On 05-02-2011 12:04, Silvio wrote:
    >> On 02/05/2011 03:38 PM, Arne Vajhøj wrote:
    >>> On 05-02-2011 09:02, Silvio wrote:
    >>>> On 02/05/2011 12:15 PM, Lawrence D'Oliveiro wrote:
    >>>>> 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.
    >>>
    >>> Not from the very beginning.
    >>>
    >>> But it was added to cfront pretty early.

    >>
    >> 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.
    >



    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.

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

    >
    > Yep.
    >
    > Arne
    >
    Silvio, Feb 5, 2011
    #16
  17. In message <2011020510425674637-angrybaldguy@gmailcom>, Owen Jacobson wrote:

    > 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â€.
    Lawrence D'Oliveiro, Feb 6, 2011
    #17
  18. In message <4d4d6002$0$23763$>, Arne Vajhøj wrote:

    > On 05-02-2011 07:24, Lawrence D'Oliveiro wrote:
    >
    >> In message<-com.hr>, Pitch wrote:
    >>
    >>> 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.

    >
    > 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?
    Lawrence D'Oliveiro, Feb 6, 2011
    #18
  19. In message <4d4d8322$0$41117$4all.nl>, Silvio wrote:

    > 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.
    Lawrence D'Oliveiro, Feb 6, 2011
    #19
  20. On 02/05/2011 10:38 PM, Lawrence D'Oliveiro wrote:
    > In message<4d4d8322$0$41117$4all.nl>, Silvio wrote:
    >
    >> 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.


    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).

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
    Joshua Cranmer, Feb 6, 2011
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Novice
    Replies:
    1
    Views:
    1,132
    Mike Schilling
    Jul 19, 2003
  2. Michael Kintner
    Replies:
    0
    Views:
    840
    Michael Kintner
    Nov 30, 2003
  3. Ilias Lazaridis
    Replies:
    0
    Views:
    565
    Ilias Lazaridis
    Feb 1, 2005
  4. manish sahu
    Replies:
    3
    Views:
    993
  5. Isaac
    Replies:
    0
    Views:
    359
    Isaac
    Jan 20, 2011
Loading...

Share This Page