Categories
Uncategorized

Ruby Foo

ruby foo

After three years away from all but the most trivial of noodling with the Ruby programming language, I have become a Ruby Foo (as in Mr. T’s catchphrase, “I pity the foo’!”). I am severely out of practice with Ruby, and with two versions having appeared since I last made a living with Rails, even the act of creating a new project is completely different. Since Ruby is the preferred back-end programming language at Shopify and I am the Platform Evangelist, it’s time for me to “sharpen the saw”.

obie

Luckily for me, I ran into Obie Fernandez at the South by Southwest Interactive conference back in March. We sat down for a coffee and he told me about what was happening with Hashrocket and I told him that I was a hair’s breadth away from joining Shopify.

“I’ve been away from Ruby long enough that I’m probably back at newbie level again,” I told Obie between sips of latte made with overcooked beans. “I did it for a bit at the beginning using IronRuby, but between doing all the C# and PHP and the open source ‘Iron’ languages dying of neglect at Microsoft, I’m severely out of practice. I thinking of joining Shopify, and let’s face it: I don’t want to look like an ignoramus in the presence of rock stars like Tobi, Cody and Edward.”

“Give me your email,” said Obie, “and I can do something to help.” Of course he could – he’s the series editor of Addison-Wesley’s Professional Ruby series of books.

Shortly after South by Southwest, a couple of links to PDF editions appeared in my inbox. Thanks, Obie!

eloquent ruby

The first link was to Eloquent Ruby, Russ Olsen’s guide to speaking idiomatic Ruby and getting the most out of the Ruby programming language. It’s a breezy read, written in the same conversational tone that Olsen used in Design Patterns in Ruby, and the book is broken down into 31 bite-size chapters about a dozen pages in length. Each chapter’s title is some principle for programming eloquent Ruby – the first few are “Write Code That Looks Like Ruby”, “Choose the Right Control Structure” and “Take Advantage of Ruby’s Smart Collections” – and each explains that principle, provides code, shows you where you can find the principles used in actual, working projects. The book straddles the line between tutorial and reference; it’s written in tutorial style, but it’s organized so well that it might as well be a reference for those parts of Ruby that you might not use often (but should) as well as for those parts you keep forgetting (in my case, I always end up having to look up metaprogramming). I’ve been going through it at about a chapter an evening, and I’ve been getting smarter each time. Whether you’re coming back to Ruby after a hiatus like I am or if you just simply want to get better at Ruby, you should have this book in your library.

If you’d like to know more about Eloquent Ruby and its author, Russ Olsen, check out this interview with him at InfoQ.

ruby on rails 3 tutorial

I have yet to properly sink my teeth into Ruby on Rails 3 Tutorial but a quick scan of the book has shown that it’s quite promising, and the Amazon reviews are bolstering my belief.

I’ll be writing from time to time about my return to Ruby and Rails in this “Ruby Foo” series of posts, and I hope that whether you’re new to the language, returning after a break like me or aiming for “guru” status, that you’ll check out this blog regularly for notes on my explorations and what I’ve learned.

This article also appears in the Shopify Technology blog.

Categories
Uncategorized

Going to Toronto for Ruby Job Fair and Portland for BarCamp

Airplane wing

Some of the Shopifolks are travelling this weekend to some interesting events.

rspec::table, a.k.a. The Ruby Job Fair (Friday, May 20th)

Rspectable employment

If you’re in the Toronto area and looking for a job, you might want to drop by rspec::table employment, otherwise known as the Ruby Job Fair. Our friends at Unspace are holding this event, where Rubyists seeking employment can meet with potential employers.

It’s the third such event put together by Unspace, and it’s specifically aimed at those programmers who’ve eschewed more mainstream programming languages and frameworks for the Ruby, Rails and other Ruby-related goodies because, let’s face it, they’re fun. And hey, we believe that if you’re going to spend your working life — half your waking existence — doing something, it had better be fun, don’t you think?

Have you considered developing for Shopify? Think of it: we’re growing start-up that’s actually profitable, and that was before we secured that Series A funding. We’re in the business of helping people sell stuff online, a field whose growth is strong and steady. We’ve got some killer coders in the shop; I feel like the dumbest guy in the room when I’m around them (I’m okay with that — it has its advantages). The perks of working here are great, from the people to the gear and welcome swag to the location — not some soul-draining industrial park, but in Ottawa’s ByWard Market: central, and the liveliest part of town.

If you’d like to get a job with us and in on some of this action, come on down to the Ruby Job Fair this Friday, May 20th at Unspace’s office (342 Queen Street West, Toronto, east of Spadina, above LuluLemon) from 5:30 p.m. to 7:00 p.m. and say hello to the Shopifolk who’ll be there: Brittany, Edward and Julie!

