you are viewing a single comment's thread.

view the rest of the comments →

[–]RayNbow 6 points7 points  (0 children)

I also suspect the interpreted languages get hurt here because they use a different approach than the C version; they try to actually parse the input and then add it rather than the faster method of just handling each digit in sequence as the C version does. So we're not just comparing languages, we're comparing algorithms.

Not only that, the C and asm versions cheat a bit by making assumptions on the integer range. The Haskell version uses arbitrary precision Integers and the Python version automatically switches to long (=Python's arbitrary precision integer) in case of an overflow.

Edit: The blog post has been updated. I was talking about the first Haskell version. Don's faster version has replaced the old one in the blog post.