News for hackers. Stuff that matters.
Re:A comparison of Rust's borrow checker to the one in C# by DeathArrow on Thursday October 31, 2024 @05:15AM (#42004849)
Re:A comparison of Rust's borrow checker to the one in C# by Ygg2 on Thursday October 31, 2024 @05:25AM (#42004905)
Re:A comparison of Rust's borrow checker to the one in C# by EraYaN on Thursday October 31, 2024 @06:17AM (#42005265)
Those are notoriously cheat-y for just about all languages on that list. Any actual project is never going to get close to the efficiency that those number would require. Both Java and .NET over promise by A LOT with the numbers they get there.
Re:A comparison of Rust's borrow checker to the one in C# by Ygg2 on Thursday October 31, 2024 @08:01AM (#42005956)
Cheat-y in what way? I don't consider micro benchmarks that interesting especially since C# does have two aces that Java will get in mid term - namely Simd and primitive types.

The Tech Empower benchmarks do seem to reflect general state of Java Web Framework ecosystem with Vert.x being they hyper fast web framework and Spring being way slower.

Re:A comparison of Rust's borrow checker to the one in C# by EraYaN on Thursday October 31, 2024 @08:46AM (#42006352)
Well the amount of tricks that basically nobody can implement in production that those implementations do to get the numbers that they do is ridiculous. Meaning the numbers they get are wildly optimistic at best and misleading at worst.

If you take the standard template for any of these frameworks (both Java and C# and any other language) and you add authentication etc, the real performance will be 5-10% of the numbers reported in those benchmarks. Have a look through some of the weirdness in the implementations it's wild (and sometimes educational). The .NET team especially has done stuff specifically to get faster on those benchmarks.

Re:A comparison of Rust's borrow checker to the one in C# by dahauns on Thursday October 31, 2024 @11:25AM (#42007849)
> Have a look through some of the weirdness in the implementations it's wild (and sometimes educational). The .NET team especially has done stuff specifically to get faster on those benchmarks.

Could you give me a pointer or two? I wondered about that myself, especially considering the massive improvement from "old" .NET to the core/kestrel based solutions - but a quick browsing a while ago mostly left me astonished how...well, for lack of a better word, banal most of the code was.

Agreed though, lack of all kinds of layers like auth, orm etc. are sadly a drawback of these kinds of benchmarks, if understandable - it would make comparability even trickier and has the danger of the comparison matrix of systems/frameworks/libraries exploding in size. But yeah, would be nice datapoints to have. :)

Re:A comparison of Rust's borrow checker to the one in C# by EraYaN on Friday November 01, 2024 @05:08AM (#42015208)
They don't even use Razor Pages but a custom RazorSlices package to do the templating [1]. Yes, that is much faster because it removes MVC and a ton of infrastructure but it's also kind of gross. Also the use of stuff like UnsafePreferInlineScheduling has some downsides (running application code on the IO thread) and honestly I'd never use in production.

The custom BufferWriter stuff is pretty neat though, although also not really something most people will reach for. And there is more, like the caching of StringBuilders etc.

But it also doesn't use the actual HTTP server to build headers, but they just dump a string into the socket [2], feels a bit unrealistic to me. In general the BenchmarkApplication class [3] is full of non-standard stuff that you'd normally let the framework handle.

[1] https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast... [2] https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast... [3] https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast...

Re:A comparison of Rust's borrow checker to the one in C# by dahauns on Monday November 04, 2024 @12:51PM (#42044154)
Thanks a lot for the input, that's quite enlightening - seems like I have been browsing everything but the "Platform" target...

Puh, yeah, I see what you mean, much the stuff in [2] and [3] is rather...bespoke, especially compared to the minimal and mvc targets. Not really what I'd consider "realistic" as per the benchmark's definition.

But TBH, I wouldn't consider [1] gross, on the contrary - simple, fast, lightweight Razor templating without other MVC (or other external) dependencies isn't that unusual a use case and something I've often thought ASP.NET Core was missing (even Razor Pages feel like overkill if you just want to quickly generate some dynamic HTML).

