Tuesday, February 2, 2010

Q&A with Michael Gundlach, creator of AdBlock for Google Chrome

On Monday (2-1-2010), AdBlock for Google Chrome became the most popular extension for the browser, with about 250,000 users as of this writing. That achievement came after nearly two months of frenzied development by its creator, Michael Gundlach, during which he was interviewed by the NY Times, got rave reviews from users, and saved the world from a giant comet. But how?



Lucky for me, Michael also happens to be my close friend and coding mentor, so I’ve got him on speed dial. Today during lunch, we chatted about AdBlock, including how agile development and editor mastery helped him achieve so much in so little time.

How did you get started making AdBlock for Chrome?

"I was reading the Google blog at work and noticed that they said extensions were available in the beta channel... When I searched for Adblock on the extensions page, I saw that it didn't exist. I was like, 'oh that's too bad,' and went back to coding. About two hours later, I went, 'what am I doing at work!?' I jumped up and went home and read a tutorial, and posted a dummy version of AdBlock, and immediately started getting user feedback. They were rating it terribly, because it was just a ‘hello world.’ So based on the comments, I updated it so it would do one thing: block ads on ESPN. Then I just went as fast as I could to get a functional version that actually blocked everything that Easylist blocked... and then I kind of didn't stop coding all through December."

What’s your development background?

"I started coding when I was nine, when my brother gave me a computer with BASIC on it and showed me how to use it… I got in trouble in high school for installing the Pascal compiler on one of the physics computers because I wasn't paying attention. They charged me with hacking into the computer system when I was just trying to make a choose-your-own adventure for my mom for her birthday… I never stopped because I can't stand do anything but program." (Note: Michael went on to work for some well-known companies, including Google.)

What's the process for writing an extension? Was it hard to learn?

"It was great - the tutorial was really freaking simple, and you just make some Javascript files that you want to run on each page. Chrome’s extensions were based on the GreaseMonkey extension in Firefox, where you just run some Javascript on a random web page... My 20% project at Google was a Greasemonkey script for internal use, so it felt very natural." (Note: Michael recently heard from a current Googler that the update system in Chrome is based on an innovation in Michael’s Greasemonkey script that allowed it to update itself automatically.)



You and I talk a lot, so I know that you've used agile development throughout this. How do you think of agile development, and why did you choose to use it?

"It's better for your psyche to have something working quickly and see that it does work... I wanted to get something out there right then, and the system supported me making tiny changes and shipping them quickly... If I had done the waterfall method and waited until the extension was complete, somebody else would have already done it and I wouldn’t have been able to catch up… Agile development keeps you focused on the task, and helps you always have something usable for the user so you get feedback."

"Agile development keeps you focused on the task, and helps you always have something usable for the user so you get feedback."


What are some of the decisions you made that helped you move quickly?

"I knew it needed to have filter subscriptions, but at first it was simpler to just copy and past the entire Easylist into a file and use Unix regex tools to turn that into Javascript code [an array]… I didn't have any updating, but that was a quick and dirty way to have something that covered lots of websites at once. The next week, I had people reported ads that weren’t being blocked because I wasn’t updating Easylist, so I had to patch manually while I was trying to get filter subscriptions written.”

"When I put new features in, I tried to put them as opt-in experiments, using the Google Labs approach, where users that are geeky enough can try it out and give me feedback... Before that, I updated one night and went to bed, and the next morning I found people complaining in my comments that I blocked all images on all web sites. I kept getting those complaints for three days until everybody’s browser had gotten the version that fixed it, even though I had released 10 updates in that time. So now I do stuff in experiments first.”

Many developers feel like we can't publish something unless it's perfect. But clearly that attitude would have stopped you from succeeding here. How do you decide if something is "good enough for now?"




"It's a balance, but I think the idea that if I put something in there that's not perfect, it will hurt my reputation, that’s false, because that's what Microsoft has been doing forever. If you can put something out that's not perfect and get feedback, you're ahead of the person who hasn't released anything at all… I just look for the absolute simplest thing I can do that adds some functionality, then do that and release it… There are still a lot of things I want to do with AdBlock, but it's been useful for thousands of people even thought it's not perfect."

What did you learn during this process?

"This project has 500 times more users than anything I've ever built personally. I'm seeing how successful Agile can be if I just listen to users and do the thing that people are shouting for most. So I've validated the agile approach... combined with not ever sleeping."

