Checking for my own “benchmark”, a gameboy emulator in several different languages[0]; it’s CPU-bound but across ~3k lines of code, so slightly more representative of real-world apps than a single-function tight-loop microbenchmark:
zig: Emulated 600 frames in 0.24s (2521fps)
rs: Emulated 600 frames in 0.37s (1626fps)
cpp: Emulated 600 frames in 0.40s (1508fps)
nim: Emulated 600 frames in 0.44s (1367fps)
go: Emulated 600 frames in 1.75s (342fps)
php: Emulated 600 frames in 23.74s (25fps)
py: Emulated 600 frames in 26.16s (23fps) # PyPy
py: Emulated 600 frames in 33.10s (18fps) # 3.11
py: Emulated 600 frames in 61.43s (9fps) # 3.10
Doubling the speed is pretty nice :D Still the slowest out of all implementations though :P[0] https://github.com/shish/rosettaboy
EDIT> updated the nim compiler flags to build in release mode like most other languages, thanks @plainOldText!
Interesting. On the trifecta of money vs pain vs speed, Go seems to be a reasonable compromise.
FWIW I personally found Rust the least-painful language, but that may well be confirming my pre-established biases :)
- With Zig I kept running into compiler bugs, plus no package manager (I’ve vendored SDL and Clap into the source tree)
- C++ I’d occasionally shoot myself in the foot in ways that other languages would have caught, plus no package manager (OS-level package management does an OK job, so long as you don’t mind using old versions, and faffing about with different operating systems acting very differently)
- The pain from Rust was one time where the compiler wanted me to specify a lifetime, and I didn’t understand, so I just spammed lifetime specifiers in various places until it compiled. I’ve been using Rust for a couple of years now and I still don’t really understand lifetimes, but thankfully 99% of the time I can avoid them.
- Nim was a relatively nice language but massively lacking in available libraries (like even parsing command line arguments took me a day just trying to find a library which worked)
- Go is pretty nice, my main pain is the tolerable but constantly-annoying verboseness of error handling (`err := foo(); if err != nil {return err}` compared to rust’s `foo()?`)
- PHP I just hate on a deep and personal level thanks to years of being a PHP4/5 developer. The language is actually mostly-ok-ish these days, but the standard library is still full of frustration like inconsistent parameter orders within a family of functions.
- Python is all-round really nice to write, but the test suite takes like 20 minutes to run, which really messes with my flow-state