I'm doing a bunch of exercises from Project Euler, as a way of exercising my mind a bit, and getting myself more familiar with Erlang.
So, I'm working on problem 7, which involves finding the 10,001th prime number. I hack up a really brute-force solution in Erlang, expecting it to take forever. 524ms of wall clock time later, it's done. Wow, that was pretty good, apparently my algorithm isn't as dodgy as I thought. What about in other languages?
My first try, in Ruby, with roughly the same algorithm, runs in 6.3s. Yeah, OK, we all know Ruby is slow as molasses, and we don't write things in it for their speed.
Next, since no doubt all the Pythonistas are scoffing at Ruby's poor showing, I converted my Ruby code into Python. This basically involved sticking a colon on every second line and filing off the ends. 2.03s, which is highly respectable relative to Ruby's time, but kinda bodgy compared to Erlang.
Finally, that old speed standby, C. 49ms. Apparently my algorithm isn't all that bad overall, and C is still damned fast compared to everything else out there.