Working with Unix Processes, Testing and Shopify

17 Dec 2012

Michael Brodhead talks to Jesse Storimer of Shopify about his upcoming book releases, and the company's roots in Rails.

  • 0:45 All about Jesse
  • 4:00 Where Jesse started
  • 9:00 Upcoming projects, including writing about threading
  • 11:45 The importance of testing
  • 14:00 The process of self-publishing
  • 17:45 Shopify's roots in Rails

Jesse on Twitter: https://twitter.com/jstorimer Jesse on GitHub: https://github.com/jstorimer Jesse's website: http://jstorimer.com

Links Working with Unix Processes: http://workingwithunixprocesses.com/ Working with TCP Sockets: http://workingwithtcpsockets.com/ Shopify: http://www.shopify.com/ Teamviewer: http://www.teamviewer.com/en/index.aspx Textmate: http://macromates.com/ Vim: http://www.vim.org/

Michael Brodhead: Hello, welcome to Cloud Out Loud. I’m Michael Brodhead from Engine Yard and today I’ve got Jesse Storimer who is the author of Working with Unix Processes, a Ruby book and the author of the forthcoming book called –

Jesse Storimer: Working with TCB Sockets. It’s actually out as of about two weeks ago.

Michael Brodhead: Oh, how would I miss that? I’m on – even on the mailing list.

Jesse Storimer: You should’ve gotten a message. I’ll forward it to you after.

Michael Brodhead: I’m gonna have to yeah, get online and buy myself a copy. I thoroughly enjoyed the first book.

Jesse Storimer: Thanks.

Michael Brodhead: Wanna start by telling us a little bit about the new one?

Jesse Storimer: Sure. So, the new book is called Working with TCB Sockets and traditionally with my first one which is about doing stuff with Unix processed in Ruby, you can apply the same kind of approach to doing socket programming in Ruby because Ruby – as much as we love doing high level stuff like web frameworks and test frameworks and stuff like that, Ruby kind of paralyze a pretty good interface to system calls like for working with sockets. It does give you access to all the lower level stuff and gives you nice DSL’s and nice wrappers for doing that at a high level.

So, the book covers little stuff you can do in Ruby or Go or C pretty much in any language like the really primitive level stuff and I go from there and I go up but you don’t really have to think about all that stuff and you don’t have to get all those steps exactly right and then I also go into some more advanced TCB stuff and different ways to organize your programs if you’re using threads or sockets or different kinds of concurrency.

Michael Brodhead: Cool, the one thing that I found in the Ruby world is that a lot of developers are not familiar with the lower level stuff, the process managements, the sockets, and are even hesitant to delve into that and so it’s good to have a Ruby centric introduction to it because I think most people want to read Stevens or whatever.

Jesse Storimer: Yeah, yeah, most people kind of started out like me. I started programming on the web and had to learn PHP and I learned some really high level stuff. I started learning Rails and I never learned C, or low level stuff I just kind of skipped over it and I think that’s true a lot of people who do it really today and like you said the Stevens books are great but you really have to at least be able to read C to understand them and they’re also each about 1000 pages, each of his books.

Michael Brodhead: Yeah, they’re huge and I certainly have not – the two that I have not gone near cover to cover, they’re references rather than things I sit down and read. How long is the new book?

Jesse Storimer: It’s about 180 pages. If you look at the word count, it’s about the same as my first but I threw in more code in there so it ends up being a bit longer.

Michael Brodhead: Makes sense, yeah because it was very pleasantly digestible. I was very pleased when I got it. I was like oh, I can crank through this whole thing in a reasonable amount of time without getting distracted and off on some other book or some other project. It’s nice to see the trend towards the shorter books.

Jesse Storimer: I totally agree. It’s nice to be able to sit down for like an afternoon or an evening and learn something new and like you say, not go down tons of tangents and people are catching on even pragmatic programmers has a new line of books. I think they call it Pragmatic Express that are about the same length. They’re very focused and short so I think this is the new thing with eBooks.

Michael Brodhead: Yeah, it’s definitely a trend that I like. Well, let’s go backwards a little bit. Tell us about how you started, what your background is, and how you found your way into programming.

Jesse Storimer: Sure, where do I start? I really didn’t do any programming I think until I guess university. I came from a small town and had a very basic programming course in high school but when I was a teenager, I wasn’t programming basic at age ten or anything like that. I was just playing video games and using computers and I started doing programming in university and really enjoyed it, did some Java, mostly Java and then I work for Shopify right now and I actually work for the administrator at school that came into the presentation at the university about Rails and I was so enthralled.

