Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #25497

Re: Java vs C++

Date 2011-02-06 21:19 -0500
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: Java vs C++
References (6 earlier) <iil74u$rac$1@lust.ihug.co.nz> <iil9uk$b6m$1@news.eternal-september.org> <iinara$2up$4@lust.ihug.co.nz> <4d4f43d9$0$23755$14726298@news.sunsite.dk> <iink6l$87t$1@lust.ihug.co.nz>
Message-ID <4d4f56ac$0$23758$14726298@news.sunsite.dk> (permalink)
Organization SunSITE.dk - Supporting Open source

Show all headers | View raw


On 06-02-2011 21:08, Lawrence D'Oliveiro wrote:
> In message<4d4f43d9$0$23755$14726298@news.sunsite.dk>, Arne Vajhøj wrote:
>> On 06-02-2011 18:28, Lawrence D'Oliveiro wrote:
>>> In message<iil9uk$b6m$1@news.eternal-september.org>, Joshua Cranmer
>>> wrote:
>>>> Try, for example, implementing both List<String>   and List<Character>
>>>> in the same class. Java will tell you that you cannot do it. C++, on the
>>>> other hand, wouldn't bat an eye.
>>>
>>> Why does Java impose such a pointless restriction?
>>
>> It is given by the use of type erasure.
>
> Which is purely a backward-compatibility mechanism.

Which does not change the fact - it just explains it.

>                                                    If I were to take two
> copies of the definition of List<E>, and in one take out<E>  and replace E
> with String, and in the other replace it with Character, Java would have no
> problem letting me declare a class that implements both interfaces. But try
> doing it directly with the generic, and it won’t.
>
> Java draws a distinction between the two cases where there really shouldn’t
> be any distinction. That’s what generics are for, after all—they’re there to
> save work for the programmer, not create it.

Backward compatibility limit the available option.

> See, Java started out as not wanting to be like C++: it would take the good
> stuff from C++, and leave the rest behind.
>
> But now, with the addition of generics, it’s clear Java wants to be more
> like C++ after all.

Not really.

As explained numerous times then Java generics and C++ templates
are somewhat different.

Arne

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 15:08 +1300
  Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 21:19 -0500
    Re: Java vs C++ Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-02-09 01:07 +0800
    Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-07 19:44 -0500
    Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 15:53 +1300
      Re: Java vs C++ Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-02-08 10:25 +0000
      Re: Java vs C++ Esmond Pitt <esmond.pitt@bigpond.com> - 2011-02-08 10:26 +1100
      Re: Java vs C++ Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-06 22:06 -0500
      Re: Java vs C++ "Mike Schilling" <mscottschilling@hotmail.com> - 2011-02-06 22:42 -0800
      Re: Java vs C++ Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-07 21:20 -0500

csiph-web