Hack Night: A Refreshing Change of Pace

2012-03-23
4 min read

I attended the Chicago Ruby Hack Night meetup last tuesday. The theme was IronMQ, a message queue web service. You can post/get/delete messages through a set of super simple HTTP endpoints, and they handle the tricky (or at least boring) stuff like storage, retries, etc.

Honestly, I almost didn’t go. I know that exposure to new technologies is good for me, but usually I have a hard time justifying messing around with something that doesn’t relate to a bigger project (be it professional or personal). Boy was I surprised! Hack nights have a number of benefits I hadn’t anticipated.

Pairing with Strangers

Paired programming is the fastest way to learn about new (to you) workflows and efficiencies. Everyone spends time customizing their environment to make things easier, but it’s interesting to see what others optimize, their go-to code constructs, and the tools and resources they’ve adopted. Pairing with a coworker is a great start, but after working together for a while you’ve probably assimilated many of each other’s tricks. Pairing with someone who works on different problems and different systems is a great way to get off the beaten path and discover answers to questions you didn’t even know you had.

Iteration

Hack night is all about getting something DONE. You have a fixed amount of time, and as this is an exploration, you probably won’t be getting back to it anytime soon. It sucks to go home a couple hours later without having accomplished anything, so hack night encourages you to work purely iteratively. I found myself working on almost infintesimally small changes, going from one working prototype to the next. WHAT you accomplish isn’t as important as just finishing SOMETHING.

Constraints

The most surprising and freeing aspect of hack night was the vastly different set of constraints. Working on a bigger project, I have to think about business requirements, clean code, the future… Those are interesting constraints, but being able to drop all external considerations and focus on simply writing cool code was a joy I haven’t experienced probably since high school. That probably says more about me than it does about hack night :)

More constraints

While we’re on the topic, hack night not only freed me from my normal daily constraints, but also introduced new ones - in a good way. A certain amount of constraint actually enhances creativity; think about drawing something on a blank piece of paper (the infinite possibilities are intimidating!) vs a paper with a few marks on it (maybe sparks some initial ideas). This hack night was focused on IronMQ, a messaging service. We entered the evening with no idea what a messaging queue was, and even less idea what one might be able to do with it - a complete reversal of the usual situation, where you know the problem and need to find the technology. We had to put a project name in IronMQ, so we just called it buttsniffer. Why not? Ultimately the combination of the project name and the messaging service led us to create a chat client for dogs (so called because we named our chatters fido and red rover). There’s absolutely no way I would ever have come to write that app myself outside of hack night.

Tangential takeaways

I learned a little bit about messaging queues, but the most interesting thing I ended up taking away was a technique for both printing to and reading from STDOUT/STDIN at the same time (a clear requirement for a chat client). Here’s how it goes:

reader = Thread.new do
  while true
    # get messages from the friend I'm chatting with
    msg = reader_client.messages.get()

    if msg
      p msg.body
      msg.delete  # remove it from the queue because we've handled it
    end
    sleep(1)  # don't kill the CPU
  end
end

while true
  outgoing = STDIN.gets  # wait for input

  # send my message to the queue for my friend to pick up
  writer_client.messages.post(outgoing)
end

The problem is that STDIN.gets is a blocking call that waits for STDIN before letting the program continue. Putting the printer in ts own thread lets it continue printing while the main program waits for input. Simple but effective.

Conclusion

Hack night ftw!