Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #25530 > unrolled thread
| Started by | Silvio <silvio@moc.com> |
|---|---|
| First post | 2011-02-05 18:04 +0100 |
| Last post | 2011-02-06 20:51 -0500 |
| Articles | 4 on this page of 44 — 10 participants |
Back to article view | Back to comp.lang.java.programmer
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Java vs C++ Silvio <silvio@moc.com> - 2011-02-05 18:04 +0100
Re: Java vs C++ Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-02-07 16:21 +0800
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 12:28 +1300
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-08 09:22 +1300
Re: Java vs C++ Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-07 17:25 -0500
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-08 16:08 +1300
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 12:24 +1300
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 15:03 +1300
Re: Java vs C++ Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-06 21:18 -0500
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 21:26 -0500
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 20:15 -0500
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 15:55 +1300
Re: Java vs C++ "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2011-02-06 19:54 -0500
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 20:50 -0500
Re: Java vs C++ Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-02-07 15:54 +0800
Re: Java vs C++ Thomas Richter <thor@math.tu-berlin.de> - 2011-02-07 01:04 +0100
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 20:26 -0500
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 19:09 +1300
Re: Java vs C++ Lew <noone@lewscanon.com> - 2011-02-07 07:29 -0500
Re: Java vs C++ "Mike Schilling" <mscottschilling@hotmail.com> - 2011-02-06 22:52 -0800
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 13:32 +1300
Re: Java vs C++ Thomas Richter <thor@math.tu-berlin.de> - 2011-02-06 16:35 +0100
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 15:51 +1300
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 22:06 -0500
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 15:01 +1300
Re: Java vs C++ Thomas Richter <thor@math.tu-berlin.de> - 2011-02-07 14:53 +0100
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-07 19:52 -0500
Re: Java vs C++ Lew <noone@lewscanon.com> - 2011-02-06 13:09 -0500
Re: Java vs C++ Thomas Richter <thor@math.tu-berlin.de> - 2011-02-07 00:55 +0100
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 15:00 +1300
Re: Java vs C++ Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-06 21:20 -0500
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 15:52 +1300
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 21:25 -0500
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 20:29 -0500
Re: Java vs C++ Thomas Richter <thor@math.tu-berlin.de> - 2011-02-07 00:57 +0100
Re: Java vs C++ Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-06 12:57 -0500
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 15:22 -0500
Re: Java vs C++ "Mike Schilling" <mscottschilling@hotmail.com> - 2011-02-06 08:11 -0800
Re: Java vs C++ Ken Wesson <kwesson@gmail.com> - 2011-02-07 04:41 +0100
Re: Java vs C++ Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-06 21:12 -0500
Re: Java vs C++ Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-02-07 12:26 +1300
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 15:27 -0500
Re: Java vs C++ Thomas Richter <thor@math.tu-berlin.de> - 2011-02-06 16:45 +0100
Re: Java vs C++ Arne Vajhøj <arne@vajhoej.dk> - 2011-02-06 20:51 -0500
Page 3 of 3 — ← Prev page 1 2 [3]
| From | Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> |
|---|---|
| Date | 2011-02-07 12:26 +1300 |
| Message-ID | <iinanc$2up$3@lust.ihug.co.nz> |
| In reply to | #25530 |
In message <iil9uk$b6m$1@news.eternal-september.org>, Joshua Cranmer wrote:
> On 02/05/2011 11:13 PM, Lawrence D'Oliveiro wrote:
>
>> They are different things in Java as well.
>
> The hell they aren't. In Java, there is only one instance of
> LinkedList::add(T object). In C++, there are as many instances of
> std::list<T>::front as times you use it.
>
> 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.
>
>> The only time they become the same thing is in “erasures” and “raw
>> types”, which are backward-compatibility mechanisms introduced to avoid
>> breaking existing code that doesn’t know about generics.
>
> I think Java would likely have gone with much the same syntax even if
> generics had been introduced in the beginning.
>
>> And then, of course, the language goes on to use exactly that deprecated
>> syntax as the recommended way of accessing static members.
>
> It's not the same syntax. List<String> is the type of a specific
> instance, while the class still remains List.
List<String> is a class, not an instance. In something like
List<String> L;
it is L that is the instance.
See, how can you try to tell me what the difference is between Java and C++,
when you don’t understand it yourself?
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2011-02-06 15:27 -0500 |
| Message-ID | <4d4f042b$0$23753$14726298@news.sunsite.dk> |
| In reply to | #25530 |
On 05-02-2011 23:13, Lawrence D'Oliveiro wrote: > In message<iil5ed$10m$1@news.eternal-september.org>, Joshua Cranmer wrote: >> On 02/05/2011 10:38 PM, Lawrence D'Oliveiro wrote: >>> In message<4d4d8322$0$41117$e4fe514c@news.xs4all.nl>, Silvio wrote: >>>> ... templates and gener[ic]s are completely different beasts. >>> >>> “Completely” as in “having nothing in common”? Or is this some usage of >>> “completely” that I wasn’t aware of? >>> >>> Please explain. >> >> Templates in C++ are basically advanced macros--each invocation of a >> template type regenerates the class, so a Foo<int> and a Foo<double> are >> two completely different things. > > They are different things in Java as well. No. Same code. > The only time they become the > same thing is in “erasures” and “raw types”, Since Java generics are always type erasured, then "the only time" is actually "every time". But .NET does not due type erasure and still only have one copy of the code for generics. >> Generics in Java are basically compile-time syntactic sugar to ensure >> type-safety of container types at compile time instead of waiting until >> you hit the code at runtime to get that dreaded ClassCastException. > > Same sort of thing in C++. > >> About the only thing they share in common is the syntax ... > > Yeah, funny that. If Java didn’t want to be seen as copying C++, why did it > reuse exactly the same syntax? Because beginners that just used the generic containers would not see the big difference. And those needing to do more advanced stuff where the difference becomes visible is expected to read about generics. Arne
[toc] | [prev] | [next] | [standalone]
| From | Thomas Richter <thor@math.tu-berlin.de> |
|---|---|
| Date | 2011-02-06 16:45 +0100 |
| Message-ID | <iimfm4$t5f$1@news.belwue.de> |
| In reply to | #25530 |
Joshua Cranmer wrote: > On 02/05/2011 11:13 PM, Lawrence D'Oliveiro wrote: >> They are different things in Java as well. > > The hell they aren't. In Java, there is only one instance of > LinkedList::add(T object). In C++, there are as many instances of > std::list<T>::front as times you use it. I would say that's an implementation detail. A compiler/optimizer could check how many different implementations are needed and could merge those that are identical. Besides that, where you use an object in java, one would use a pointer or a reference in C++, and hence the code would be identical, allowing a good compiler to merge the implementations. C++ and java are quite different in their tradition how to use types, or what types are. Java has two sorts of types: First class citizens like int or double that are copied, and second class citizens like classes that are referenced. C++ doesn't have that, objects are objects and ints and classes are handled alike. > 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. True. >> The only time they become the >> same thing is in “erasures” and “raw types”, which are backward- >> compatibility mechanisms introduced to avoid breaking existing code that >> doesn’t know about generics. > > I think Java would likely have gone with much the same syntax even if > generics had been introduced in the beginning. That's really a speculation. One could also speculate that if java would have used or required generics from the beginning, they would be closer to C++ templates and would not use type erasure; instead, they would be parametrized classes as they are in C++. It's really speculation. Greetings, Thomas
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2011-02-06 20:51 -0500 |
| Message-ID | <4d4f500b$0$23755$14726298@news.sunsite.dk> |
| In reply to | #25530 |
On 06-02-2011 00:01, Joshua Cranmer wrote: > On 02/05/2011 11:13 PM, Lawrence D'Oliveiro wrote: >> The only time they become the >> same thing is in “erasures” and “raw types”, which are backward- >> compatibility mechanisms introduced to avoid breaking existing code that >> doesn’t know about generics. > > I think Java would likely have gone with much the same syntax even if > generics had been introduced in the beginning. I think so too. But I believe that type erasure would have been dropped in that case. Arne
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | comp.lang.java.programmer
csiph-web