Re:A comparison of Rust's borrow checker to the one in C# by neonsunset on Thursday October 31, 2024 @11:04AM (#42007647)
I second this sentiment. If anything, I genuinely think that the way .NET's TechEmpower submissions look does more damage than good. BenchmarksGame offers a much better close-up comparison by having much simpler submissions that mostly consist of code that you could totally see yourself write in a regular setting.

.NET is perfectly capable of standing on its own, and if there are specific areas that need improvement - this should serve as a push to further improve DB driver implementations and make ASP.NET Core more robust against various feature configurations. It is already much, much faster than Spring which is a good start, but it could be pushed further.

I'd like to note that neither Go nor Java are viable for high-performance programming in a way that C# is. Neither gives you the required low-level access, performance oriented APIs, ability to use zero-cost abstractions and platform control you get to have in .NET. You can get far with both, but not C++/Rust-far the way you can with C#.

Re:A comparison of Rust's borrow checker to the one in C# by Ygg2 on Thursday October 31, 2024 @12:41PM (#42008572)
> BenchmarksGame offers a much better close-up comparison by having much simpler submissions that mostly consist of code that you could totally see yourself write in a regular setting

Yeah, except if you are working on Web servers the quality of the framework and its supporting libraries is much more important than what code could theoretically achieve. What is the point of being able to 200 mph when you only ever drive up to 30mph.

> Neither gives you the required low-level access, performance oriented APIs, ability to use zero-cost abstractions.

Java is working on high performance abstractions, see Vector API (Simd) and project Valhalla (custom primitive types).

Sure C# has a theoretical leg up (for which it paid dearly by causing backwards incompatibility with reified generics) but most of the libraries don't use low-level access or SIMD optimizations or what not.

Re:A comparison of Rust's borrow checker to the one in C# by vips7L on Thursday October 31, 2024 @02:44PM (#42010078)
Most the Debian benchmarks for C# are cheaty too. They frequently just call out to C libraries rather than use something implemented in the language.
Re:A comparison of Rust's borrow checker to the one in C# by neonsunset on Thursday October 31, 2024 @03:59PM (#42010872)
Not sure which benchmarks you have in mind. Could you provide a link to any of those? .NET's standard library never calls into anything C aside from kernel APIs and certain runtime helpers which is a given.

If you meant BenchmarksGame, then it's the other way around - Java is most competitive where it relies heavily on GC[0], and loses in other areas which require capability to write a low-level implementation[1] that C# provides.

The only places where there are C calls are pidigts[2] and regex-redux[3] benchmarks, in both of which the Java submissions have to import pre-generated or pre-made bindings to GMP and PCRE2 respectively. As do all other languages, with varying degrees of "preparation".

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

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

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

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

Re:A comparison of Rust's borrow checker to the one in C# by vips7L on Friday November 01, 2024 @09:19AM (#42016672)
Im sorry, but calling out to C libraries — regardless of the language — is cheating. Just because everyone in the competition is on steroids doesn’t mean you got there legitimately.
Re:A comparison of Rust's borrow checker to the one in C# by neonsunset on Friday November 01, 2024 @11:39AM (#42018050)
This is a strange reply given that sibling comment points out it's only 2 out of 10 benchmarks where this is allowed because all languages end up calling out to the same libraries.

Even if you prohibit PCRE2, the .NET submissions using out-of-box Regex engine end up being about 4 times faster than Java.

Surprisingly, even though .NET's BigInteger is known for its inefficiency, it ends up being more memory efficient and marginally faster at pidigits than a Java submission that does not use GMP. The implementations are not line-by-line equivalent so may not be perfectly representative of performance of each BigInt implementation.

My point being - if you look at the submissions closer, the data gives much clearer picture and only supports the argument that C# is a very usable language for solving the tasks one would usually reach for C, C++ or Rust instead.

Re:A comparison of Rust's borrow checker to the one in C# by vips7L on Friday November 01, 2024 @12:28PM (#42018640)
Its not a strange reply at all. _All_ of those languages are cheating. Those benchmarks are junk because they don't test implementations in the language.
Re:A comparison of Rust's borrow checker to the one in C# by igouy on Friday November 01, 2024 @01:16PM (#42019251)
Re:A comparison of Rust's borrow checker to the one in C# by igouy on Friday November 01, 2024 @12:27PM (#42018629)
https://www.wilfred.me.uk/blog/2014/10/20/the-fastest-bigint...

Look at all the programming language implementations that provide big integers by calling out to GMP. Why would it be "cheating" when available to all and done openly? Libraries matter.

Re:A comparison of Rust's borrow checker to the one in C# by igouy on Thursday October 31, 2024 @05:52PM (#42011933)
No, they do not "frequently just call out to C libraries".

2 of 10 (pidigits and regex-redux) allow use of widely available third party libraries — GMP, PCRE, RE2 — because there were language implementations that simply wrapped those libraries.

Re:A comparison of Rust's borrow checker to the one in C# by lossolo on Thursday October 31, 2024 @09:04PM (#42013094)
You should really create a way to filter solutions with SIMD intrinsics and without them.
Re:A comparison of Rust's borrow checker to the one in C# by igouy on Thursday October 31, 2024 @10:12PM (#42013443)
Like the hand-written vector instructions | "unsafe" section down-page?

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

It’s not that easy. I assume other programs hide the use in macros and libraries, in ways far beyond my simple understanding.

Re:A comparison of Rust's borrow checker to the one in C# by lossolo on Thursday October 31, 2024 @10:23PM (#42013501)
Cool! I didn’t see it before, maybe because I mostly use the language vs. language feature. There is no such section there, but it would be very helpful IMO, instead of clicking every solution to check which one is intrinsics free.
Re:A comparison of Rust's borrow checker to the one in C# by igouy on Thursday October 31, 2024 @10:38PM (#42013573)
> language vs. language

Where there are few enough programs that readers should check that the programs they compare seem appropriate for their purpose.

Re:A comparison of Rust's borrow checker to the one in C# by lossolo on Friday November 01, 2024 @01:13AM (#42014237)
Well, it's your site, so you can do what you want with it, but I don't believe what you just wrote is logical at all. Sometimes, you just want to see, in general, how one language compares to another when one uses intrinsics and the other doesn't, without having to click through every single benchmark across multiple versions to find one without intrinsics. This is just bad UX and waste of time.
Re:A comparison of Rust's borrow checker to the one in C# by neonsunset on Friday November 01, 2024 @03:32AM (#42014769)
Surely you wouldn’t say that if the language you wanted to win had SIMD API :)
Re:A comparison of Rust's borrow checker to the one in C# by igouy on Friday November 01, 2024 @12:09PM (#42018387)
> one uses intrinsics and the other doesn't

Why? Did you mean both use intrinsics or both don't?

> Sometimes, you just want to see

As-it-says, look for more-secs less-gz-source-code -- probably less optimised.

Re:A comparison of Rust's borrow checker to the one in C# by igouy on Saturday November 02, 2024 @07:09PM (#42029913)
*

But it’s not that easy.

Filters some but maybe not all and maybe filters some wrongly.

Re:A comparison of Rust's borrow checker to the one in C# by vips7L on Friday November 01, 2024 @09:10AM (#42016606)
20% is frequently. And calling out to C is cheaty.
Re:A comparison of Rust's borrow checker to the one in C# by igouy on Friday November 01, 2024 @12:10PM (#42018407)
Why would it be "cheaty" when available to all and done openly? Libraries matter.
Re:A comparison of Rust's borrow checker to the one in C# by igouy on Saturday November 02, 2024 @02:12PM (#42028078)
In any case, because the charts are frequently cut & pasted out-of-context they should not include pi-digits and regex-redux data. Now they don't, so thank you.

If you don't think it's appropriate to compare the pi-digits and regex-redux programs, simply ignore them and compare the other 8!