Finally reading Programming Crystal, by Ivo Balbaert and Simon
St. Laurent. Good stuff. The Crystal language has
advanced some since the book came out, but nearly all the code runs as-is.
Something that jumped out at me was the difference between their results and
mine with the benchmarking example. Not the raw numbers. I’d be a little
confused if those were exactly the same. The ratios caught my attention.
It’s faster on native Linux than WSL. That’s hardly surprising. But the
differences between to_s and interpolation are now negligible. For
that matter, both of them are closer to the speed of append than to_s
was in the book’s example!
Is the difference because of changes in Crystal? Some dependency, like LLVM?
My computer’s 40GB of RAM compared to whatever the authors used? My hard
drive? GPU? Is Mercury in retrograde?
I don’t know! I just saw different numbers and thought it was curious.
My point isn’t that the book’s wrong. Heck no. The example’s supposed to
remind you that testing your assumptions is important. All I’ve done is
emphasized the validity of the lesson.
Anyways.
Good book. Fun language. Don’t forget to try out the example code. And if
you need to care about performance? Don’t assume — benchmark.