I knew I had to work for them and do more Rails so I ended up doing that and I got into writing the books after doing even a couple of years of Rails there and so I had a good understanding of that level of the stack but in wanting to understand better about the lower parts of stack and helping and optimizing the performance and stuff, I started looking at the internals of our web servers and rescue and a couple of other projects that may use some stuff I’ve never seen before and that got me really intrigued and looking around and so I think the story goes that if you’re looking at stuff like Unicorn and Resque, they’re using system calls like fork and exact and doing signals and stuff I haven’t seen before and the Ruby documentation was really poor about that kind of stuff.

So, if you’re looking at many pages and like you say Stevens’ books and various other sources, I kind of grew my understanding of that level of the stack and I knew that people wanted to learn that stuff or at least lots of people should learn that stuff but like you say, they’re kind of afraid to look there and that’s really what inspired me to write the book was this is what I really needed a year or two earlier to understand stuff at that level.

Michael Brodhead: Yeah because if examples are written in a language that you haven't developed in then you feel dumb when you read the examples so you tend to not to want to do it and I know I had that experience too and even I used to do C programming, it’s been so long that I feel a little dumb when I read C code and I have to fight this resistance. So, yeah it’s cool to see the stuff laid out from a Ruby’s prospective. I actually I could’ve used that TCP book about two months ago. Actually just finished a project with lots of TCPIO and actually I have a request for your next book although you probably have plenty of your own ideas.

Jesse Storimer: All right.

Michael Brodhead: TTY’s.

Jesse Storimer: Yeah, that’s something that I know how to do a little bit and there’s very little documentation in Ruby about how to do it and I haven’t fully understood how to translate the other stuff I’ve read into Ruby specific stuff so that’s something that somebody should write about. Maybe I’ll put up a couple of blog posts about it or something because I know you can do some pretty cool stuff with it.

Michael Brodhead: Yeah, so we made an SSH proxy as it turned out that nothing out there did quite what we needed and yeah, the TTY stuff ended up taking a long time and there was a lot of just muddling through --Martin Emde who did the bulk of that work, a lot of stuff he just had to do by trial and error because there weren’t good docs for him.

Jesse Storimer: Yeah, interesting.

Michael Brodhead: So, seeing as you’re not going to write the exact book that I want you to, you just met me today and I think you should be writing the books I ask for. What is in the hopper, what’s coming up?

Jesse Storimer: So, there’s a couple of writing projects that I’m interested in right now. One of them is I started a series on my blog months ago now. It’s called A Unix Shell in Ruby. So it was creating something kind of like bash but it hit Ruby so the ideas was to learn how to fork and exact, when you want to spawn a process and how to manage processes like on the shell when you just want a command and present it in the end, push it in the back ground, you can pull it back to the program, push it in the background so I want to learn more about that kind of stuff and share how to learn about your shell by implementing instead of just showing you a bunch of example commands.

So, I made a few articles in that series and there’s a few more that I need to finish it. Though I’d like to do more on that and the other thing that I’ve been writing about – this is probably because I spent last week at RubyConf, and as always at RubyConf the hot topic is threading. So, the alternate implementations like JRuby, and Rubinius, offer real parallel threading with no global lock whereas MRI does offer need of threads but they don’t work the same way because of this global lock and I know a lot of people don’t’ fully understand what that really means for doing threading and the same reason that I talk about processes or sockets, threads are kind of a lower level thing that people are kind of afraid of.

A lot of people say oh threads are hard so I don’t use them so I really love to kind of clear up that space and show people what they can do with that.

Michael Brodhead: That would be awesome. There was a similar, even when I was a Java developer there was a similar mindset about threads there and O’ Reilly came out with a book that was just about threads and just explained stuff really clearly and succinctly and it took a lot of the fear away and was just able to do stuff and yeah, there are challenges but a lot of it is just you understand how the things work and then use those tools correctly rather than just forging blindly and you do pretty well.

Jesse Storimer: Yeah and that’s something that I’ve heard people who have read the books that you don’t have to use the stuff right away or use it every day. Just knowing what’s going on underneath gives you more confidence. You aren’t afraid to look there anymore. It’s funny that you asked about next projects because this is the first time I’ve mentioned that so this is like an exclusive announcement.

Michael Brodhead: And you’re exclusive, you heard it here first folks on whatever day this comes out two weeks from now. Cool, do you have any kind of timeline for that or are you just getting rolling?

Jesse Storimer: I’m doing a timeline estimation to know that I shouldn’t estimate timelines so I won’t say anything.

