October 31, 2013

RECTO: How to Program at a Startup

Print More


It’s 11:15 p.m. I look outside my window overlooking College Avenue and note the eerie quiet, the lack of people, the still-crisp summer night.

I turn back to my computer, and on my screen there’s a PDF that I’ve been wrestling with for the last two days. It’s supposed to be a list of grocery items, dynamically generated and populated with data from a customer’s order, but it’s not quite perfect. The page breaks are, well, broken, and the rows on the table have inconsistent heights. I entertain the thought that, hey, maybe this PDF doesn’t really need to look all that good, and that what’s important is that this thing is functional…

I sigh. It’s not good enough for me. I realize now that trying to generate a pixel-perfect PDF from an HTML document was probably not a good idea. I curse the CSS gods that be, scratch my temple, and open yet another tab of Google, hoping for some sort of answer.

I look over the table next to mine and see our CTO, Mike, with brows furrowed, typing away. He catches my look and understands immediately.

“Maybe you should try Prawn?” I Google Prawn and find that it’s a library perfectly suited for the sort of PDF generation that I’m trying to do. It’s conveniently supported by our software stack and is written in Ruby, a language that I’ve used exactly zero times in my life. I hastily decide after a few more minutes of searching that I have found my solution and that I should learn Ruby so that I can rewrite this whole thing from scratch. Feeling a mix of desperation and adventure, I also decide that I want to do this right now. This PDF feels like an itch on my mind, one that won’t go away until I finally get it right — the all-the-way kind of right, not the halfway-there, kinda-sorta right.

It’s a little past midnight and I’m not tired at all. Most people have left the office. I read an article called “Ruby in 20 minutes.” It’s a start.

Thankfully, Ruby turns out to be really similar to Python, a language that I do know in a little more depth. A lot of the constructs are the same, and even the syntax, too, is familiar. I immerse myself in documentation deep into the night, typing up expressions in the Ruby interpreter, reading articles about how to use Prawn and how to get it to do the things that I want. I fall into a sort of haze: my eyes glaze over and my eyelids droop a little, but my headphones are on my ears and the world falls away, lost to a lot of brow-furrowing, intermittent chin-scratching and relentless typing. In Prawn page breaks work, right out of the box. Tables are supported nicely. I want to bang my head on the table for trying to use HTML for this task first, but I don’t have time for that since there’s more code to write. On occasion I got up to pace and look out of the window a little. I can tell the sky is getting lighter and lighter.

At around 6 a.m. I have a (fully) working PDF. In the space of a few hours I learned enough of a new language and a new library to (finally) accomplish my task.

I sit back on my chair. Outside, the sun is breaking through, and the first few people to wake are walking up and down College Ave., starting their business for the day. I’m feeling tired now. My eyelids are heavy to the point where I can’t keep them up anymore. But I feel oddly satisfied, like an itch has been scratched, and I doze off wondering what new challenge is next.