To find out more about the Ruby Job Fair and the after-party, visit the Ruby Job Fair site.

BarCamp Oregon (Friday, May 20th – Saturday, May 21st)

BarCamp Portland logo

Shopify is one of five startups that makes up the BarCamp Tour, a group helping sponsor BarCamps all over North America. Thus far, we’ve been to BarCamp Boston and MinneBar (a Minneapolis-based BarCamp serving all of the state of Minnesota). This weekend, we’ll be at the third BarCamp on the tour: Portland, Oregon, affectionately known to some as Portlandia:

BarCamp Portland is an unconference: a conference whose topics, sessions and schedules are determined by the attendees. On the start of the unconference day, people will propose session topics and set up a schedule, after which the unconferencing will begin. We’re expecting geeks of every sort to show up: not just the hackers, but artists, engineers, hobbyists, writers and poets, jokers and journalists, entrepreneurs, cooks and bakers, people who till the land or help neighbourhoods take shape, and anyone else who likes create.

Shopify, along with our partners on the BarCamp Tour — BatchBlueGrasshopperMailchimp and Wufoo — isn’t your typical event sponsor. Yes, we’re each throwing in money to help BarCamp organizers hold their events, but we’re also there at the conference, actively participating, joining in the discussions, providing food and drinks, and even helping carry stuff or clean up. We’re also there to promote our companies, but not in a hard-sell way — we’re there to meet people who want to use our software and services, have questions and get to know the creative, inventive, ambitious people who attend BarCamps!

I’ll be there, helping out, facilitating sessions, answering questions about Shopify and playing accordion (of course). If you see me, please say hi!

To find out more about BarCamp Portland, visit the BarCamp Portland site.

If you’re interested in finding out more about BarCamps, watch this video, taken at one of the first BarCamps in San Francisco:

This article also appears in the Shopify Blog.

Categories
Uncategorized

rspec::table Employment (or: Ruby Job Fair)

Rspectable employment

It’s Ruby Job Fair time! This Friday, May 20th, from 5:30 p.m. to 7:00 p.m., at the offices of Accordion City-based development shop Unspace (342 Queen Street West, just above the LuluLemon store), rspec::table, a.k.a. The Third Ruby Job Fair will take place. If you’re a Ruby developer looking for work, you also want to be at rspec::table. If you’re curious about developing in Ruby, guess what — you should also drop by rspec::table!

Shopify logo banner

Among the employers who’ll be present at rspec::table will be my employer, Shopify. We’re sending a couple of people, including developer advocate Edward Ocampo-Gooding, down to Toronto to chat with developers and see who’s got the chop and the interest in working for the company who’s making the only ecommerce platform that matters. If you’d like to work for one of Canada’s most promising startups (who also recently landed $7 million in series A funding and hired Canada’s best tech evangelist), you should come to rspec::table and talk to Edward about Shopify!

Rails Pub Nite: Bruce Lee holding Rails nunchuks

At 7:00 p.m., the event will shift gears and become a special edition of Rails Pub Nite, the monthly get-together or Rails developers and their friends. This special edition will be an “afterparty” held on Unspace’s rooftop deck, which offers a stunning view of downtown Toronto that gets even more stunning as the sky gets dark. Free food and drink will be provided, and having attended a number of Unspace catered events, I can assure you that they’ll be good. The fun will continue until 11:00 p.m..

By the way, the regular edition of Rails Pub Nite, which takes place on the third Monday of every month, is still taking place tonight at its usual digs: The Rhino (1249 Queen Street West) from 7:00 p.m. – 11:00 p.m.. If I were in town, I’d be there.

If you’d like to attend rspec::table, you need to register (it’s a mere $5.00 to register)! If you want to attend the Rails Pub Nite afterparty, you also need to register (it’s free)! To register, go to rspec::table’s Guestlist page — and hurry before the tickets run out!

Categories
Uncategorized

Maritime DevCon: June 18th in Moncton

martime dev con

If you’re a developer out in the Maritimes, you might want to check out Derek Hatchard’s Maritime Dev Con, which takes place on June 18th in Moncton. It’s a single-afternoon, two-track conference – which means you should be able to take time out to attend it – covering a number of topics including:

  • .NET and ASP.NET
  • Java
  • iPhone development
  • Ruby
  • Python
  • Groovy
  • NoSQL and MongoDB
  • “Rockstar Estimating Skills”

Maritime Dev Con has a registration fee that won’t hurt your wallet – it’s a mere CAD$19!

I’m a big fan of small, regional gatherings like Maritime Dev Con and its western counterpart Prairie DevCon. Each region has its own specializations and needs that a by-locals, for-locals conference can do a better job of serving, and the smaller size of these conferences allows for more back-and-forth between audience and presenter, and between attendees. Support your local conference!

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

