BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

Jonathan Dahl on Programming and Minimalism
Recorded at:

Interview with Jonathan Dahl by Werner Schuster on Nov 19, 2009 |
16:58

Bio Jonathan Dahl is a developer and entrepreneur. His projects include FlixCloud (http://flixcloud.com), a distributed video transcoding service partnered with On2 Technologies; Tumblon (http://tumblon.com), a site that provides parents with interactive developmental information for their children; and a few dozen consulting gig; he blogs at http://railspikes.com.

FutureRuby isn't a Ruby conference, but a conference for Rubyists. This is a call to order - a congress of the curious characters that drew us to this community in the first place. We have a singular opportunity to express a long-term vision, a future where Ruby drives creativity and prosperity without being dampened by partisan politics.

   

1. We are here at Future Ruby 2009 in Toronto, I am sitting here with Jonathan Dahl. Tell us a little bit about yourself.

Great. I am a Ruby developer from Minneapolis, Minnesota. I do freelance Rails development. I also work on a couple of start-ups, Zencoder which is a video transcoding platform, Tumblon which is a social media site for parents of young children, some open source stuff, and I blog railspikes.com

   

2. About your projects - what is Zencoder?

Zencoder is a video transcoding platform, with the goal of basically handling every level of the video transcoding problem from the low levels of actually processing a video using certain options to the high level of queuing up jobs, scaling across multiple servers, etc, having a dashboard to look at what's going on in your video transcoding engine, video transcoding system.

   

3. How do you use Ruby in ZenCoder?

Just about everything we wrote is Ruby so the Zencoder consists of a Rails application which is the queue, it basically provides the API so you can send a request to Zencoder for transcoding and that is managed with a Rails application, then we have a Ruby application that handles the actual transcoding and it sits on one or more transcoding servers, and gets a job from the queue, does the processing and returns the result of the processing back to the queue.

   

4. So where does Zencoder run, is there a product that I can download?

Zencoder runs on a couple different ways, it is software that we can install we have what we call ZencoderPro, ZencoderCustom, where we will actually set it up configured for our customers and maybe modify it for what they want. And that version can run on dedicated hardware it can also run on Amazon EC2 we have another version called Zencoder DevPay which only runs on EC2, which you can use by the hour, so through DevPay you fire up an instance of Zencoder and use it, one or more instances as much as you want and pay Amazon by the hour for that. And then we have a third version called Flix Cloud, which is a joint project we did with On2 Technologies, who does video codecs like the VP6 codec in Flash 8. And Flix Cloud is entirely a service so you never install anything, you never have to worry about EC2 you just sign up, you get an API token and you pass jobs to your Flix Cloud for trans-coding.

   

5. How does Ruby interact with the encoding software?

Yes, so we didn't do any transcoding in Ruby because transcoding is very CPU intensive and extremely slow and hard to write, so we used Unix transcoding tools, and we basically just interfaced with them with Ruby, in a simple way, not even at a code level, we call to these tools, with whatever options are needed for a particular job. So Ruby is perfect for that, Ruby is slow but when you are transcoding the bottle neck is the transcoding itself. So it might take an hour or a minute or five minutes or whatever to do the transcoding, all written in C, all written in C++, as optimized as they can be. The Ruby time even though Ruby is slow is maybe a tenth of a second to set all that up, so Ruby is a good language for wrapping that.

   

6. Which Ruby version do you use?

I believe we are using 1.8.6 maybe 1.8.7. We are not at 1.9 yet. And actually I think we use Ruby enterprise edition so scratch all that, we use the Phusion Passenger.

   

7. Are there any features in Ruby 1.9 that would drive you to move to 1.9? Or is that not relevant?

I definitely want to move to 1.9, I am excited about it but honestly I am excited more only for just having a better implementation, speed-ups, things like that. There aren't any features right now that I am longing for I guess. The new features in 1.9 that I am aware of like the new stabby lambda syntax, and fibers are interesting but again I guess I haven't had a concrete need for them at this point.

   

8. The other project you mentioned was Tumblon. So what is that?

Tumblon is a website, a social media website for parents of young children, basically between the age of zero and five, children develop at a really rapid pace and develop far more than they do for the rest of their lives, 90% of brain growth happens between those years, 10% happens after that through the rest of a child's life, so we provide information, development of milestones, and recommended resources that we have partnered with hospitals and authors and pediatricians, and child psychologists for our information and we provided it at a very specific level so we know your child's age and we can provide the information at the right time and we also make it interactive so you can record milestones when they happen, you can say on this day or at this approximate time my child accomplished this particular milestone, so you can understand what is going on right now, you can have that for your archives, your memories and then you can also share that along with stories and things like that with family and friends, so we provide a secured blog as a way of getting access to the information about your child.

   

9. Tumblon is built on Rails?

Yes, it's a Rails app started at the end of 2007, Rails and JavaScript.

   

10. What is your experience with Rails? Do you like it? Would you like to switch to Merb?

I did think of switching to Merb and I probably would, still be thinking of switching to Merb had not the Rails 3 change happened. I think Rails is great, I think it is really effective, it has problems and I don't know if it's the best software I have ever seen, but I can't imagine another framework being much faster or more pragmatic to developing, for web applications at least. Merb is interesting because Merb did just about everything that Rails did and it did a lot of what Rails did but a little differently with some other optimizations. But I think it would have been interesting to learn but I think the merger is going to be great for Rails I think Rails is going to come out as a much stronger project after that. I think Sinatra is for me right now probably the most interesting other framework, probably because it is in Ruby so I can apply everything I know from Rails to Sinatra, but it tackles a different problem. Whereas Merb and Rails try to tackle the same problem, Sinatra is useful in other places.

   

11. Which places do you use Sinatra?

An API, a small application, I have used it for a couple of small sites, that just need a few pages. Integrating at a Rack level with the Rails app is really interesting; I haven't done that although on Zencoder my associates did, actually get some significant optimization by doing some of the internal communication directly at the Rack level. So one other thing about Sinatra that I think is really interesting is the idea of stacking multiple small applications next to each other, communicating via HTTP, which you could do with Rails of course but Sinatra is so lightweight it just seams like it would be easier to manage.

   

12. So the appeal of Sinatra is its simplicity or does it have any other special paradigms that it uses or offers?

Probably performance, although I haven't used it for that reason, but I think simplicity is great, Rails abstracts you from some basic things like routing which I like, it's really useful but it's also nice to go to something like Sinatra that doesn't do that. I think it is helpful for developers to explore the problems of building web applications from multiple directions.

   

14. So you have a two minute elevator pitch for it?

Sure, the idea is that programmers fundamentally are writers more like composers or authors than maybe like engineers or mathematicians, so we have to worry about style, the style of the code that we write. So I look at style from two other prospective, writing and music. For writing I talk about George Orwell's essay on politics in English language, which is a great essay on writing style. It talks about what makes good style, what makes bad style, how to write simple, direct clear language that communicates well, but it also connects bad language to totalitarianism, through things like propaganda, basically the idea being bad language, bad speech is hard to understand it makes it hard for people to think for themselves and easier to just accept what is being told. Then I talk about minimalism in music, looking at the development of classical music from simple classical music to bigger and bigger and bigger and more complex and less accessible music in the twentieth century, to a minimalist reaction that is going on right now for the last forty years in classical music. And similarly I think some other thing happened in Rock music with Rock music like the Beatles giving way to hard rock and heavy metal and hair bands and all these things that were sort of big and complex and then punk music was the minimalist reaction to that. So, then I take that and I think both of these things can be applied to programming, in that the best programming style I think is usually minimal, it's simple and direct and it's expressive and that simplicity can be beautiful.

   

15. So what is Rails on the musical scale? Is it Rush is it Ozzy, is it punk? And what is Sinatra?

That is a hard question. I think Sinatra would be more of a punk style, although Rails could arguably be that too, punk had sort of a do it yourself mentality, there is an old kind of famous thing in punk history where a punk fanzine published three cords, here is a cord, here is another cord, here is another cord now go start a band which I think Rails and other dynamic languages or web frameworks have a similar mentality that know a little bit and you can start doing things as opposed to maybe bigger technologies.

   

17. What is the biggest offender in there?

I don't know, ActiveResource was pretty hard to understand, last time I looked at it but that was a couple of years ago. I think Rails 3 is getting a nice rewrite hopefully that will help. But it is also a big complex piece of software and I can say that people should write simple minimal software but sometimes you really do have to introduce complexity to solve a problem and Rails is a big piece of software.

   

18. In your talk you mentioned that you shouldn't do meta programming unless you have to, maybe you can expand on that?

Yes, so I said you don't need meta programming, unless you do, and sometimes you do, and a lot of the beauty of Rails happens through meta programming, Active Record is maybe the biggest example but other places too. I don't know the specific examples but there is a time early in DataMapper's history where it redefines something at fundamental level was on Object or Kernel something like that, and it didn't play nice with Test::Unit and the DataMapper people were RSpec people, I don't know if they didn't know about it or it wasn't as important to them, but a friend of mine who was working and trying to use DataMapper at the time. So I think that meta programming that redefines things at a high fundamental levels, should almost always be avoided and it almost always is avoided, I think the examples of places where it is not are few. But just adding functionality, adding methods especially important to well understand things like Active Record does. I think it is a good use of meta programming.

   

19. Do you like open classes, or do you suggest that you don't use open classes or what's your advice?

I do like open classes, I just don't think they should be used often. I think they give developers power and I don't think that is a bad thing. But developers need to be responsible with that power.

   

20. Another topic you mentioned is the model view controller pattern that might in some cases degenerate to too big models or too thin controllers, or something like that.

Sure so the most basic level of model view controller theory is your use should be stupid, you shouldn't have logic in it, you just present the information. The next step is that your controllers should not be too smart, they shouldn't be too fat, they should do their job of governing interaction and that's it, so from there you get to the point where all the logic of the application is in the models which I think is ok, models should be where business logic resides, but models can get fat too, the reason for that is I think because we tend to put all logic in models and anything that is not really business logic, that's more shared logic, user authentication, search, things like that. It's not business logic, unless you are Google, with search, it's a solution to a shared problem that everyone has and it should be ideally in an external library. So in a Rails app that might mean you take logic from your models and put it in a library in your lib/ directory, better it might be taking that logic and put it into a plug-in or a gem in vendor/ and share it with the world. Basically by doing that your application does less, which is a good thing because it is simpler to write, simpler to maintain, simpler to understand.

   

21. You don't like the ternary operator. Why not? It's nice.

I have seen it abused too many times, I have seen ternary operators who had to do assignments and have compound comparisons and then they do multiple things and then each side of the condition the only reason to use a ternary operator is if it is something really simple then it's ok, but usually I think it's best to expand that out into your regular old conditional.

   

22. Are there any other Ruby features that you think lead to obfuscated code?

I think this is a good feature but it is possible to chain too many things on a single line, I talk about that a little in my talk. I like Ruby one liners when they are expressive and a few things are going on but you can chain operations as long as you want and that can definitely do obfuscated code. I wouldn't get rid of it but it can.

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT