Ruby 1.9, Shmuby 1.sh9

August 13th, 2008 by ymendel 2 comments »

There’s a lot of buzz about Ruby 1.9, at least if you’re looking in the right places. Sam Ruby gave a presentation about what to expect at OSCON, and I just found the slides today. They have me seeing red.

Before anyone gets the wrong idea, that’s not all aimed at Sam. It’s not even mostly aimed at Sam. I know it’s hard to put a good presentation together, and like anything else, the mistakes that are obvious after the fact were hiding during all the preparations and preliminary run-throughs.

So, some … let’s say “observations” about the slides.

(Note that I don’t have Ruby 1.9 installed and don’t plan to do anything with it or anything else past 1.8.6, not just yet.)


? (used like ?c), like defined?, was something of an annoyance (or it would have been had I ever wanted to use it). The shock of being suddenly shoved into a different world where normal scoping rules don’t apply is too much. And now that ?c will return 'c' instead of 99, what’s the way to get the ASCII value? Is there String#ord? Not that it ever really concerned me since I’m actually trying to write Ruby and not C, but it seems like some people care. For instance, I think Ryan Davis used ? heavily, so I can take some consolation in the fact that 1.9 will break some of his code.

The example given for Array#to_s makes it look like Array#inspect.

Apparently there was a lot of debate about the slide showing [1,2,3].each { |i| ... } vs. for i in [1,2,3]. My humble suggestion is that anyone liking the for i in syntax should go back to PHP.

Fixnum#to_sym presently returns nil? Who knew?

He already has errata for the ‘Hash Keys Now Unordered’ slide.

Okay, the BasicObject slide just hurt my head. This doesn’t even show what I would expect to see, which is that BasicObject has even fewer methods than BlankSlate (a NoneMoreBlankSlate, if you will). Instead, it shows something that looks like constant lookup being hijacked, detoured, and driven into a cliff.

“The biggest obstacle to Ruby 1.9’s adoption is the sheer number of mostly working but essentially unmaintained gems that virtually everybody in the Ruby community depends on.” ahem You know who you are.

Nitpick: For the alternate Hash syntax, the example should have ‘show’ quoted/

Jesus, who doesn’t hate stabby proc? And this also includes one of my pet peeves: defining a arg-taking method without using parentheses.

He implies that 1.8.6 doesn’t allow lambdas to be called with []. And 1.9 allows a lambda to be called like x.(1,2,3)? C’mon, people.

Complex(3,4) == 3 + 4.im. Not 4.i? Painful.

It took me far too long to even read the stabby proc line of the ‘Splat in Middle’ slide. I’ve never read Structure and Interpretation of Computer Programs, but I know that “Programs should be written for people to read, and only incidentally for machines to execute.”

He already has errata for the ‘“Nested” Methods’ slide.



That’s all I have now. I have to go lie down and take some deep breaths.

2 Responses to “Ruby 1.9, Shmuby 1.sh9”

  1. Piers Cawley Says:

    I like stabby proc. At least, I like what it buys and I’m sure that there were many worse options available to Matz.

  2. Yossef Says:

    I’d prefer to simply do something like

    
    def (a,b)
      a + b
    end
    
    

    And use the return value of that. It could cause a problem if some people depend on def returning nil, but who does that?

    At least one person I know (Phil Hagelberg) doesn’t like the semantics of that because def should mean “define” and you’re not defining anything there. I think that’s a smaller problem than stabby proc, and the fact that worse options were/are available doesn’t make stabby proc better.

Leave a Reply