Ruby Stuff: IronRuby 1.0, IronRuby Reading and a Ruby Job Fair

Hello, IronRuby 1.0!

ironrubyAlthough it’s been out for the past couple of weeks and might be considered old news, I couldn’t let it pass unmentioned, especially given my history with the Ruby programming language: IronRuby 1.0 has been released!

IronRuby is an implementation of Ruby targeting the .NET Framework and built on Microsoft’s Dynamic Language Runtime, which in turn runs on top of the Common Language Runtime. Version 1.0 is compatible with Ruby 1.8.6; future releases will aim for compatibility with Ruby 1.9.

You can use IronRuby 1.0 to build these sorts of applications:

  • Desktop applications using WPF
  • Desktop, in-browser rich internet applications and Windows Phone applications using Silverlight
  • Ruby on Rails applications (up to Rails version 2.3.5)
  • Good ol’ command-line applications
  • and of course, the REPL (Read-Evaluate-Print Loop) goodness of irb

As of version 1.0, IronRuby comes in two flavors:

  • The one that runs on top of .NET 4.0. The .NET 4.0 framework is the latest version and was released with Visual Studio a couple of weeks ago (you can download it for free here). This is the preferred version, and features goodies such as:
    • Faster startup
    • Compatibility with C#’s dynamic keyword
    • Access to all the new features in the .NET 4.0 framework
  • The one that runs on any earlier .NET, starting with 2.0 SP1. For compatibility with earlier versions of .NET as well as with Mono, you’ll want to use this version.

IronRuby is free in both senses of the word:

  • Free as in beer. It costs nothing – just download it and use it!
  • Free as in speech. It’s open source software, released under the Microsoft Permissive Licence, which is recognized by the Open Source Initiative.

Download icon You can download IronRuby 1.0 from the IronRuby site on Microsoft’s CodePlex site.

Ruby and IronRuby Reading

programming ruby

Programming Ruby, a.k.a. “The Pickaxe Book”, is on every serious Rubyist’s shelf. It’s both a good introduction to the language and a pretty decent reference.

poignant guide foxes

why’s (poignant) guide to ruby isn’t a complete guide to Ruby, nor is it your typical programming book. It’s free, online, the most whimsical programming book you’ll ever read, and it’s been the driving force behind a lot of dynamism and creativity of the Ruby community.

ironruby unleashed

The newly-released IronRuby Unleashed covers both the Ruby programming language, the IronRuby implementation and using IronRuby to mix Ruby and .NET into a Reese peanut butter cup of developer goodness.

Ruby Job Fair 2010

Last year, I attended and wrote about employment.nil?, the Ruby job fair held by Toronto software development shop Unspace. They’re doing it again this year with a different format. Where last year’s was modelled after a science fair (the kind you remember from high school), this year’s is going to be modelled after “speed dating” and will feature 5-minute chats between people looking for work and people looking to hire.

To reflect the new format and pay homage to the Ruby-style naming of the first event, they’re calling it require ‘date’. The job fair will take place in Toronto on Sunday, May 30th in the back room of the Rivoli (334 Queen Street West, just east of Spadina) from 2:00 p.m. to 4:00 p.m.. It will be followed from 4:00 p.m. to 9:00 p.m. with OMGRPNBBQ, a special barbecue party edition of Ruby Pub Nite held at Unspace’s office and rooftop deck (342 Queen Street West, a few doors over from the Rivoli).

  • If you’re looking to hire people or looking for a job and want to attend, sign up here. There’s a small registration fee of $6.66.
  • If you want to attend OMGRPNBBQ, sign up here.

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

How and Where is _why?

why_missing_milk_carton Photo courtesy of "ejc".

A Little Bit About _why

Cartoon foxes from "Why's (Poignant) Guide to Ruby" screaming "Chunky Bacon!"If you were to walk up to someone and utter the seemingly meaningless phrase “Chunky bacon!” and get a smile rather than a look a bewilderment, you could probably mark that person down as a Ruby programmer. That strange two-word combination is seared in the minds of those who have read what is probably the most whimsical programming language book in existence, Why’s (Poignant) Guide to Ruby. The book is one of the strange and beautiful Ruby-related works created by the enigmatic programmer, musician, artist, comic illustrator and wag known only as why the lucky stiff, or _why for short.

whys_poignant_guide

_why’s contributions to the world of Ruby programming are many. In addition to the (Poignant) Guide, some of his goodies that I’ve made use of are:

  • Camping, an incredibly tiny Ruby web application framework
  • Hackety Hack, a “coder’s starter kit” for Ruby, meant to bring back the spirit of experimentation of those days when the BASIC programming language was built into every home computer
  • Hpricot, a parser that’s great at scraping HTML and even parsing XML
  • Redcloth, a library that implements the Textile markup language
  • Shoes, a desktop UI toolkit
  • Syck, a YAML library

_why made it a point to reveal as little about himself as possible, and most of us were happy to indulge him. Most people were happy to simply know and address him as “why”, and in the community, it was a point of etiquette to not try and dig too deeply.

_why Vanishes from the Net

Yesterday, _why’s presence vanished from the web. The places online where you could find him have been taken down. These included:

John Resig has written a lovely “eulogy” for _why, and while I think it’s premature to say that he’s gone forever, it’s still nice to see a nice tribute to him. My favourite part of the eulogy is where John likens _why’s works to a sand mandala:

Sand mandalas are incredibly intricate works of art that take many people many days to construct. They’re very expressive, but fragile, works of art.

After a mandala has been constructed – and displayed – it is ceremoniously deconstructed – which is meant "to symbolize the Buddhist doctrinal belief in the transitory nature of material life."

_why’s entire online presence and code was presented in the sand mandala that was ‘_why’. The person behind ‘_why’ simply decided to move on and close that portion of his life.

I hope that _why’s disappearance is a brief hiatus. The Ruby world – hey, the programming world, the art world, the music world too – just isn’t the same without him.

Finding _why’s Stuff

There’s only one problem with _why’s deletion of his online presence: a number of people have come to depend on his works, particularly his code. The (Poignant) Guide is downloadable from Scribd, and I figure that if it hasn’t happened already, someone will start a Github repository of his code. There’s also Facebook group called Missing why the lucky stiff — let’s hope it doesn’t get all maudlin and support-group-y.

Last but not least, there’s programmer Leah Culver, who commissioned a tattoo from _why:

leah-culver

leah-culver-tattoo

In Closing

I’ll finish with my favourite tweet from _why, which I blogged about a year ago:

when you don’t create things, you become defined by your tastes rather than ability. your tastes only narrow & exclude people. so create.

Categories
Uncategorized

Exceptions: The Airbags of Code

This article also appears in Canadian Developer Connection.

its_okay_i_wrote_an_exception

The trouble with a lot of example code covering exceptions is that the examples are often cases in which you shouldn’t be using an exception in the first place. Consider the classic known as “Someone’s trying to divide by zero” – here’s the C# version:

// C#

try
{
    result = dividend / divisor;
}
catch (DivideByZeroException ex)
{
    Console.WriteLine("Idiot.");
}

and here’s the Ruby version:

// Ruby (works in IronRuby too!)

begin
    result = dividend / divisor
rescue ZeroDivisionError
    puts "Idiot."
end

// You have to hand it to Ruby for picking great keywords for
// exception handling. While C# borrowed Java's "try / catch / finally",
// Ruby went with the more macho "begin / rescue / ensure".
// As Yoda himself would say: "Do or do not. There is no try."

The better approach would be to do a little defensive programming and make sure that divisor is non-zero before performing the division operation. So why do tutorials on exception handling almost always bring out the “Someone’s trying to divide by zero” example?

There are two reasons:

  • It’s simple. It’s only a handful of lines of code.
  • It’s predictable. Set the value of divisor to zero and the exception gets thrown. Always.

The truly exceptional exceptions — I/O errors, timeouts and other things that cause exceptions are a little harder to set up and take more code to handle. Hence the divide-by-zero example; it illustrates try and catch (or rescue in a Ruby block) in a way even the newest newbie can understand.

The problem is that many tutorial authors don’t get any deeper than simply explaining the keywords with simple examples, leading people to misuse exceptions, either as a substitute for checking for preconditions or as an unstructured form of flow control in the style of the much-maligned goto (which in many cases is considered harmful).

Like goto, exceptions are unstructured jumps, which make your program’s flow more complex. Unlike goto, exceptions are computationally “expensive” because of all the extra work involved in setting up and backtracking program flow that comes with a thrown exception.

A good guideline to follow is that exceptions are for exceptional cases. Stuff that you can’t easily predict. You can tell if a division operation is going to result in an undefined result – just look at the divisor! Harder to predict are things like whether a server access will time out or if the hard drive will decide that the moment you’re reading a file is the best possible time to corrupt it. Those hard-to-foresee, believed-to-be-rare, exceptional cases are really what exceptions are meant to handle.

Think of exceptions is as being like the airbags in your car. The idea is that they’re a last resort; they’re no substitute for defensive driving. (Like airbags, they’re also expensive to reset.)

Lee Dumond goes into further detail on the topic of defensive programming as being like defensive driving in an article titled Defensive Programming, or Why Exception Handling Is Like Car Insurance. He cites the “Someone’s trying to divide by zero” example, provides a list of defensive programming strategies that you should consider before coding up that exception handler and talks about those exceptional cases when you will have to use an exception. Check it out!