Metacircular thoughts

June 17, 2007

If Ruby is so great

Filed under: Politics — metacircular @ 9:40 pm

Why do I always see Ruby programmers using hash parameters as a substitute for keyword/optional arguments? Why don’t they cook up a DSL that adds that to Ruby, huh? Why do they destroy the readability of their code by making 80% of their functions take one or two parameters and then a completely uninformative one called “options?” Why do they, in spite of this wannabe Common Lisp phenomenon, then insist that Ruby is an acceptable Lisp?

Why doesn’t Ruby have a decent VM?

Why do I have to drop down to C if I want to do anything that requires performance and there’s not a major bottleneck like a database? Like, say, large unit test suites?

Why do available Ruby development tools imitate IDEs for Java/C/C++ rather than imitating Squeak and VisualWorks? In fact, why does Ruby ignore so much of the valuable prior art the Smalltalk community has accumulated?

31 Comments »

  1. Ruby is not great, it is all just hot air. Maybe in 5 years when they get a good implementation going it will be useful, but for now it sucks.

    Comment by Slava Pestov — June 17, 2007 @ 11:59 pm

  2. “why does Ruby ignore so much of the valuable prior art the Smalltalk community has accumulated?”

    Because the Ruby community is trying to appeal to developers who currently use languages like C++, Java and C# and who are used to relying on an IDE to organise their projects for them. These developers have never seen a Smalltalk environment and would not understand what to do with one.

    Comment by CR — June 18, 2007 @ 2:43 am

  3. Well, M. Pestov, if you think it “sucks”, then why don’t you go ahead and write your own language? I’ll have you know that writing a language is hard, requires a lot of going back and Forth, and even when you think you’re done you have to post-fix it.

    Comment by René Ghosh — June 18, 2007 @ 5:04 am

  4. Five points for René.

    Comment by John Nowak — June 18, 2007 @ 6:12 am

  5. Hey Rene, I don’t know if you know this, but slava pestov *has* written his own lnaguage: IO (see http://www.iolanguage.com/about/)

    Comment by George Jempty — June 18, 2007 @ 6:34 am

  6. What a bad troll. Go use something else. Why are you so jealous of ruby’s success?

    Comment by Andre — June 18, 2007 @ 6:45 am

  7. George - Slava’s language is Factor (http://factorcode.org/). And I think Rene knew this, given the multiple jokes hidden in his post.

    Comment by Jonathan — June 18, 2007 @ 7:27 am

  8. Completely agree with the article. Ruby is great as a Perl++, but it is still lacking as an “acceptable Lisp.” However, the big win of Ruby is in integrating lots of good stuff from Perl, Smalltalk, and Lisp into a *popular* language.

    And René, you just made my day.

    Comment by Brad Ediger — June 18, 2007 @ 8:31 am

  9. Why do I always see Ruby programmers using hash parameters as a substitute for keyword/optional arguments?

    Because hash parameters work pretty well? Why fix what isn’t broken? This is an idiom that comes from Perl, btw.

    Why do they destroy the readability of their code by making 80% of their functions take one or two parameters and then a completely uninformative one called “options?”

    This is a useful idiom if you have a method whose behavior can vary in lots of subtle ways. It’s not “completely uninformative” if the options are documented (which they are pretty consistently throughout Rails, for example).

    Why do they, in spite of this wannabe Common Lisp phenomenon, then insist that Ruby is an acceptable Lisp?

    By “they” you mean “one guy who wrote a blog entry a year and a half ago.” Personally I think that Ruby is much better than Lisp, and think it makes more sense to ask if Lisp is an acceptable Ruby, which it isn’t. Syntax matters. People don’t write natural languages in grammar trees, so why should we write programming languages in abstract syntax trees?

    Why doesn’t Ruby have a decent VM?

    If by “decent” you mean “fast,” the answer is that Matz worried more about getting the language right before making the interpreter fast. It’s not like he’s never heard of compiling to byte code.

    If by “decent” you mean “uses native threads and doesn’t have weird corner cases with I/O,” the answer is that green threads unfortunately ended up being a problem because the OS’s on which Ruby runs have somewhat spotty support for doing fully non-blocking I/O.

    Why do I have to drop down to C if I want to do anything that requires performance and there’s not a major bottleneck like a database?

    Because Ruby’s not fast yet.

    In fact, why does Ruby ignore so much of the valuable prior art the Smalltalk community has accumulated?

    Because a large part of Smalltalk’s failure was a result of how it lived in its own little world, preventing you from reusing any of your existing toolchain (editor, source control system, grep, etc). Yes, I know that Smalltalk had amazing versions of these tools, but no language is important enough to dictate my toolchain to me, especially if that toolchain works ONLY for the language in question.

    Comment by Joshua Haberman — June 18, 2007 @ 8:34 am

  10. I would have factored in even more references, but I didn’t want anybody to get pestov at me.

    Comment by René Ghosh — June 18, 2007 @ 8:51 am

  11. wha? a post bashing ruby that doesn’t mention tail recursion once.

    TAIL RECURSION.

    jeez.

    Comment by andrew cooke — June 18, 2007 @ 8:54 am

  12. Slava is a known troll who was once beaten up by Java,Ruby,Python, and Perl one day. At least that’s what he believes: it was actually Smalltalk, who refuses to play nicely with anyone. He can’t stand that more people use (and even like) the above languages more than his pet languages. For some reason, he posts lots of inflammatory material to reddit. I worry about him a little.

    Comment by ToothFairy — June 18, 2007 @ 9:24 am

  13. “…green threads unfortunately ended up being a problem because the OS’s on which Ruby runs have somewhat spotty support for doing fully non-blocking I/O…”

    Then how did Java manage to produce their NIO package?

    Comment by Rintoul — June 18, 2007 @ 9:52 am

  14. Because its a work in progress. Calm down.

    Comment by Tyler — June 18, 2007 @ 10:13 am

  15. IO? Factor? mmm ok.
    Slava comes out like a bitter old man.
    Sorry, I usually do not take so strong positions, I prefer to see both sides of things, but “Ruby is not great, it is all just hot air”? Don’ kno Factor but I played with both, and Ruby IS better than IO…

    Comment by C — June 18, 2007 @ 2:41 pm

  16. [...] If Ruby is so great Why do I always see Ruby programmers using hash parameters as a substitute for keyword/optional arguments? Why […] [...]

    Pingback by Top Posts « WordPress.com — June 18, 2007 @ 3:58 pm

  17. There are important technical reason for making keyword parameters work this way. Ruby is Object-Oriented in Smalltalk way (not in C++/Java/CLOS way), so there are no function/method calls, only message sends. You have no idea what’s on the receiving end - sender needs to package all arguments in a single standarized message packet and send to the receiver. The message format is [receiver, method selector, list of arguments, block argument, (some ugly metadata to make protected and private work that shouldn't really be there)]. If keyword arguments were passed as a separate field in the message packet instead of simply as extra last argument it would make the message packet format more complex and metaprogramming would be harder - for example method_missing would need to handle (meth, *args, **kwargs, &blk) instead of (meth, *args, &blk). More syntactic sugar on the receiving end would be possible, but nobody really cares that much - Ruby looks nicer than all other languages anyway.

    Comment by taw — June 18, 2007 @ 4:21 pm

  18. All problems with Ruby are offset once we can start optimizing our applications, because as you know, there are those three steps: first make it work, then make it right, finally make it fast.

    It means that once we start optimizing, we have gotten a lot of the job done. Multiply that by many different projects and you have a winner.

    Comment by Joao — June 18, 2007 @ 6:10 pm

  19. Will a Ruby programmer ever admit Ruby is slow, or will it always just be more platitudes?

    Comment by John Nowak — June 18, 2007 @ 6:53 pm

  20. As I write some thousands of lines of JavaScript, and being a Ruby programmer at heart with some tens of thousands of Ruby in some tens of different libraries, and as I write in “optimized JavaScript code” with fear of making matters too slow, I can only say that I prefer Ruby’s code, slower as it may be, as I could be done coding way faster and in far fewer lines of code.

    I just came in here thinking how Slava’s Factor can be optimized for the “compiler” rather than for the programmer, and how out of luck he has been in making Factor any popular. It’s a price one needs to pay, right? One way or another.

    Comment by Joao — June 18, 2007 @ 7:59 pm

  21. “Will a Ruby programmer ever admit Ruby is slow, or will it always just be more platitudes?”

    Here you go: http://antoniocangiano.com/articles/2007/06/19/on-ruby-and-rails-criticism :)

    Comment by Coder — June 19, 2007 @ 12:13 am

  22. “There are only two kinds of languages: the ones people complain about and the ones nobody uses”

    Comment by catch23 — June 19, 2007 @ 12:46 am

  23. Why should we use syntax trees to write code when we don’t use them to write
    natural languages? Well, why do I write this post in English and not
    my native language? Because I choose the language that is most likely
    to get the message across and since computers are *much* worse at
    learning natural languages than people are at learning syntax trees lisp
    doesn’t seem as such a bad idea.

    My point isn’t that lisp is the One True Language (which it is, btw
    :-) ) but that the seemingly bizarre syntax greatly facilitates
    stuff like metaprogramming, code generation and even editing. Ruby
    isn’t an acceptable lisp (lacking e g macros and fast compilers) but
    it still deserves love, for if java shifted the computing mainstream
    halfway from C++ to lisp, then ruby will halve the distance again if
    it gains enough traction.

    Comment by rickardg — June 19, 2007 @ 3:22 am

  24. I like Ruby. Has a lot of good stuff to it. My company, one of the top investment banks is starting to use it too. I just wanted to add this though…

    Ruby is too slow to be used on anything mission critical in many lines of business. Unless you are creating another social network site or Web 2.0 startup, then in the corporate world your business realm will be limited to whatever issue tracker / procurement website that will be used to order toothbrushes, and toilet paper w/ a bit of ajax mixed in. If you find that kind of business / interest satisfying, then good on ya. If you’d rather do pricing / trading engines etc, then java / c++ are still the way forward.

    Comment by javaToRubyThenBackToJava — June 19, 2007 @ 8:29 am

  25. javaToRubyThenBackToJava, do you think that Adobe’s Flash, Flex and Apollo could have a run at some of the “pricing/trading engines” too? At least for the front-end? And the Web browsers are some of the most developed pieces of front-end programming, ever. Firefox with its extensions, plugins, cross-platform support, and so on, is a king, and it’s even coded in C++ as well. The ways to leverage Firefox’s features are still growing, so don’t be too fast to play down where the world seems to be moving to.

    Comment by Joao — June 19, 2007 @ 9:24 am

  26. In answer to Joshua Haberman and taw:

    Why do I always see Ruby programmers using hash parameters as a substitute for keyword/optional arguments?

    Because hash parameters work pretty well? Why fix what isn’t broken? This is an idiom that comes from Perl, btw.

    If you’ve taken a look at Smalltalk, you will understand what Henning is getting at. Here are a couple examples of what he’s complaining about. Firstly, in Smalltalk:

    (internalDB
    findDatasetWithCategory: #General
    region: ‘Georgia’
    subRegion: ‘Atlanta’ ;) value: dataset.

    The findDatasetWithCategory:region:subRegion: call returns an association. To translate this into Ruby as much as possible, you’d get:

    (internalDB.Find_dataset_with :category=>:General, :region=>”Georgia”, :sub_region=>”Atlanta” ;) = dataset

    Here’s a cascading example in Smalltalk:

    query := (WebQuery fromAddress: ‘http://data.bls.gov/cgi-bin/srgate’ ;)
    where: #format is: ‘block’;
    where: #html_tables is: ‘no’;
    where: #catalog is: ‘no’;
    yourself.

    Each where:is: call is the same message with different parameters, cascaded to the WebQuery object before it’s assigned to query. Each symbol (preceded by ‘#’ ;) is directly translatable to a string, so it’s easy to format them into a CGI string. I wanted to make screen scraping a bit like querying a database. The closest I could get in Ruby is:

    query = WebQuery.new :fromAddress=>”www.google.com/search”
    {hash[:format=>"block, :html_tables=>"no", :catalog=>"no"]}

    Apologies if I mangled the syntax and semantics. My Ruby skills are weak.

    If you compare the styles, there’s more cruft in Ruby, IMO. Ruby doesn’t support named parameters in message sends, nor does it support cascading. The hash parameters are really associations. You can do the same thing in Smalltalk, but why would you?:

    (internalDB findDatasetWith: #(#category->#General #region->’Georgia’ #subRegion->’Atlanta’)) value: dataset.

    Why doesn’t Ruby have a decent VM?

    If by “decent” you mean “fast,” the answer is that Matz worried more about getting the language right before making the interpreter fast. It’s not like he’s never heard of compiling to byte code.

    I support the idea of getting the language right, but even Squeak (Smalltalk) runs quite a bit faster than Ruby, according to one benchmark test.

    In fact, why does Ruby ignore so much of the valuable prior art the Smalltalk community has accumulated?

    Because a large part of Smalltalk’s failure was a result of how it lived in its own little world, preventing you from reusing any of your existing toolchain (editor, source control system, grep, etc). Yes, I know that Smalltalk had amazing versions of these tools, but no language is important enough to dictate my toolchain to me, especially if that toolchain works ONLY for the language in question.

    You haven’t looked very hard at Smalltalk. GNU Smalltalk supports scripting, so you can use your own toolchain. Performance probably suffers a bit because it has to recompile your script each time it’s run. Squeak supports scripting as well, though I haven’t used it for that, so I don’t know how well that works.

    I understand the “all-in-oneness” of the Smalltalk system turns off a lot of people. The reason that those of us who’ve tried Smalltalk and actually like it is we’ve changed our mind about how to do development. There are some ways in which Smalltalk is easier to deal with than the file-based systems that I used to be so used to. Nothing is set in stone. Like with Emacs, if you don’t like how the code browser works, you can change it…all you like, as long as you’re willing to delve into its code. You can even make any text window in Squeak, including the code browser behave like Emacs if you like.

    Comment by Mark Miller — June 19, 2007 @ 8:52 pm

  27. Oops. Screwed up the 2nd Ruby example. I meant it to read like this:

    query = WebQuery.new :fromAddress=>”www.google.com/search”
    {hash[:format=>”block", :html_tables=>”no”, :catalog=>”no”]}

    Comment by Mark Miller — June 19, 2007 @ 8:58 pm

  28. (sigh) I hate this editor crap! I meant to say I got the web address wrong. Tired. Argh.:

    WebQuery.new :fromAddress=>”http://data.bls.gov/cgi-bin/srgate”
    {hash[:format=>”block”, :html_tables=>”no”, :catalog=>”no”]}

    There. I think that does it. :( Sorry for any confusion.

    Comment by Mark Miller — June 19, 2007 @ 9:03 pm

  29. ruby simply rocks!

    Comment by I — June 29, 2007 @ 3:19 pm

  30. [...] Henning wrote an article titled If Ruby is so great and opportunely filed it in the “Politics” category. He asks a few rhetorical questions – [...]

    Pingback by On Ruby and Rails Criticism | Zen and the Art of Ruby Programming — July 21, 2007 @ 4:52 am

  31. [...] ring into this courtly talk at http://metacircular.wordpress.com/2007/06/17/if-ruby-is-so-great about [...]

    Pingback by wellness-pet-food.1pets — September 9, 2007 @ 6:16 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.