Friday, November 28, 2008

Three Hours to Ruby

Hey, lazyweb, I need your help.

I'm just about done teaching a series of classes on Bash scripting for the systems admins where I work (mostly junior types). I present a one hour course every other week, focusing on the basics that they'll be able put to use right away.

Pretty soon, I'm going to start a series of similar courses about Ruby. Here's the rub though, I'm not sure where to start. If you had three or four one hour blocks to get a group of junior to mid-level sys admins going on Ruby, what would you focus on?

5 comments:

Sebastian Yepes F. said...

I think one of the most important points is a good understanding of the IO Class, specially to make scripts that are able to execute external shell commands and the possibility of manipulating the stdin,stdout and stderr IO streams of the commands.

Hope on seeing this post, regards.

glenngillen said...

If they're sysadmins then an intro to puppet, or some scripts out of the enterprise scripting with ruby books might be the best place to start

Alan Bailward said...

Probably go with the syntax and "naturalness" of it. While I'm not a ruby-head by any means, as a perl guy, and a sysadmin things like the cool "everything is an object" paradigm don't fall into the usefull-to-the-job side of the desk.

If they're familiar with shell programming with perl/bash/whatever pull in what in Ruby makes it better than $favorite_language and maybe pull in any advantages like the lispy proc() or lambda() or whatever it is.

Speaking for myself, sysadmins gravitate to what they know to get the job done. If I need to say, export a database table to a CSV file I can whip something up in perl in a few minutes using Class::DBI and a while loop or three. Show me how to do it more easily in Ruby and they'll be all yours.

Mark said...

I would recommend starting with the irb. If they can grasp the irb, it will help them learn the language more effectively.

elg said...

I agree about IO - ruby is my go-to language when I need to whip up a simple homebrew test client or server in sysadmin tasks.

As a sysadmin, I find the text manipulation features the most helpful. You know, the sort of thing perl is supposed to be perfect for, but without all the cruft. Do some readability comparisons with some perl code.

Cover arrays, hashes, and YAML. Cover map, inject, select, and friend.

As someone already mentioned, irb and ri are vital tools.