Arithmetic
Thursday, May 8th, 2008Just when I was beginning to think that maybe Ruby’s slight edge in readability made up for its big loss in consistency, I needed to use rational numbers:
- Ruby: Rational(3,5)
- Lisp: 3/5
Languages like Ruby and C are basically infix for arithmetic, and prefix for everything else. For a web app (like most apps, come to think of it), I pretty much never do anything more than the most trivial arithmetic. And here, in the one place where I do need something as complex as fractions(!), Ruby forces me to use prefix notation — which even Lisp, the prefix-notation king, doesn’t require. And not just prefix notation, but spelling out the name of the numeric type I want.
This seems just so deeply, thoroughly wrong.
