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


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

Re: Java vs C++

Path csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!aioe.org!news.mixmin.net!news.albasani.net!not-for-mail
From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.programmer
Subject Re: Java vs C++
Date Tue, 08 Feb 2011 07:53:33 -0500
Organization albasani.net
Lines 36
Message-ID <iirebq$9k4$1@news.albasani.net> (permalink)
References <iijbfr$pb2$1@lust.ihug.co.nz> <4d4d585c$0$81476$e4fe514c@news.xs4all.nl> <4d4d60dc$0$23763$14726298@news.sunsite.dk> <4d4d8322$0$41117$e4fe514c@news.xs4all.nl> <iil53i$q34$1@lust.ihug.co.nz> <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> <iink6l$87t$1@lust.ihug.co.nz> <4d4f56ac$0$23758$14726298@news.sunsite.dk> <iinmra$9er$7@lust.ihug.co.nz> <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>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.albasani.net OAWFzr3ZHUVTJb1DgEnx7LmxLByqrNLMXGYVT8hzsh7e16BEtzTPyJZWs2vaO4dJ8kd6hP3DGUcUxbv+3MjHkw==
NNTP-Posting-Date Tue, 8 Feb 2011 12:53:15 +0000 (UTC)
In-Reply-To <slrnil26hf.nej.avl@gamma.logic.tuwien.ac.at>
Cancel-Lock sha1:Y2u+HOL6KiKYuEpZ7A4fk8lMAt4=
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7
Injection-Info news.albasani.net; logging-data="UXTyCziDEMWncfQndY+oXOoChDkBOd0w1EjX3D5AH+x9E1Fki1eVJaDw8EgARGl0Btp69Cv29DZeB7vliuvBn9fnh9wBEZfOLu30SqVn414XuYHyZfc38zTQ/t0YEag3"; mail-complaints-to="abuse@albasani.net"
Xref csiph.com comp.lang.java.programmer:26189

Show key headers only | View raw


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