The title is intentionally (but semiseriously) contentious, but I’m not
trying to say that Ruby is a bad language–I’m using it, right ?
However, any language has its unfortunate share of bad APIs, design
decisions, etc., and Ruby is no exception. I’ve stumbled across a few,
and thought it might be useful to start up a thread discussing what
people view as Ruby’s stupidities. Why? Because it’s a lot less painful
to find out about them by reading them than be tracking obscure errors
in one’s code.
In order to keep this on a not-completely-shouting-match level, I think
it’s fair to give a reason something you mention as a Ruby Stupidity is
in fact stupid. For example, it violates common sense, it causes more
trouble than it’s worth, etc. etc., and to discuss what a better way of
implementing such a feature might be.
Having said that, here’s my first entry. I think it’s utterly stupid
(can you tell I just wasted some time tracking this down?) that
"abc" == "a"
is false. Why doesn’t that work? Because, with a single index, the array
access operator on a string returns, not the character at the given
position, but the character code of the character at that position.
And why is that stupid?
1) It’s inconsistent even in Ruby’s own String API; all other index
operations (at least as shown in the standard rdoc) give strings or nil.
2) It’s unusual compared to most other scripting languages, meaning
it makes Ruby less approachable.
3) There seems to be absolutely no reason to do things this way;
providing a ‘char_code’ string method would result in clearer programs,
and it’s not like converting a character to a char code is such a common
operation that it’s necessary to save a few keystrokes at the cost of
Here’s hoping someone out there avoids this mistake after reading this.