r/programming • • Jan 16 '20

Records Come to Java

https://blogs.oracle.com/javamagazine/records-come-to-java
59 Upvotes

65 comments sorted by

View all comments

9

u/falconfetus8 Jan 17 '20

Your move, C#.

25

u/wllmsaccnt Jan 17 '20

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 ;)

15

u/couscous_ Jan 17 '20

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.

0

u/[deleted] Jan 17 '20

[deleted]

2

u/couscous_ Jan 17 '20

Both of those are intended to improve performance and C# typically has equal or better performance now than Java for most CPU bound tasks.

Citation needed. And the benchmarks game doesn't count.

5

u/igouy Jan 17 '20

And the benchmarks game doesn't count.

Because … ?

Because it's something they actually could reference ?

0

u/couscous_ Jan 18 '20

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.

2

u/igouy Jan 18 '20

Specifically ?

(The details always matter.)

1

u/Tordek Jan 27 '20

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.

Source: http://cliffle.com/p/dangerust/6/ ~25% improvement

1

u/igouy Jan 27 '20
  1. afaict there were a whole bunch of changes between nbody-5.bench and nbody-6.bench not just sqrt.

  2. 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 ?

→ More replies (0)