The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
My response to a rant about Ruby

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Vincent Foley

Posts: 512
Nickname: gnuvince
Registered: Apr, 2005

Vincent Foley is a hobbyist Rubyist.
My response to a rant about Ruby Posted: May 27, 2005 9:53 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Vincent Foley.
Original Post: My response to a rant about Ruby
Feed Title: Vincent Foley-Bourgon
Feed URL: http://www.livejournal.com/~gnuvince/data/rss
Feed Description: Vincent Foley-Bourgon - LiveJournal.com
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Vincent Foley
Latest Posts From Vincent Foley-Bourgon

Advertisement
Somebody on comp.lang.ruby posted about a blog entry he'd spotted which openly ranted about Ruby. The rant seems to be written by an angry teenager, he keeps saying the word "shit" and "fuck" all over and even calling Ruby developers "fucktards". I don't have a problem with people writing critiques of Ruby (or other things I like), however, you need to know how to keep it civilized so that people don't think that _you_ are a fucktard when they read it. The guy should've read this section of Eric Raymond's "How To Ask Questions The Smart Way". Nonetheless, I think some of the points he made were worth discussing, so I'm gonna do that here.

First, he mostly attacks what some people called the Principle Of Least Surprise (POLS). Now, least surprise is very subjective, and matz, Ruby's creator, has tried many, many times to explain it, but people, as usual don't listen. The principle of least surprise means that when you are used to Ruby, if you learn a new language feature, or a new library, its behavior should surprise you the least, it should be as similar as the rest of Ruby. That's what it means. It doesn't mean least surprising to people from other languages, how would we be least surprising to a guy who like C, a guy who likes Forth and a guy who likes APL? We can't, so people saying that Ruby doesn't do things the way other languages do them (and usually, other languages means the three languages the person is used to, and those are very often C, C++ and another language).

Okay, let's start it off.


It's 5.abs for absolute value, but Math.sqrt(5) for square root.

Almost every Ruby document I read boasts about how everything's a method and how it's a "pure OO" language. Whoops. I guess not.


I agree with him. Once you know Ruby, your reflex would be to use 5.sqrt. I don't know exactly why a lot of mathematical functions are in the Math modules, but some are in the Number class. I think rewriting the methods in Math so that it can be included in the Number class would be a good idea.


Only nil and false evaluate to false.

That is to say, empty sets like [], {}, and "" all evaluate to true. But here's the kicker: 0 also evaluates to true:

if 0     # True
if []    # True
if {}    # True
if ""    # True
if nil   # False
if false # False



Personnally, I love this behavior. And it would be even better if nil did not evaluate to false. In my opinion, the expression you put in an if statement should evaluate to true or to false, any other result (non-boolean) should raise an exception. Having an empty hash table evaluate to false can be useful for small scripts, but becomes an maintenance nightmare. I think matz made the right choice, and I think I can live with nil (but we could easily just say if foo.nil?)


There's no decent namespace mechanism a la Python.


I'm not going to paste the whole thing here, it's a bit long, so you'll have to read it on his blog. However, I'm a bit divided on this issue. One the one hand, implicit namespaces like Python would be easier and modules would then be used only for mixin purposes. I agree with him that it's a drag to use modules to make namespaces, especially if you want module methods. On the other hand, doesn't using modules to control namespaces make Ruby more flexible? You can have methods of a namespace defined in multiple files.


Remember back when I said "I'm just going to ignore for a moment that @attribute is no less distracting or retarded than self.attribute?" Well, here's where I stop ignoring it.


The guy doesn't like prefix symbols in variables (@ for instance, @@ for class and $ for global variables). I personally don't have a problem with it. Once you're aquainted with the language, it's not hard to distinguish them, and typing @foo is faster and shorter than self.foo. $foo will raise a huge alarm signal for any Rubyist, a global variable should be used only in special circumstances, so upon seeing the fearsome leading dollar-sign, people know what they're dealing with.


The difference between :: and . is arbitrary and stupid.


Wholeheartedly agree. Never quite understood why we didn't use the dot for everything


The ever helpful "syntax error."

If you forget an end somewhere the only error you get is "file.rb:5: syntax error." Well golly, thanks for that in-depth error message. It took me ten minutes to figure out what the fuck it was talking about the first time around, as the line number it spits out can be anywhere from one to infinity lines within the actual error.


First, the missing end keyword rarely bites me, because I use auto-indenting editors, so you know if you forgot one, or got one too many. But besides that, sure the message could be a little more specific, but I don't have a problem with it, just go to line 5, and look there. Not there? Start looking up for a missing comma or something like that. Not terribly hard. I don't know of projects like Lint or PyChecker of Ruby, but I guess if we had one, you'd just stick a RakeTask in your Rakefile and run that to know whether you have a syntax error somewhere, and what it is.


Globals that resemble the Sunday comic swear characters suck.

That is to say, the Perl special variables like $_, $*, $' et al. Fortunately, the Ruby community pretty much hates these too, and they're steadily losing popularity in Ruby code. Ruby never should have started off with the implicit $_ shit that Perl pulls though. The only Good Thing they got from Perl was inline regular expressions.

These variables aren't going to be familiar except to Perl hackers.

So much for POLS.


I agree, I don't think Ruby should've had those in the first place. It did help me with my IORCC entry, but that's pretty much it. $LOAD_PATH is much clearer and telling than $: if you ask me. But like he said, most Rubyists shun upon those, so I sort of hope that they can completely go away in Ruby 2.x

I'm gonna stop there, I don't really feel like going over the other rants he has (mixins, exceptions) but I think that in spite of his bad mouth, this guy has put together a list of things that the ruby-devel gang should look at and ponder about.

Nevertheless his harsh criticism, I think we can still safely say that Ruby is one of the best programming languge out there. Not a B&D language like Java, not a mutant monster like C++, not a divided language like Lisp (a shame they can't work together) or a language people rejected years ago and won't reconsider, no matter how great they are (Smalltalk comes to mind, so does Lisp).

Ruby has a large and very friendly community, its implementation is good, and is gonna get even better with YARV in 2.x, we got plenty of third-party libraries and the most important of all, it's fun and we enjoy programming in Ruby.

Read: My response to a rant about Ruby

Topic: RubyForums Looking for Moderator Previous Topic   Next Topic Topic: Ruby's typing model vs Haskell, ML

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use