"Also, I need to weigh how loud the user is with what percentage of the user base they represent. People were clamoring for a long time that I get a change log up and post my source code. I could have spent 4-5 hours doing that, but that would have been time I wasn’t blocking ads and fixing bugs, and most people don’t care about a change log. I actually wrote a priority list down – responding to user requests quickly was first, because people liked my fast customer service, then fixing ad reports, then fixing bug reports, then feature requests, and way down the list was administrative stuff like a change log. The list got more formalized when I finally got some breathing room, when the ads were being blocked and most of the bugs were fixed, so I created a Google Code project, where I can mark bugs with low or high priority and people can see my change log."

You used object orientation pretty heavily in your Javascript on this project. How did that help you?

"What makes it most useful for me in Javascript is that it simplifies the code; it's one level of complexity that's hidden. If an object has two methods exposed, I only have to remember those two methods, where with procedural code there are a bunch of methods in the global namespace that I have to keep up with. It's harder to do in Javascript because the syntax isn't as friendly as in something like Ruby, but once you learn the syntax, it's fine, and it makes your JS feel SO much nicer."

I had the chance to actually see you working for a bit, and the main thing that stood out to me was your fluid use of vim. It's almost like you're playing an instrument: you don't seem to think about the commands. You're just typing at a thousand miles an hour, and fully formatted code flows out and morphs on the screen, while split windows appear and disappear as needed. How did you attain such editor mastery, and how important is that to your career?


It's freaking wonderful to be fluent in one editor... I just think ‘I want an IF statement’ and the braces appear.


"I got it because I've been using Vim for maybe 21 years – my brother got me a Unix account at the University of Georgia and showed me vitutor and said ‘use this.’… I don't know nearly all there is to know about Vi, but I know the bits I need to... It's freaking wonderful to be fluent in one editor, because my thoughts get to flow straight from my brain onto the page, and I don't have to worry about what my fingers are doing in the meantime. I don't have to think at the level of how to put the braces in anymore, I just think ‘I want an IF statement’ and the braces appear. Maybe I'm manually indenting them and getting the formatting right, but it's such lower brain stem work that I can ignore that and think about the code. It's like my fingers are plugged into the computer. It's not 100% - sometimes I get things wrong. But because I've been using it so long, and because Vi rocks so hard, I don't have to think much about it."

So being really fluent in an editor is crucial?

"Absolutely. Vi or Emacs, whichever one, I don't care, learn it. The exception is if you're going to spend all your life doing Microsoft .NET programming, then learn Visual Studio and learn everything about it.”

“One nice thing about Vi is that it can be used for text editing as well as code, so every time you write a notepad file, you're improving your Vi skills… Get a good .vimrc, that's important... When I try to use Vi on a machine that I don't control, it's painful again. Syntax highlighting and stuff like that don’t work, and I have to stop thinking about my code and think about my editor.”

Projects like AdBlock for Chrome are not just fun for you – they’re part of your vision for your career. Why?

"I've always had the idea that when I can retire from having to work for money, I would still be doing all the same stuff I do now, it would just be for free. Instead, I am fortunate enough to find some hours that I can do this now, and holy crap, I'm the author of a successful open source project, which was one of those goals for retirement... I’m looking for a job now that will let me work from home full time, and possibly less than full time, so I can use some of those hours I would have spent working for pay working on AdBlock."

How is the AdBlock community coming?

"We've already got three official contributors who triage bug reports and figure out how to block ads, and two offers of translation work. So if I ever want to leave, I think can hand it off. That's what open source is so awesome for. If I want to move on to another project, it will be when the community is so strong that AdBlock is running itself. But I don't see that happening anytime soon, because I'm still really excited about making this thing great.”

Monday, February 1, 2010

Windows development toolbar

At work, I develop on a Windows machine, and need access to various config and log files, as well as my main code trunk and a branch. I got tired of digging through layers of folders to find everything, and set up a quick way to access everything. Here's how.

(Note: these screen shots are from Windows XP, but I've confirmed that this works on Windows 7, and it probably works on Windows Vista as well.)

First, create a folder on your computer (anywhere you like) and create a bunch of shortcuts in it to everything you might need.

Second, right-click the menu bar and choose Toolbars > New toolbar. Select the folder you just created.



Finally, click the little arrows next to the toolbar name. It will pop up with all your shortcuts. Hooray!



Final tip - if you'd like to see the full date and time on your menu bar, right-click it again, deselect "lock the toolbar," and drag the toolbar edge up to make it taller. When the full date and time appears there, right-click again and re-lock it.



Ta-da! No more double-clicking to see today's date on the calendar.