by neonsunset · 2y ago · 0 comments
Comparable code (for errors.Is()) written in C# takes about 4ns on M1 Pro:
(made unidiomatic and abstracion-heavy-ish for demonstration purposes)
https://gist.github.com/neon-sunset/65a8deeaac745ba159f990c7...
Of course were it rewritten to a TryGet or (object, bool), it would bring that to 1-3 CPU cycles, as everything would get inlined and lowered to a few branches.
(this does not make the point any less valid as the solution this is applied to discussed in the blog post uses "vanilla" runtime flavour)
If 19ns is critical to my existence, I'm certainly not going to spend hours of it finding out if a handful of ns might be shaved off by using another implementation.
> which is inadequate at systems programming
Implying that Go is a scripting language?
The biggest lie is Go looks like a low-level-ish language whilst it's anything but, so you end up with the worst of both worlds. It's tooling starts fast, which gives you a false belief that it will continue perform fast, and time and time again people learn the hard way that it's just not the case.
It's ironic the story with C# is the opposite, that people expect it to underperform, and avoid it on the premise of criticism based on their imagination, only to be repeatedly proven wrong that it's much faster and extremely capable at systems programming tasks.