Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> benchmarkgame benchmarks

Lol look at the code. N-body for example, the C# is horrific C-in-C# code with a million optimizations (just read the comments lol), the Java code is idiomatic and not optimized at all.



Well the fastest C# entry for n-body looks like a translation of the C/C++ versions. It is a meaningful result that the primitives of the language allow for it to hang in that company. The absence of a Java version using numerics is unfortunate, that'd be a nice addition.

A lot of the coding style seems optimized around copy-pasting the C code, e.g. trying to alias the Vector methods (Vector256.Create) to their instruction name (_mm256_set1_pd). That makes the code non-idiomatic, but it also doesn't really help performance, just makes the porting easier.

The F# example is on the same runtime and a better view of using the numerics directly. As a trade-off of performance, memory, and code complexity it is actually a pretty solid balance, which I wouldn't have expected.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...


How is it meaningful?

I can inline C code in Ruby, does that mean Ruby is as fast as C now?

I'd much rather see a comparison of idiomatic code in different languages. When I choose a language to build something in I'm not thinking "How can I write C in this language?"...


Inline C/ASM is literally a different language. System.Runtime.Intrinsics is a library. Just because this one benchmark used the library in a C-like style doesn't mean that's required.

There are many simpler implementations in all languages. I actually like that there are multiple implementations, as this lets us estimate the benefit and complexity of adopting various optimizations. Limiting the benchmark to naive implementations would penalize languages with more broad capabilities for optimization.

I'd personally prefer a benchmark limited to memory-safe implementations, though.


Please show the objective rules that could be used to identify "idiomatic code in different languages".



And they're slower than Java... Albeit super close. The parent I responded to was referencing how C# is supposedly faster than Java... But idiomatic C# is about the same (slightly slower).


Isn't that writing Java in C#?

Why should C# programs be limited to what can be done in Java?


You can do the same thing in Java, but apparently no one wrote it yet because it's just a silly micro-benchmark. Either way I'd rather see idiomatic code. Or just write C/C++ directly.


> I'd rather see idiomatic code

As you know simpler C# programs are shown.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: