Tuesday, May 1, 2007

Rails Developers Need Computer Science Too

This is kind of ironic, given that I have no degree in anything myself, but Rails developers with degrees in comp sci have an advantage. The complex stuff is useful much more frequently than people usually realize.

On the ruby-talk mailing list, there have been a couple examples of this which revolved around sets. Sets are a standard mathematical concept taught to children with Venn diagrams.



The first example came when people were trying to do set math with arrays when translating Peter Norvig's short Python spell-checker into Ruby. Translation is cool, but changing from sets to arrays just didn't seem logical to me at all. (To be fair, I don't actually know if it makes a difference in terms of performance.) The second example referenced this blog, where a happy Dr. Strangecode learned to stop worrying and love the standard library.

Wow, am I sounding pompous today. It makes a difference, though. In the long term, shortcuts don't lead to increased readability, increased performance, or increased ease of maintenance, and you want all those things. Also, the Norvig Python spell-checker had to import Python's collections. To use Ruby's Set, you need to require 'set'. So it's not even translation in that instance; it's a nearly literal and exact transliteration. The only explanation for not requiring Set in that case is ignorance of its existence.

It's sad but true; if a Ruby programmer learns the standard library, they've distinguished themselves in the marketplace. They've acquired a powerful competitive advantage. This wasn't true a year ago. It makes Rails' popularity bittersweet.

The good news is, if you want to learn the standard library, there are easy ways to do it. One is to read the docs. Another is Hal Fulton's excellent book The Ruby Way. And the best news of all is that if you were programming Ruby before Rails, that's not just a competitive advantage; at this point it's practically a gold mine.

4 comments:

  1. I'm sure I'm not alone in wishing that Ruby had a rich collection hierarchy akin to Smalltalk's.

    However, I don't want it so much that I'm prepared to get off my fat arse and implement anything.

    ReplyDelete
  2. Hmm. I can't say I know the collections hierarchy in Smalltalk as well as I'd like. In fact it's the major frustration with Smalltalk for me, I find things so easily in other languages and Smalltalk regularly has my scratching me noggin goin Hmmmm.

    Anyway, you've probably got a point there, given that Smalltalk has a good decade or two head start in the libraries department, but the whippersnapper's not down for the count. Ruby handles so many things beautifully with iterators that I feel pretty comfortable letting it off the hook as far as collections go.

    ReplyDelete
  3. (...mainly because I'm just guessing anyway.)

    ReplyDelete
  4. You'll probably find what you're looking for easier if you open the Package-pane Browser. I'm using Ramon Leon's image. It may be the same for yours. To get to it I open the World menu, go to "Open...", and select "package-pane browser" from the next menu. This browser organizes the classes by packages. Just look for Collections there. They'll be in one place.

    In a normal browser you'll notice that most categories have names in a [name1]-[name2] format. [name1] represents the package name.

    ReplyDelete

Note: Only a member of this blog may post a comment.