logoalt Hacker News

branko_dlast Monday at 12:36 AM3 repliesview on HN

And as a consequence, C# can pack the value types directly in the generic data structure, instead of holding references to heap-allocated objects.

This is very important both for cache locality and for minimizing garbage collector pressure.


Replies

SPBSlast Monday at 11:40 AM

> And as a consequence, C# can pack the value types directly in the generic data structure, instead of holding references to heap-allocated objects.

> This is very important both for cache locality and for minimizing garbage collector pressure.

How is C# just not straight-up faster than Java then? Instead of both language punching around the same weight on benchmarks? Doesn't cache locality like, have a huge effect on performance?

show 2 replies
kgeistlast Monday at 4:09 AM

With reified generics, you can also do "new T[]" because the type is known at runtime. With type erasure, you can't do that.

svieiralast Monday at 12:41 AM

And Java has been working on Project Valhalla for ~20 years to retrofit the ability to do this to the existing Java language...

show 2 replies