Reified generics, advanced null handling, async/await, stack allocated arrays, tuple syntax, partial types, auto implemented getters and setters, dynamic types, extension methods, nullable value types, exception filters and many more...but sure, we'll give you this one as a first ;)
Type erased generics allowed Java (the JVM) to have better multi-language support (Clojure, Kotlin, Scala, and many more.). Scala wasn't able to get ported to the CLR because of reified generics. In either case, Java is getting a form of generics specialization for primitive types.
It also doesn't need async/await because it's getting green threads. I believe it has exception filters, just a different syntax than C#.
Let's not forget a best-in-class JIT and best-in-class GCs also.
It's a good start don't get me wrong, but it's running on an outdated CPU. I ran some benchmarks myself where golang was quicker than Java in the benchmarks page, and I got the opposite result.
I ran the spectral norm benchmark (input size 30000) with the following result:
golang:
1.274224153
18.81 real 70.19 user 0.38 sys
Java (I think it was even version 3, which ran faster for me than version 2 which currently tops the benchmarks list for Java):
1.274224153
16.18 real 105.95 user 0.45 sys
and nbody benchmark with input size 60000000:
golang:
-0.169075164
-0.169012474
6.09 real 6.04 user 0.02 sys
Java:
-0.169075164
-0.169012474
6.04 real 5.94 user 0.06 sys
I recall seeing a pull request submitted by someone for Java that uses Math.fma which should have speeded up that benchmark (don't recall which one it is, but it's available in the project's list of issues), but because the CPU used to run the benchmarks didn't support it, it actually caused a degraded performance.
The second issue with just relying on microbenchmarks to judge a platform is that they only test out specific parts of said platform, and do not highlight what it's capable of overall. For example, large Java programs do run faster than golang programs because of what the JIT is able to do (inlining, de-virtualization, certain cases of auto-vectorization, etc.), but microbenchmarks don't run long enough to be able to demonstrate this. Other long running Java programs work in high throughput rates (which the golang GC is bad at), again would be difficult to show in microbenchmarks.
Tangential, but there was a recent article about converting C to Rust, and the C version included some manual uses of vectorization and a hand-optimized inverse sqrt function, which the new Rust version elided. The Rust version was faster by a LOT because it used a native inverse sqrt not present in the CPU used in the benchmark game.
afaict there were a whole bunch of changes between nbody-5.bench and nbody-6.bench not just sqrt.
If you're talking about this:
At face value, this should make the program twice as fast, because AVX instructions can chew on four f64s at a time instead of SSE's two. But, on my Skylake-based machine at least, the AVX version becomes slower.
:then afaict the faster program is the "outdated CPU" program that uses SSE ?
9
u/falconfetus8 Jan 17 '20
Your move, C#.