Michael Brodhead: So, writing books is like writing software in that respect then?

Jesse Storimer: Absolutely, yeah, except with writing, you can end up with writer’s block which is harder to get out of than rather if you end up with you separating coding you can always write a test or usually go somewhere else and writer’s block is sometimes harder to get through. So, don’t want to make any promises.

Michael Brodhead: Yeah, it’s comparatively recently that I was introduced to the idea of tests as overcoming writer’s block and it’s really interesting how it works that the test can not only be a way of making the code more reliable but just a way of springing me to action.

Jesse Storimer: Yeah, absolutely I find that keeping the tests, people like driving near with your design of tests, I find tests is just like a flow of keeping things moving so I’m not just sinking or sitting stuck in a place. The test will keep you moving forward.

Michael Brodhead: Totally. Yeah, actually I had the experience just a couple of months ago where I was just staring at a screen and because it wasn’t runtime code, it was some offline thing that was only gonna get used a couple of times. I was not writing tests and was just kind of stuck and another guy I worked with had some free time and sat down and said. Why aren’t there tests? Let’s write some tests. He got pulled away after only 20 minutes but just the fact of having the test, open the floodgates and all of a sudden the code was easy to write.

Jesse Storimer: Yeah. I think it’s especially important on – okay, I work on Shopify which is a large Rails app. Running a test can take a number of seconds. So in a situation like that, actually been using this really cool tool that came out, came from one of our guys called Zeus which uses PTYs and forking to load your – it rails out in a kind of like a parent process and then you run a test or open a console or something, it works off at child process and hooks you up to a terminal that are – so you can get your application or get a test running in like sub second time as opposed to waiting for a few seconds. Which really would let me get back into that fast test feedback loop, the really good –

Michael Brodhead: That’s awesome. I just made myself a note to check it out. Yeah, especially with JRuby because you’ve got that JVM startup overhead, the few times that I’ve started developing in JRuby, I’ve looked at how fast it takes me to run my test and I’ve said oh, another time, back to MRI. So, tell me a little bit about self-publishing and how that’s worked out and have you considered going to a mainstream publisher or you wanna stick with this approach?

Jesse Storimer: I’ll tell you how it’s worked out, on my blog at jstormer.com, I’ve published some revenue numbers in the past, anybody that’s interested in seeing how it’s actually doing financially – I’m always really flatters that I can go to somewhere like RubyConf and meet people who have read this thing that I wrote and said that they learned something. I look at it as some really fun for me that way. In terms of self-publishing versus traditional publishing, I’m not really against traditional publishing but I enjoy self-publishing so much. I enjoy the talking to people. I enjoy putting up the sales page. I enjoy doing the marketing. I kind of take pride in the whole thing, top to bottom was me. So in that way, I’m not really looking to partner with traditional publishers. Also, I’m kind of scared by people who say that the royalty rate, if you work with someone like O’ Reilly, it’s 10, 12 percent or 15 percent if you get a great deal whereas the work that I’m doing, I don’t have the kind of reach that they do but when I make a sale, most of it comes back to me. So that’s really rewarding, too. In terms of working with publishers, I was able to get my first book distributed through Pragmatic Programmers. They set me up a good deal where I’m on their store and they sent a newsletter around to their readership, toting my book but I didn’t actually work with the editing team. I didn’t actually go through that whole process but I kind of get some of the benefits by just being distributed by them.

Michael Brodhead: I know for a lot of people, it’s that would much rather have an electronic edition of the book anyway because now it doesn’t take up any space in my bag if I wanna go back and refer to that. I don’t have to put it on a shelf. It’s just on my iPad all the time. It was pretty great. So yeah, it seems like it’s getting more and more viable to just not bother with that and do it directly. I love the hiring your own editor because you still get the advantage of it without giving up all the control.

Jesse Storimer: Yeah, and as a self-publisher, it’s really the electronic distribution, that makes it possible like if I had to print copies or keep them at my house or ship them off, it would just be a lot more daunting. It’d be a lot harder to get started. This really – if you wanna write an e-book and distribute it, there’s really on startup cost. Like, you write the book with free tools. You can generate it with free tools and then open source tools and then you got your book and you may have to pay a little bit to get an e-commerce account somewhere but really, it doesn’t cost anything to write a book.

Michael Brodhead: And I imagine you know a little something about interfacing with the e-commerce companies?

Jesse Storimer: Yes, it’s been a fun experience for me working at Shopify, an e-commerce company. I run my sales websites off that platform so I’m getting to experience the software as users would suggest, which has been a good experience for me and helps me make better decisions and all those kinds of good things. I would always use the software you work on.

