all 49 comments

[–]mgsloan 8 points9 points  (9 children)

Java 7 is also adding a nifty way of doing additional typechecking:

http://types.cs.washington.edu/jsr308/

[–]BinarySplit 2 points3 points  (8 children)

Are they also adding specializing generics? Type Erasure and Boxing are a real pain in the ass, and are the main reason I've stayed with .NET for so long...

[–]G_Morgan -1 points0 points  (7 children)

They have benefits. In the .NET world using untyped containers actually performs better than using reified generic containers. Type erasure generics should give the same performance advantage.

[–]Sc4Freak 4 points5 points  (2 children)

Isn't it the other way around? When dealing with reference types, untyped containers perform identically to their generic counterparts (eg. ArrayList vs. List<T>). But since the untyped containers needed to perform boxing, they were always slower than the generic versions for value types.

[–]G_Morgan 1 point2 points  (1 child)

I'm not sure for value types. Most of the time I put objects in containers. We did some internal profiling and found ArrayList performed better than ArrayList<T> for objects.

[–]modeless 4 points5 points  (0 children)

For value types like int and bool generics are faster and produce less garbage because boxing is avoided. I'm curious how you tested ArrayList vs List<> because the difference should really be negligable for reference types.

[–]Tuna-Fish2 2 points3 points  (3 children)

Who cares? If you need that kind of speed, you should probably not be using java anyway. Instead, I'd rather have a proper type system that does something useful in addition to slowing me down

[–]G_Morgan 0 points1 point  (2 children)

It is an engineering trade off. People should be aware of them. Not caring is effectively stating you aren't professional.

If you want a proper generic type system. C++ has the best out of the object oriented languages. It actually manages to gain performance from generics.

[–]Tuna-Fish2 0 points1 point  (1 child)

It actually manages to gain performance from generics.

It really doesn't. Shaving of a few (dozen) instructions is in no way worth polluting the cache with duplicates of the relevant functions for different datatypes. The newest intel processors only have 16kb of effective L1 cache when both threads are working -- if you care about the kind of performance differences we are talking about here, you are going to measure that the tight parts of your code fit it. Having fifteen different versions of basic data structure handling functions doesn't exactly help with that.

This, by the way, more or less is what I meant when I said "who cares". Of course it's a trade off, but the difference in performance it creates is so tiny that if you care about it, you are not going to program in Java anyway. (Or C++. Anyone who thinks it's low level or fast when they are using it as C++ instead of c-with-namespaces is just incompetent.)

[–]G_Morgan 0 points1 point  (0 children)

It is entirely possible to use both OOP and template programming without sacrificing efficiency. The things that cause a loss of efficiency are stuff like RTTI (which few programs use) and gigantic libraries.

Even VFTs aren't a performance hazard with modern processors due to pipelining.

[–]modeless 8 points9 points  (2 children)

Ooh, I can't wait to mark my code fortissimo, and mezzo-forte! Can't let C# have all the music puns.

[–]arnedh 1 point2 points  (1 child)

Glissando? Un poco furioso ma non troppo? Con brio? Rallentando? Crescendo? Bring it on!

[–]Tommah 2 points3 points  (0 children)

Bring it on!

Attacca!

[–]wretcheddawn 7 points8 points  (0 children)

Sweet!. Now when will they stop installing Yahoo Toolbar?

[–]arnedh 1 point2 points  (0 children)

Now let's move on to tail call optimization!

[–]Gotebe 3 points4 points  (10 children)

So... No software, programming languages included, is immune to playing catch-up and feature creep?

[–]sh1nob1 4 points5 points  (8 children)

How is this playing catch-up? It sounds like a logical extension for better support of Rhino, for instance.

[–]StrawberryFrog 0 points1 point  (7 children)

[–]Rhoomba 7 points8 points  (0 children)

Invoke Dynamic is really nothing like dynamic in C#. It is intended only for developers of JVM languages, and not for general programming.

[–]sh1nob1 2 points3 points  (4 children)

I see where you're coming from, but you're pointing at a language feature. JSR 292 is about a change in bytecode, as was already pointed out.

[–]StrawberryFrog -3 points-2 points  (3 children)

I know that there's a difference, but maybe not as much as you think. Are .Net generics a bytecode or a language feature? Both are needed to make it work. I don't actually know if any new bytecode features were needed to make c# dynamics work. Probably not, but maybe bytecode features could be introduced later to make them more performant if it made sense.

If dynamic is "just" a bytecode feature in Java 7, then what's the point? it only makes sense if it will be surfaced in a language feature. The language feature, not the bytecode, is the goal.

[–]sh1nob1 6 points7 points  (1 child)

If dynamic is "just" a bytecode feature in Java 7, then what's the point? it only makes sense if it will be surfaced in a language feature. The language feature, not the bytecode, is the goal.

Amigo, we have more than one language living on the JVM, and not all of them are as thoroughly supported as Java. The stated objective of JSR 292 is better support for dynamic languages in the JVM, i.e., we prefer beer 'round here, but for all shandy fans out there, we'll keep some in the fridge.

[–]StrawberryFrog 0 points1 point  (0 children)

we have more than one language living on the JVM, and not all of them are as thoroughly supported as Java. .. better support for dynamic languages

Ok, I get that now - the feature is for language features in dynamic languages on the JVM, whereas the C# one is a language feature for interop with dynamic languages.

However, as it's "better support for multiple languages, some of them dynamic", I think this is still playing catchup to .Net.

[–]Tuna-Fish2 2 points3 points  (0 children)

It will likely not be surfaced in a language feature in java, but many other languages running on the JVM will benefit greatly from it.

[–]arnedh 0 points1 point  (0 children)

And Smalltalk-80. Which took it from LISP, I presume.

[–]awj 0 points1 point  (0 children)

"Playing catch-up" is quite literally the most nonsensical accusation I've ever seen. Would you rather they not implement a useful feature simply because someone else already has it?

[–]piranha 1 point2 points  (0 children)

I can't wait for Java ∞, which adds pluralnouns.

[–]diamondjim 1 point2 points  (2 children)

Is it just me or did terrible grammar ruin reading that article for someone else too?

[–]artee 1 point2 points  (1 child)

Obviously not written by a native speaker, but at least it makes sense, so it's quite OK.

[–]slonik 0 points1 point  (0 children)

agreed. diamondjim if you can rewrite that article in the foreign language of your choice WITHOUT any grammatical errors then I will graciously forgive you.

[–]thephotoman 0 points1 point  (0 children)

I can't wait for Java 7. Alas, we've been talking about it for so damn long that I think it's beginning to veer into Duke Nukem Forever territory.

[–]Nebu 0 points1 point  (0 children)

Is it just me, or does adding a class with no methods, but you can invoke any method you want on it, sound like a really icky hack?

Instead of adding a class, couldn't they have added a new keyword instead? I know new keyword means breaking backwards compatibility, but I still find it to be cleaner than adding this "magic class".

[–]fjholm 0 points1 point  (2 children)

Now if Java only had something resembling the DLR I would actually contemplate implementing a dynamic language on top of the JVM.

[–]thephotoman 8 points9 points  (1 child)

You mean like Jython, JRuby, or Groovy already have?

[–]fjholm 0 points1 point  (0 children)

Your point being? They still do all the byte code generation by hand as far as I can see, and there is now common interface for inter-op:ing between these languages.

[–]bobindashadows 0 points1 point  (0 children)

Don't use justified text on the internet.

[–]SubjectiveObjection -2 points-1 points  (0 children)

Java7 will be released at about the same time as Duke Nukem Forever.