Hejlsberg Talk About Generics in C# and Java 128
An anonymous reader writes "artima.com has a very interesting interview with Anders Hejlsberg - the Borland guy now at Microsoft who can best be defined as MR C# - doing all the stuff that Borland wouldn't let him do. He discusses generics in C#, Java (1.5) and C++. Naturally there is the chance of bias but he does raise some interesting points againt Java's generics. Specifically that Java's genericised collections will have to box all primitive types as full objects, whereas C# does not. This is a big performance plus for C#. Java created the primitive types in the first place to address performance concerns but appears to be stepping sideways here. I can't help wondering if Sun has taken this approach to get the syntatic sugar in the language without requiring a bytecode change, but perhaps in a future VM version will allow primitive generics (obvioulsy forcing a bytecode regeneration)?"
Boxing in Java (Score:3, Interesting)
Why Generics? (Score:3, Interesting)
Re:Boxing in Java (Score:2, Interesting)
So for instance if you have a List, you can not place an Integer with out unboxing it. Vice-versa, if you have a List you can not place an int into with out boxing it.
However if you have a List you can place an int into it directly without boxing it.
Re:Boxing in Java (Score:4, Interesting)
I got the impression that C# could actually use generics to instantiate the array at type int, rather than type Integer with autoboxing.
It does seem any "performance" argument is bogus (Score:2, Interesting)
Though really, I want to know why these languages have to be written so "primitives" are special at all. I would really like to be able to subclass an int or other built-in, and having "methods" on an int would be nice (even if you can't define new ones). The main reason is so you don't have to rewrite if you change your mind about whether type A is a primitive or something you define. Can't the byte compiler do a bit of work so any fast-path for the primitive can be used, without building in such restrictions to the syntax?
Oh, the irony! (Score:3, Interesting)
where it makes sense, but we are also very
conscious about not sharing where you want
the performance.
Welcome to the Microsoft business model. :)
Re:It does seem any "performance" argument is bogu (Score:3, Interesting)
I disagree here.
Think of Moore's law, processor speeds, etc... Java is a fast enough language for doing just about anything a user needs to do. Even if java were only 25% as fast as native code, that would be 2 cycles of Moore's law, 36 months, 3 years ago. (And, java is much faster than 25% of C, check here [bagley.org])
3 years ago, users were all doing the same things they are doing today.
A couple of exceptions apply, of course: scientific computing, games, etc, tax the hardware pretty heavily.
But, the primary reason that Java is perceived as slow by users is the terrible speed of the GUI.
All the widgets are implemented in Java directly. This is almost like the same exception as game software, since all this rendering code involves moving around lots of memory, etc...
The GUI matters more than anything to user perception of slowness.
An old 14mhz 68000 amiga often "felt" faster than a 50mhz 386, because the amiga's os/gui were very responsive, while the 386 was running win3.1
Look at the recent developments with the linux kernel. Compare X responsiveness with a preemptible low-latency kernel, and how the whole machine "feels" better.
By going with preemption and low-latency, the overall throughput of the machine is actually slightly slower. But it feels loads better.
C# and the
Re:It does seem any "performance" argument is bogu (Score:1, Interesting)
But you're right about the GUI...that's the single biggest fuck up that Sun made. IBM has done better as SWT comes pretty close to being fully responsive (though it still makes it possible to be unresponsive if you write bad code.)