Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #26189
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java vs C++ |
| Date | 2011-02-08 07:53 -0500 |
| Organization | albasani.net |
| Message-ID | <iirebq$9k4$1@news.albasani.net> (permalink) |
| References | (13 earlier) <4d4f61fb$0$23756$14726298@news.sunsite.dk> <iio27n$g2f$2@lust.ihug.co.nz> <4d507f8a$0$32793$c30e37c6@exi-reader.telstra.net> <iiqcjh$qt4$5@lust.ihug.co.nz> <slrnil26hf.nej.avl@gamma.logic.tuwien.ac.at> |
Andreas Leitgeb wrote: > The "problem" about type-erasure is over-rated. > > Suppose, an instance created so: Object o = new ArrayList<String>(); > actually "knew" that it was an ArrayList of Strings (and not just > that it was an ArrayList, as it does now). > Then you would get a *runtime*-Error, if you tried to cast "o" to > ArrayList<Integer>, later. But generics aren't about runtime errors. > They are about being able to prevent some runtime-errors, by turning > them into compile-time errors. So, giving *still runtime*-errors for > casting between generic types of incompatible parametrizations is only > little win over giving runtime-errors on element-use. I'm very glad you made that point. I am glad we have type erasure in Java. It forces you to deal with type assertions at compile time. The problem with reifiable types is that it's too easy to do a half-assed job of your type analysis, thus resulting in the runtime errors to which Andreas alludes. Besides, all you need to do to get runtime typing is to include a runtime type token as a final member of your class and Bob's your uncle. Like so much else in Java, that just means you have to *think* and act for yourself, and type a few extra lines of code. Don't sprain your finger with that extra typing, whiners! -- Lew Ceci n'est pas une fenêtre. .___________. |###] | [###| |##/ | *\##| |#/ * | \#| |#----|----#| || | * || |o * | o| |_____|_____| |===========|
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
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++ Lew <noone@lewscanon.com> - 2011-02-08 07:53 -0500
Re: Java vs C++ Esmond Pitt <esmond.pitt@bigpond.com> - 2011-02-08 10:26 +1100
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-08 16:17 +1300
Re: Java vs C++ Esmond Pitt <esmond.pitt@bigpond.com> - 2011-02-08 16:51 +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
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 22:07 -0500
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 19:07 +1300
csiph-web