Zig finished #1 leaving Rust, C, C++, and Java in the dust. Top 5 Fastest Programming Languages: Rust, C++, Swift, Java, and 90 more compared! - YouTube
I wonder how much Zig’s “-march=native”-by-default helps it out here. I think I read a Zig developer say that Zig isn’t the fastest compiled language.
A lot of things came into play in this benchmark. The main thing being measured here is how motivated was the person who got nerd sniped into participating in this competition.
In our case it was Isaac Yonemoto (with the help of a couple more people) who, among other things, figured out that the CPU the test was run on was a 16-core machine with hyperthreading (ie which reports having 32 cores to the OS). HT is not useful when doing compute-heavy work with a focus on throughput, so he would only spawn 16 threads, while is seems the other language teams didn’t realize it would have been a useful thing to do.
Both Zig and Rust use LLVM for release builds so they ultimately are subject to the same set of optimizations. There are practical differences, but you should expect both to be pretty much equivalent.
While I’m certainly pleased at the performance of Zig (it’s obviously really good), I have to say that I’m more excited about how easy it is to build large-scale projects.
For context, one of the larger companies I worked for has a 30 year-old C++ back-end… the build system was a nightmare and terribly fragile. There’s all kinds of features and expansions that we’d wanted to do but were often deadlocked by what is lovingly referred to as “DLL Hell”. I’m not sure most people are aware of how deep the “legacy” goes… I did some back of the envelope calculations and there was roughly 124,000 macros through the whole system (~124 solutions, 1000 #define statements per resource file… and those were just the resource files… the actual number is much higher).
I can think of all kinds of optimizations and improvements we wanted to perform at work but our hands were basically tied most of the time. And as @kristoff pointed out, we should be skeptical of benchmarks in general. Benchmarks aside, I think the biggest win here is moving away from the archaic build systems so we can modernize some of these things and move forward.