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 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: References: <4d4d585c$0$81476$e4fe514c@news.xs4all.nl> <4d4d60dc$0$23763$14726298@news.sunsite.dk> <4d4d8322$0$41117$e4fe514c@news.xs4all.nl> <4d4f43d9$0$23755$14726298@news.sunsite.dk> <4d4f56ac$0$23758$14726298@news.sunsite.dk> <4d4f61fb$0$23756$14726298@news.sunsite.dk> <4d507f8a$0$32793$c30e37c6@exi-reader.telstra.net> 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: 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 Andreas Leitgeb wrote: > The "problem" about type-erasure is over-rated. > > Suppose, an instance created so: Object o = new ArrayList(); > 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, 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| |_____|_____| |===========|