Live data from Hacker News

Golang vs. C# (.NET 5.0) at Benchmarks Game

benchmarksgame-team.pages.debian.net

41–50 of 114 posts

Re: Golang vs. C# (.NET 5.0) at Benchmarks Game

#41
post #35

I prefer C#. But here the Go code actually looks like normal production code while the C# examples look like something made by a low-level optimization wizard.

I looked at the k-nucleotide, n-body, etc and saw nothing out of the ordinary in terms of C#.

There wasn’t even a lot of “modern C#” low level optimization like ref-structs/spans and similar. It actually looks like there is quite a bit of performance from C#8, 9, 10 left on the table.

Re: Golang vs. C# (.NET 5.0) at Benchmarks Game

#42

Earlier quoted context omitted.

> even ships with its own cloud environment (Azure) Can you elaborate on this? What does it mean that ".Net ships with Azure"?

Microsoft created .NET and Azure and a lot of the tooling so the integration is tight, now that it's multi platform and with Rider (multiplatform .NET IDE) being as good as if not better than Visual Studio there is nothing stopping it.

Alternative take, the Azure documentation is shit if you are not using dot net... but pretty good if that's your toolchain.

Re: Golang vs. C# (.NET 5.0) at Benchmarks Game

#43
post #11

I say modern .NET is a marvel of features, development tools, interoperability, performance and even ships with its own cloud environment (Azure). Unfortunately developers who don’t know better judge it by it’s historical association with Windows rather than how powerful it is today.

Can you now get the full .NET development experience in a Linux-only environment? I haven't used it in a while, but from using Unity (game engine) it seemed like C# on Linux was a bit crippled

Also relevant... can you learn it, build it and deploy it for free?

I've always thought the whole ecosystem looked really productive, and the code I've had to review occasionally looked well structured and readable. But when I was starting out MSDN cost a fortune and I've never really considered trying to learn it.

Re: Golang vs. C# (.NET 5.0) at Benchmarks Game

#45
post #35

I prefer C#. But here the Go code actually looks like normal production code while the C# examples look like something made by a low-level optimization wizard.

I looked at the k-nucleotide, n-body, etc and saw nothing out of the ordinary in terms of C#. There wasn’t even a lot of “modern C#” low level optimization like ref-structs/spans and similar. It actually looks like there is quite a bit of performance from C#8, 9, 10 left on the table.

Are we looking at the same file?[0]

Tons of very "interesting" attributes like this:

    // prevent inlining into main to decrease JIT time to generate main
    [SkipLocalsInit][MethodImpl(NoInlining)]

    [SkipLocalsInit][StructLayout(LayoutKind.Explicit, Pack = 32)]

    [SkipLocalsInit][MethodImpl(AggressiveOptimization | NoInlining)]

    [FieldOffset(32)]

and tons of "unchecked" blocks.

Not to mention that the entire file is using explicit vectorization, which I consider to be a very high degree of optimization -- tons of software never bothers to implement explicit vectorization, and does just fine.

If all of this is "nothing out of the ordinary", then "ordinary" C# has changed a lot since I last spent much time with it.

[0]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re: Golang vs. C# (.NET 5.0) at Benchmarks Game

#46
post #37

I say modern .NET is a marvel of features, development tools, interoperability, performance and even ships with its own cloud environment (Azure). Unfortunately developers who don’t know better judge it by it’s historical association with Windows rather than how powerful it is today.

> Unfortunately developers who don’t know better judge it by it’s historical association with Windows rather than how powerful it is today. Some of us actually got to experience the entire journey from the old to new world first-hand. We started out as a .NET 3.5 Framework solution (windows only), and are now looking at a .NET 6 upgrade (any platform). Over the course of 7+ years, we went through all of the following…

I’m on a project I created in .NET 1 and then migrated to 2.0 (to generics) early on. It’s moved through VSS via svn to git. It has gone from VS 2002 on CD’s to VS2019/2022. It has over 100k commits. Still work full time on it today. I share your experience with the migrations. Never an issue. The new sdk (“core”) style project system was probably the largest blessing of this whole journey.

Re: Golang vs. C# (.NET 5.0) at Benchmarks Game

#47
post #35

I prefer C#. But here the Go code actually looks like normal production code while the C# examples look like something made by a low-level optimization wizard.

For C# they went too far, it has this comment in one of the files: > Using GOTO which currently causes dotnet to generate better machine code

Re: Golang vs. C# (.NET 5.0) at Benchmarks Game

#48

I can't imagine a better setup for a language flame war :). I really like debating languages, so I hope it doesn't go that direction. One of the standard caveats with this particular benchmark game with respect to Go is idiomatic optimizations are prohibited. To use the btree example, Go's memory management is low latency and non-moving, so allocations are expensive--any Go programmer writing a performance-sensitive…

> absolutely idiomatic and trivial optimization

Which is not accepted for the C# programs either.

sync.Pool is accepted —

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

> the Go version is expressly contrived to be slower

The requirements were contrived in April 2008.

afaict Go initial release was March 2012.

Re: Golang vs. C# (.NET 5.0) at Benchmarks Game

#49
I've never understood why folks treat the Benchmarks Game results as indicative nor representative of anything useful. The code specimens they use are often unpolished nor idiomatic, without even commenting on whether they could be made to perform better through Byzantine, careful by-hand optimization.

Why does their web site have no contact nor link to where the source code for the project can be checked out, contributed to, or amended?

Re: Golang vs. C# (.NET 5.0) at Benchmarks Game

#50

Earlier quoted context omitted.

I looked at the k-nucleotide, n-body, etc and saw nothing out of the ordinary in terms of C#. There wasn’t even a lot of “modern C#” low level optimization like ref-structs/spans and similar. It actually looks like there is quite a bit of performance from C#8, 9, 10 left on the table.

Are we looking at the same file?[0] Tons of very "interesting" attributes like this: // prevent inlining into main to decrease JIT time to generate main [SkipLocalsInit][MethodImpl(NoInlining)] [SkipLocalsInit][StructLayout(LayoutKind.Explicit, Pack = 32)] [SkipLocalsInit][MethodImpl(AggressiveOptimization | NoInlining)] [FieldOffset(32)] and tons of "unchecked" blocks. Not to mention that the entire file is using ex…

Agree - those attributes are definitely “low level” and not idiomatic in most situations. I must have missed them skimming that file.

For the particular case of n-body you could argue you are already in a pretty extreme HPC world and doing it without vectors would basically be a toy calculator. The problem then of course that C# isn’t really ever idiomatic for that. The question (as alaways) becomes about what to compare. Typical or pushed to the limit.

Post reply on HN