Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #25484
| From | Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java vs C++ |
| Followup-To | comp.lang.java.programmer |
| Date | 2011-02-07 15:08 +1300 |
| Organization | Geek Central |
| Message-ID | <iink6l$87t$1@lust.ihug.co.nz> (permalink) |
| References | (5 earlier) <iil5ed$10m$1@news.eternal-september.org> <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> |
Followups directed to: comp.lang.java.programmer
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. 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. 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. The only thing holding it back is not deliberate design choices over functionality, but the dead hand of backward compatibility.
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar
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