This is fantastic, I love when people show the code for comparison. It really highlights the differences in ergonomics between the languages. I did the same when comparing Crystal to Rust and, even though the ergonomics weren’t the point of that post, people still mentioned it a lot. :-D
One of the Disqus comments makes a good point, though: have you tried running the Crystal code with --release
and CRYSTAL_WORKERS
environment variable set to the number of CPU cores on your machine (defaults to 4)? That may or may not make it fast enough to outperform the Go code (seriously, it might!), but even if it doesn’t it’ll likely be a lot closer than without it.