This post originated from an RSS feed registered with Java Buzz
by dion.
Original Post: Value types in Java: Striving for the stack
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
I have recently had some .NETers claiming that they do now know how we live on our side of the fence in Java-land, without value types. They laugh in our general direction as they add structs to the stack.
I do understand that value types can be useful. I do understand that it will take longer to dereference an object each time vs. not having to do that bypassing the heap entirely. There are lots of good things there.
However, I am actually quite glad that we don't have value types. Simple put: Have you missed them? I haven't! I haven't run into a performance or scalability issue that was profiled, and the result was "man if we could just put this String on a stack we would be fine". It just hasn't been a problem.
On the other side, if you flip through Effective C#, you see items dedicated to value vs. reference types. Sneaky methods like EqualsReferences vs. EqualsValues. Subtle differences. Common mistakes.
So, give me partial classes, and true delegates, but keep your value types :)