Michael Brodhead: Yeah, dogfooding is definitely the way to go. So, you mentioned that Shopify was an old Rails code-based – how old is it and what version of Rails did it start on?

Jesse Storimer: I don’t have the definitive answer because I wasn’t there at the beginning but I can tell you that I know that Shopify started in 2004 when the first line of code was written and I believe Tobi Lutke, he started writing it like more or less the day that Rails was publicly released. He was in Europe at the time and he had a connection with someone who said hey, check out this Rails thing. And I think he had started writing Shopify in Java. He at least had the idea to do it, oh, wow, this is amazing, I’m abandoning what I have and I have to start using this. He joined the Rails core team and did a lot of work on Rails every day so that he could write Shopify. I mean the application, the Git history goes back to that day so it’s like 7 or 8-year-old app now.

Michael Brodhead: Wow, that’s crazy. Yeah, I don’t know of another app in the Ruby world that’s that old. So, what version are you guys running on today?

Jesse Storimer: Yeah, we’re running right now on 3.0 so we did a big push when 3.0 came out to upgrade from 2.3 I guess, to 3.0. I think 3.1, you’re looking at upgrading and then had some performance hits we didn’t wanna take and now we’re just kind of – haven’t had the time to focus on the 3.2 upgrade.

Michael Brodhead: What city are you based in?

Jesse Storimer: We’re in Ottawa, in Canada.

Michael Brodhead: So you work actually physically in their office?

Jesse Storimer: Myself, no. I’m mostly remote. I’m kind of like – I live in a rural area around Ottawa. I’m about a little over an hour away. So I’ll go in if there’s something that’s calling me in but for the most part I stay at home, it’s easier for me, less commuting and I’ve got a young family here. I guess spend a little more time with them.

Michael Brodhead: Yeah, especially when there are little kids, it’s nice to be around for that.

Jesse Storimer: Oh, yeah. It’s great to have the flexibility.

Michael Brodhead: Yeah. So do you mostly code solo? Do you do remote pairing?

Jesse Storimer: I would say mostly code solo. I haven’t had a lot of success with remote pairing and that may just be that I haven’t tried the right tool. I’ve been working a lot lately with a guy from India which has been interesting because we’re in a very almost opposite time zones so we end up either chatting late at night or early in the morning and it’s kind of the opposite for the other guy and we’ve done a bit of remote pairing but I just find the network latency makes it really hard to do. Mostly we just do pull requests or we’ll chat on Skype and code or something but we did most of our discussions through pull requests.

Michael Brodhead: Oh, interesting. What editor were you using for the pairing?

Jesse Storimer: We were using an app called Team Viewer. It was just kind of like a shared screen thing so we’re using Textmate. I haven’t tried the – I’m a Vim user so I haven’t tried the SSH into a shared box. I’ve heard that that works pretty well for people but I’ve never met another guy who uses Vim that I need to pair with.

Michael Brodhead: Interesting. Vim seems pretty popular around here. Personally, I just switch from Textmate to SublimeText but did a little bit of pairing with over SSH using screen and Emacs which was okay except my EMac foo was really rusty and the guy I was working with had a bunch of new custom cool Emacs stuff that meant that even didn’t wanna remember didn’t work like I remember it worked but an approach that’s worked well for me so far in the few times I’ve done it at least if it’s Mac to Mac, it’s using Apple’s native screen sharing stuff and it seems pretty snappy. The person on the remote end reports that they could barely notice the latency.

Jesse Storimer: Is that through iChat?

Michael Brodhead: Yeah, iChat or in the new OS they call it Messages but it’s the same thing. What I assume is happening is because it’s all the same OS, they can make certain optimizations that just intercepted at the API call layer.

Jesse Storimer: Interesting. I will give that another try and maybe that’ll work better.

Michael Brodhead: But then again it was within the United States so you know there’s –

Jesse Storimer: Right. My comparison point was Skype screen sharing is so-so.

Michael Brodhead: Yeah. Well, I am about out of questions. Is there anything I should’ve asked that you wanna trumpet?

Jesse Storimer: I don’t think so. You’ve got all the good stuff out of me.

Michael Brodhead: Leaving you as an empty husk. Cool, well thanks a lot for your time. I appreciate having you and yeah, soon as we get off this call, I’m gonna go get your new book and spend some time reading it this weekend.

Jesse Storimer: Awesome, appreciate that.

Michael Brodhead: All right, thanks very much. Have a good one.

Jesse Storimer: Okay, take care.