Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

Thinking Functionally In Ruby – A Great Presentation by Tom Stuart

By Peter Cooper / November 3, 2009

thinkfunc.pngThinking Functionally in Ruby is a talk that British Ruby developer Tom Stuart gave at a recent London Ruby Users Group meeting. In it he covers what functional programming is, why it's a "pretty neat idea," and how to adopt functional programming principles in Ruby. Skills Matter took a video of the entire 47 minute presentation (it's embedded on the right hand side of that page - Flash required.. just been told it might be limited to UK visitors only, if so get the original MP4 file) but there's also a 110 page PDF (1.5MB download) you should have to hand too (with Tom's slides).

minecode.png

I don't like to link to individual presentations on Ruby Inside too often, but in spite of poor audio quality on the video, Tom's presentation is top notch (the slides are particularly good) and Tom covers some interesting topics that I think Ruby developers could do with revising. If you've wanted to stay on the functional bandwagon but have found yourself slipping into imperative ways where you shouldn't, this presentation is worth a watch.

[advertisement] Want the ultimate guide to Ruby 1.9? The Ruby 1.9 Walkthrough is a 3 hour screencast that goes through Ruby 1.9 from start to finish, all aimed at existing Ruby 1.8 developers.

Comments

  1. James Adam says:

    I was there, and can confirm that this talk was really excellent. Everyone knows about 'each', and most people know about 'map', but despite this, I doubt that very many of us are really *thinking* functionally when we're actually solving problems.

    Tom's presentation was clear, informative, and entertaining - I highly recommend giving it your time, if only just for the animated explanation of inject, which was inspired.

  2. raggi says:

    Looking forward to having a look. The image on the page is a bit scary though, although the functional approach may have some advantages, the above example is hideously complex. Part of the complexity comes from a (relatively common) avoidance of local variables. Personally, I think that's an anti-clarity-pattern in this kind of language.

    sub_grid = (x-1..x+1).zip(y-1..y+1)
    sub_grid.count { |x, y| mine_at?(x,y) }

    Two very easy to read lines, combining both functional and imperative styles to form a happy hybrid (IMO).

  3. Peter Cooper says:

    Probably not the best shot I used there, admittedly. There's some really good stuff in the slides though - I just wanted to pick something busy looking to spark the imagination here ;-)

  4. raggi says:

    oops, forgot the other dimensions...

  5. Tom Stuart says:

    Thanks Peter (and James)!

    raggi: I completely agree — see later in the video (page 107 of the PDF) for a sane refactoring of that code using local variables and extracted methods. (Your lines, while certainly easy to read, don't do the same thing as mine!) It's left intentionally messy at that stage of the talk for mundane reasons like fitting everything on the slide and making it easy to show which bits of code generate which values.

    More worrying is the moment when I blithely agree that foldr is "the same as" foldl over the reversed list, which is correct in the context of the example, but only true in general when the function is commutative.

  6. Andrew says:

    BOOO. Video linky no worky!

  7. Todd says:

    Is it just me, or is the first example with the red X 10 times easier to understand?

  8. Jan Wedekind says:

    Inspiring presentation. Somehow I never realised how important the connection between functional programming and parallel computing is.

  9. Chris says:

    Can somebody explain me why I can't see the video?

  10. Chris says:

    It's me again. Seems that all the videos from the London Ruby User Group are private. That make me ask the question how much sense it makes to write a post about it, if only x users (with x < 10 or even 100) of 22041 reader can watch it?

    Nevertheless the slides are really cool stuff.

  11. Peter Cooper says:

    I don't understand. I'm not in LRUG or anything like that but if I go to that Skills Matter page, the video loads on the right hand side. I click play and I can watch it. The video might be private on Vimeo, but you can still watch the embed on the Skills Matter page.

    Or perhaps it's filtering by geolocation or something? I am in the UK after all.

  12. Tom Stuart says:

    The videos do appear to be "private", but AFAIK that's some kind of inverse embedding restriction, i.e. you can view the video when embedded on skillsmatter.com but not directly on Vimeo. But I'm in the UK too, so if there's some kind of geolocation filtering I don't know about it.

    I've put the video file at http://experthuman.com/files/thinking-functionally-in-ruby.mp4 for anyone who's having problems.

  13. Chris says:

    Thanks Stuart.
    I would suggest that there is a kind of geological restriction as I'm living in south of Germany and don't have "permission" to see the video neither on vimeo nor at skillsmatter.com. On skillsmatter instead of the video the following message is displayed: "Sorry. The creator of this video has not given you permission to embed it on this domain."

    But anyway, you put the video on experthuman so that works now. But I hope that any future videos will be available without workarounds.

    Thanks.

    Chris

Other Posts to Enjoy

Twitter Mentions