Hacker News new | past | comments | ask | show | jobs | submit login

Sigils on variables are a good point. This is an area where I think Python wins out. Dependence on "self" all over the place is irritating at first but ultimately quite comforting - especially when you wonder whether you're going to screw up your attributes when you use the same name for a local variable in your Ruby method ;-)

But on inheritance - you have to put the class name in round brackets in Python, no? That's 2 characters to Ruby's 1.

Stuff like a ||= shouldn't be considered Ruby-specific noise as Python also has the same idiom as in a += and a -=, just not with ||. || is arguably noise over "or" but it shouldn't seem like cryptic noise with any sort of experience of C, C++, Java, JavaScript, or almost any other mainstream language.

Further, that Ruby code of yours does seem more Perlish than Rubyish, but I suspect this is because Ruby style is gradually shifting away from Perl-like styles to more idiomatic approaches. For example, I'd probably choose 'string'[/re(g)ex/, 1] or if I was trying to be "proper" then something like m = string.match(/re(g)ex/); m[1] (or potentially use Regexp#match, but I far prefer String#match). I see those solutions more typically than those you present - and the latter is quite like your Python example - but.. TMTOWTDI and that's Ruby's greatest asset :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: