Ruby's frustrating use of cryptic variables

written by paul on August 9th, 2007 @ 01:26 PM

One thing that really bothers me about ruby is its use of cryptic variables such as $: and $?. For example:


$: << "/some/path" 

I find this version much better:


$LOAD_PATH << "/some/path" 

I vastly prefer the verbose version for its clarity. In addition, an unfamiliar user cannot search $: in google.

The standard Ruby distribution provides a library called English which maps many of these variables to useful names. I think this should be the default, however, and not require an external library (which is not part of core). I also think the cryptic versions should be deprecated and eventually removed to encourage the use of the verbose names.

Comments

  • Peter Ryan on 10 Aug 14:15

    I couldn't agree with you more about including English into the standard library (although what to do about French.rb, Spanish.rb and the natural ruby juggernaut Japanese.rb. After six months on Rails I find that I still have no idea of the differences between $' and $` and a poor font might make it even harder to distinguish. That said for historical reasons I am not against keeping the $' $` cryptic versions. The globals are language agnostic . And lastly let's not that Ruby is a scripting language and may need to compete in some cryptic code competition with a perl module.

Post a comment

Options:

Size

Colors