The author of HAML rants on markup, Macs, diversity, and tech writing.
Interviewed by Sam Aaron
Geoffrey Grosenbach: It’s the “Ruby on Rails” podcast, I’m Geoffrey Grosenbach. Interview today with Hampton Catlin, author of the HAML templating language, submitted by Sam Aaron, director of the Newcastle branch of the Geoffrey Grosenbach fan club, did a good job on this one.
Over an hour, so if you’re on a long flight across the pacific this will keep you occupied for at least one-fourteenth of your journey.
Also, I recently announced PeepCode Press, a boutique independent publisher. If you want to work for a publisher that will make your books look fabulous, use multimedia where appropriate, has a smooth workflow, generous royalty for authors, give me an email at peepcode AT topfunky.com or see me at RailsConf.
Sam Aaron: So here we are with Hampton Catlin for the “Ruby on Rails” podcast. OK, hello Hampton, how are you doing?
Hampton Catlin: I’m doing great today actually.
Sam: So you are all the way from Canada?
Hampton: Yeah, I’m here in Canada and I’ve got my glass of rum and coke right now.
Sam: Ah, nice.
Hampton: It’s afternoon, so…
Sam: Yeah, sort of a grim Newcastle day here today.
Hampton: it’s a grim Ontario day here too.
Sam: Well yesterday we had lovely sunshine and the day before we had snow, so I mean who knows.
Hampton: It’s still winter here is what I can tell you.
Sam: Ah, that’s not good, we need the summer. OK, so what’s HAML?
Hampton: HAML is my venting of all the frustrations I was having with conventional templating languages basically.
Sam: So what kind of venting, is it sort of a loud vent, or sort of a quiet vent?
Hampton: Yeah, kind of. It’s just that I was getting really frustrated with the… I don’t know, I was probably around my third Rails project, beginning then, and I just kept doing the same things, and every time you had a partial I just felt they were really big, and I was opening and closing tags, like the little bracket thing on my keyboard about to fall off.
Hampton: But I worked with designers very closely.
Hampton: And I found that they were having difficulty with the RHTML’s, especially when we were putting in extra functionality. I don’t know, like the more complicated sites got, I found that we were starting to have difficulty. If we would try to make something drier or more beautiful, we would generally make it more confusing for them, because we would have to put in too much pure Ruby.
Sam: OK, so you quite love code in your views?
Hampton: Well, I mean there are things like when you’re AJAX, you can’t really help it.
Sam: Absolutely, yeah.
Hampton: You know, I mean you put in the helpers, but then they don’t know to look there. I don’t know, I just sort of one day got frustrated and I opened up a notepad.
Sam: Windows Notepad?
Hampton: No, a GRF on Linux. And I don’t know, I printed out the document that I had there, the HTML page I was looking at that I was working on that day, and it felt so ugly and awkward. Still, I put it in there, and I just started changing, I wanted to boil it down, I said “How can I take this and start removing the cruft, how can I make it a little bit more beautiful than it is right now?”
So I just started hitting the delete key, and it was already dented because I did it with my own code anyway, and I just kept hitting delete, and getting rid of all the closing tags. And I ended up thinking that I started to see a pattern here, I started seeing the DOM come out of it, once you start removing all the syntax.
Sam: Taking out the structure really.
Hampton: Exactly. Then I noticed that most things were DIV’s, and they’re classed as attachments, and I was like “Well, what if I could remove these attributed of the end, and what if made it look more like CSS?” Because I knew that our designers would probably like that idea.
So I had fun, I just sort of started literally as an experiment, and I guess my own useful frustration with thinking “Is this really the best we have?”
Its fine to impeach P and ASP, and all these things before, the way we do templates is just what we’ve done, and you know it’s functional, it’s certainly fast. But I don’t know the thing that was really driving me nuts, was the nerdy part of my brain that was thinking to me “What are these templates, where do they fall in the greater scheme of syntax?”
Like when you do these escape sequences, and then they have special meaning in the middle of an HTML document basically.
Hampton: And then I’m doing loops inside of it, but what’s behind it, what does this mean if I’m actually trying to look at it as a computer scientist or a sort of actual programmer? Could I remove these little open and close tags and put quotes there? Is everything that is in the HTML part that looks like most of it, is that just a big string, and then is everything important in between?
Sam: You sort of went through a quite complicated distillation process essentially?
Sam: Squeezing much of the crap out, you know.
Hampton: Yeah, I was like “This doesn’t feel very pure in any way to me” That’s sort of what I find about traditional templating languages, they were build to originally process text before we had the web, that’s what ERB was build for, it obviously wasn’t before the web, but…
Sam: Sort of a string….
Hampton: A lot of the pearl scripting stuff that us a lot of the same syntax too. It was just build for “I want to query a server, and I want to get a response” You know, and that’s what sort of the original idea was, I don’t think it was so much like “Oh, we have XHTML now, lets…”
I didn’t find that anybody had come to the problem saying that we live in a world that’s a little bit different now, and how can we come up with an actual templating language that isn’t pure programming code, but is a representation of the data behind it?
Sam: Absolutely, the string is like the representation of the DOM.
Hampton: Exactly, that’s exactly how I focused on it. And you know, there had been things like Mark Huckabee out there, and a lot of people still enjoy using that, I just tend to find that some things are better at one job than another. So for me, I find that code is really great for explaining logics, like it’s fantastic at it.
I mean, I love programming, and programming languages are awesome if I ever want to loop over something or do some math, or build an object, or do all sorts of things. But to me, I don’t personally find them to be the most natural representation of structure, of data… Which is actually a particular thing that drives me insane, is that I keep hearing HAML referred to as Python-SQL, and it drives me insane.
Sam: There is a similarity isn’t there, with the space indentation thing?
But just because they use alpha-numeric keyboards or something like that, functional languages are just like comparative language because they both have compilers.
Hampton: Yeah, there’s very little besides the fact that some structure is using spacing indentation. I mean, to me that was just simply that I wanted to get rid of cruft, and that was the reason for it, and everything was indented anyway.
And that was one of my original obsession, I hated how my viewing source looked on these projects I’d written. Like, I worked on this projects and I literally poured months of my into them and then all the code behind it, I would strive for beauty in everything I did. And the templates looked nice from my angle, but when I actually looked at the output, like the sum total output of everything I had done is this lanky, ugly, terrible source code.
And so I started having little waves, I would wrap my content for… It’s now yield in your layout, but it used to wrap that in something called Tabafine, so it had a tab automatically, because I just hated that automatically my templates would be ruined right from the start.
Sam: Yeah, sort of out of the box Rails produces the HTML’s that were completely indented and it’s all sort of all over the place, isn’t it?
Sam: You felt a problem with this?
Hampton: I totally did.
Sam: [laughs] A vengeance.
Hampton: I kept trying to fix it, because I just always felt, “Oh, if I could do a little bit of extra work and make this better…”
Hampton: And then I sort of realized, I was like, “Well, why doesn’t it do itself?” And I started investigating how to get our HTML to do that properly. And I felt that it was possible. I did have a little hack for that.
I wanted this idea of structure and indentation. When I was sitting down to sort of fantasize-that’s what I was doing; I was fantasizing about syntax…
Hampton: I said, “This would be great if I could say this” and it would just magically happen for me. So yeah, that’s how HAML was invented, with this Spartan edit screen of white.
Sam: So you took like Python-SQL indentation, CSS-style descriptions, and…
Hampton: Hold on, hold on.
Hampton: It’s YAML-SQL.
Sam: YAML-SQL. OK, OK.
Hampton: Because it’s structure, just like YAML does.
Sam: So you boiled it down, and you used a lot of similarity with CSS. But then now I’ve seen you’ve started to do the same approach with CSS, making it more like HAML.
Hampton: Yeah, that’s Sass.
Sam: Yeah, so what’s this?
Hampton: Well, I don’t know. Oddly enough, the only thing it really shares with HAML is a love for CSS, but that makes sense for a CSS language. But really, I don’t know. I sort of had mixed together HAML and CSS. I kind of tend toward CSS, though.
Actually, I see Sass as something probably that may actually be more usable for a general audience of people than HAML is, because I think designers in general have been finding a lot of frustration with CSS. Myself personally, too, every time I use it, I just think to myself, I’d be like, “Well…”
Really, nesting was the thing. The original idea was simply to do a pre-parser on CSS that all that it would do is you could nest CSS inside of an open tag in CSS, and you could put a new one in there and it would magically concatenate the name; it would magically build it out for you and just make it repetitive.
Because I kind of realized CSS two or 3, or whatever’s next-I guess three or something-it’s not going to be out forever. And we’ve got to wait till browsers implement and all these things. So I thought, “What can I do with current CSS to make it more like something I’d want to work with?”
Sam: Sure. So you’ve done the same kind of distillation process. You’ve removed all the braces, you’ve gotten rid of all the… [laughs]
Hampton: [laughs] Yeah. Me and braces don’t get along.
Hampton: Well, in some instances. The way I like to approach a problem is, I want to think, “For this problem, how much does it help me?”
Hampton: Like if I was writing an actually programming language, I don’t actually think I would go the Python route. I don’t think I would. I don’t think I would do indentation-based code, because I think code should be able to be flattened. I think it should be free to move about on the page, and I think that’s part of its beauty. And that’s even part of the beauty of XHTML.
I won’t even deny that it’s a better thing, that the standard underneath, the base of everything, is very clear on open and closing; I just wanted something easier for me to work with and the same thing with Sass.
CSS has limitations built into it; there are no constants; there’s no math. You can’t adjust things by adding on a certain amount. You can’t change colors. I can’t say, “Take the background from behind this new element and make it lighter.” You can’t say that; you can’t modify existing variables in the DOM for styling.
Sam: Sass allows you to do that, does it?
Hampton: The constants are built-in. Well, variables, really. And also you can do math with them.
The example I put on the site, it’s the main example, is one I really like. You just say, “I want the page to be 800 wide” and you say, “I want the sidebar to be 200.” And then when you actually get down to styling, let’s say your content div, the part that isn’t the sidebar, whatever you want to call it-everybody has a different name. Whatever you call that, you would take the width of the page and subtract it from the width of the sidebar so that if I want to go change the whole width of the page, everything will magically resize for me in the CSS; every time I regenerate the CSS, it will do that for me.
Actually, another constraint in Sass that doesn’t exist in HAML is it is not actually dynamic; it’s a pre-compiling language. It can compile into CSS. And it generally happens once. It’s bundled with HAML right now. That’s one I really want to have implemented. It’s kind of simple to implement, so I definitely want to have that in multiple languages.
When you’re in production mode, when you first launch the server, it takes the Sass file, compiles it into CSS, and drops it into your folder.
Hampton: So it’s statically served. That was a big thing, because I don’t want to slow down my servers by having, all of a sudden… Oh, and it gets really complicated because then you have to worry about people wanting to pass in colors and stuff like that.
Hampton: That stuff has its place, but I really wanted to keep it simple. I want to keep this an idea that we can have Sass and it goes directly into CSS, and it only needs to happen once on a production server. Obviously, in development, every time you reload the page it generates a new one, just so that we can make sure…
Sam: Yeah, development process and get going. Yes.
Hampton: That was one big stricture. But there are constants. You obviously nest things. I call it scoping, really. See, what it really does is, HAML started spoiling us, at least at Unspace. We’d use classes a lot more, to be much more descriptive in our DOMs, in our documents we were creating about what it is we are. Every message on the page, we would have class message, along with message, underscore, and its ID.
HAML has built into it something a lot like Simply Helpful’s div-for. It does something where it will automatically assign a class and an ID. In a sense, we’re doing that. I’m calling this wrapper a message. Well, which message, because I have messages on three pages? When I’m actually semantically naming things, it starts to become more and more important that I’m saying, “On this page, I want a message to do this, ” or, “The general message should have this behavior.”
You could start actually approaching your styling and your XHTML documents in a whole different way, because you start thinking about what are the semantics of it? What does it mean to be a message? What does it mean to be a title class of a div with a class title, inside of a message? That would be different than a title inside of an article or something…
Sam: So the structure starts to become quite clear.
Hampton: Exactly. It’s using classes as ways to describe the location of things. And CSS has a limited way to do this; it just requires that you keep repeating yourself every time you want to refer. You can’t nest. You have to keep repeating it out. And I’ve met a couple CSS designers that would just keep writing it out, over and over again. I know somebody who actually indents their CSS and does it nested, but it’s not really nested; he just keeps repeating everything from the parent, by hand.
Hampton: You have to use find and replace a lot if you want to rename something.
Sam: Yeah, sure.
Hampton: Yeah, I’ve seen that. Oh, and yeah, doing things like lightening colors, that’s very useful. You could say, “I know that my sidebar, no matter what the background color is, I might change it, I want the sidebar to be 10 points lighter than the rest of it.” And that’s really easy to do: you just type in the color, plus 10. And that’s it. It just works.
Hampton: And it compiles out into an actual color. There’s nothing fancy going on.
Sam: That’s nice.
Hampton: I’m excited about that one, because right now I’m trying to build a-well, it’s built, I’m waiting to release it-sort of laboratory where you can go in and designers, they’ll get a little bit of sample Sass and they can just start playing with it. They can start typing in their own values and seeing what will come out.
And hopefully, even people in other technologies, I hope designers might be able to even find use in it if you’re doing.NET. You can go to the site, you can type it in, and then you can generate CSS.
Sam: Cool. So in a nutshell, why should people look at HAML and Sass? What’s the elevator pitch for it?
Hampton: HAML is not for everybody at all, but it is, I believe for people who are really anal about their code. They want things really well structured, they love, they love creating documents, not just creating websites like people who really sort of see their sites as something more than just some HTML spread across you know some pages, with some random data interspersed there. If you, if you have any inkling towards that, I mean I would definitely look into HAML. It’s not, some people don’t, and well the good thing is the only people that I’ve heard who don’t like it are people who aren’t willing to try typing even a single line of it. Even the, there’s only one person I know who was initially skeptical, tried it and liked it but…
Sam: You know…
Hampton: I’m sure, I’m sure that people have different ways of working, that’s not it, I just I’ve yet to actually meet somebody who’s like, ‘yeah, I used it for a week and then I didn’t.’
Sam: I ditched it.
Hampton: I’ve yet to meet that, in general, people tend to be, well I mean, I don’t know, I get at least an email or two a day from people just saying, ‘Thank you, thank you, thank you.’ Because I think this is something that’s been a long time coming, to be honest and you know, I hope other people have better ideas.
Hampton: That’s the thing though, it’s not absolute.
Sam: Oh actually…
Hampton: I feel like I’ve invented the best thing. I hope this sort of breaks open the mold where you can go, ‘Maybe we will rethink these problems, ’ you know, think there’s ways we can generate, we can sort of think about coding in a whole new way, and the way we’re working on the web, the way we feel about it. And if we can do that and break out of the mold of what we’ve been doing for the past decade I think that will really, there are a lot of ideas yet to be discovered. I think there’s a lot of creativity that’s waiting to be released and that’s what I’m really excited to see you know, how does a dot net developer when they see HAML, well, what’s their reaction? What’s the best solution for their toolset? Is there something they could do that would be like this but different for them?
Hampton: Actually… yeah… let’s… I’m going to be at E-Tech in a week, which well I don’t know, will probably be passed by the time this thing hits the airwaves, Internet but yeah, that’s what I’m really excited about that because there’s going to be PHP and Java guys there and I can’t wait to tell them about HAML and just see. Actually you know, my, somebody, one of my coworkers went to Microsoft the other week, and they were talking about, they were like, ‘Oh, you guys do HAML?’ which was really kind of creepy.
Sam: So they knew you?
Sam: Famous in Microsoft.
Hampton: App, I don’t even, I don’t even know what to make of that. Cause, cause he was like, like, ‘Are you sure you mean like, I don’t know, are you saying the right words, is this guy not understanding.’ So who knows maybe the next version of dot net will have something like it.
Sam: I saw Eric Meyers speak last week at Q-Con and he introduced a load of cool new features for C# and VB most of them already available in the, pretty much all of them available in C# already so it’s quite interesting. So they are; I’m sure they are, looking at the community as a whole and trying to find out what’s cool and trying to incorporate that.
Hampton: Well, that’s actually why my friend was there.
Hampton: Yeah, they just were interested in finding out about Rails and how to integrate it with different other technologies. How to integrate, you know, yeah, I mean the thing is, you know, I don’t know I think a lot of people to have the gut reaction, that’d go, ‘this is a bad thing, that dot net is… is getting inspiration from a post Rails world. And for me that, that’s not I, I, I don’t think that at all, I think, I’m not supported by Microsoft, but I think that’s it’s fantastic that your average Microsoft programmer might have a slightly better life because of something that we did, you know.
Sam: Yeah, exactly; almost in a way.
Hampton: I think that, yeah, if we’re going to be running…
Sam: Lead the path!
Hampton: Yeah, well exactly. We’ve sort of, maybe, maybe made their day just a little bit better cause there’s just something that, that was obtuse that has been made a little more clear.
Sam: So when you introduced HAML originally, the, London for the LasComp and I remember reading a quote about it from DHH and I can’t help have respect for Canadian, though actually you’re not quite Canadian, you’re American so much right, who manages to swear more than I did at my vendor-iris rant and drink beer at the same time, a perfect example of the diversity of the Rails community.
Hampton: [mumbles and laughs]
Sam: [laughs] Exactly. So you’re diverse. What does that mean to you, do you think?
Hampton: I drink, I swear, and I have sex with men…
Hampton: Does that count as diversity. Well, I like to think that I am, as a white male, bringing diversity to the Rails community. [laughs]
Sam: Right. That’s good. That’s good.
Hampton: I think white males, they’re really a minority, and as long as we cuss more and get funky haircuts, it’s fine.
Sam: [laughs] So how is your hair these days? Last time I saw you, you had a sort of a poof.
Hampton: It’s long and curly right now.
Sam: Long and curly? Oh…
Hampton: Because I know the Rails community, there is one thing that they want to know. There is one question on the lips and minds of every Rails programmer out there…
Hampton: What is Hampton’s hair looking like today?
Sam: Absolutely. Today? Exactly.
Hampton: [wheezes] You’re getting emails that are like, “When are you going to do an interview with Hampton? You should totally find out what his hair’s like.”
Sam: [laughs] You should have a site like, every day you have a snapshot of your hair.
Hampton: Every day, just take a new shot. [laughs]
Hampton: Hey, that’s an idea.
Sam: So do you think that there are many gay Rails developers? Is it a thing which is unspoken about? Or is that something that you’re..?
Hampton: There are more than I think people know.
Hampton: But, yeah. Some of them I’ve dated, some of them I haven’t. [laughs]
Hampton: The thing is, the Rails community is very… I’ve never heard anything bad. The reason I make the white male joke is because it’s a boys’ club, but I get along in boys’ clubs-not like that! [laughs]
Sam: [laughs] You’re digging a hole.
Hampton: [laughs] I sort of get along with that. I don’t know. I haven’t ever gotten any crap about it or any weirdness at all.
Sam: That’s good.
Hampton: Actually, more than anything, I’ve been incredibly impressed with, just in general, the community.
Hampton: I think it’s more of a general thing to say anyway. It’s just that the Rails community really has-well, there are some terrible people-but mostly it has just people who tend not to be satisfied with the answers that they’re given.
Sam: Some crazy-ass people, absolutely. They aren’t willing to accept someone else’s answer. They want to go it themselves.
Hampton: Exactly. People tend to be much more open-minded, about everything. The thing is-I call us the rebellion-you would think that, us as the rebellion, we would hate the empire. But I find that’s not true; most of us have come from working in technologies which are more settled and are perhaps more traditionally minded than Ruby on Rails are.
But I find that people tend to understand that they’re maybe dissatisfied, but they’re always looking for something better. So it’s not this, “Us against them” or, “Isn’t this terrible? We should just remove it all.”
Hampton: Oh, actually, that’s a whole other rant. That’s just one of them.
Hampton: There’s one exception to that that drives me nuts.
Sam: Which is?
Hampton: You know what drives me nuts? It is the Rails Mac obsession.
Sam: Ah, OK. [laughs]
Hampton: Right. Yeah, drives me nuts.
Sam: Isn’t that also the similarity between you talking about HAML and the search for beauty, and a lot of people see a lot of beauty in the Mac operating system. There’s that sort of similarity.
Hampton: There is a lot of beauty in the Mac operating system. There actually is a lot of beauty. [laughs] I do have things I could say, but not even to nitpick with any platform, I just tend to find it gets a little gang-y; people get made fun of for using either Windows or Linux. And to me, that’s not very open.
Sam: That’s not good at all, no.
Hampton: I tend to feel that if somebody wants to develop on Windows or Linux or Mac or Solaris-whatever makes them happy is great. Tell them about your platform. I heard a quote one time, somebody said, “Well, any serious Rails developer uses OS X.”
Sam: That’s rubbish.
Hampton: I know for a fact that [laughs] Wise, Zed Shaw, and myself all use Linux.
Sam: Absolutely, yes.
Hampton: I mean, come on. That’s a crap thing to say.
Hampton: I’m not saying everybody would agree with that, but there is sort of this culture of, “Use this or you’re not actually going with the Rails thing.” I think actually my biggest criticism is, to me, the true Rails way would be the MIT licensed open source mindset that sharing is better than not. And unfortunately, at this point, Apple has no plans to actually open-source their software.
Sam: DRM city.
Hampton: Exactly. They tend to embrace…. Well, but Jobs did say something that he didn’t like DRM, but…
Sam: Yeah, that’s true. I heard about, in the Rails conference, one guy was walking around with certificates of non-conformism, for people who weren’t using Macs.
Hampton: Oh Really? That’s awesome!
Sam: There’s a whole page about people with certificates to show they’re using Windows or Linux.
Hampton: Yeah. I just think whenever we say that we’ve found the only better way, that’s really where you start getting into trouble. I mean, Rails is fantastic. It’s hard to find a bigger Rails nut than me, these days. But also, there are limitations and there are differences. I totally think there are problems in the web that might be solved better on another platform. I have yet to face them….
Also, somebody will come up with something better later, I hope. If this is the best that we’re going to get, then something’s messed up. It’s this idea that we’ve reached perfection now, or we’re barreling towards it and we’re on the right path, and everybody else isn’t. That just gives me the willies because I tend to prefer the idea that as a community, as a nerd community, as a human community, we all have different paths that we’re working on. Whatever makes us happy.
Hampton: From operating systems to where you put your sexual genitalia – it doesn’t really matter.
Sam: No. Get along and be happy. That’s one of the things that the Rails community, to me, seems to be one of the friendliest communities I’ve ever met. So hopefully we can get on with our differences between Linux and OS X. Anyway, tell us about Unspace.
Hampton: Unspace is the company I work for, here in Toronto. It’s the reason I’m an American who’s stuck up in the cold. It’s a great little place. It was started by Pete Forde and Ryan McMinn, along with Anthony Watts, who’s the design side. Ryan’s sort of the business guy, and Pete started doing the coding, and they brought me in about six months after they were founded. Then Jeff Hardy came on board. We have a new guy, Mike Ferrier, who we’ll make sure people find out about later. We’re going to properly pimp him. We’re just a small little company. We do consulting only; we do hourly consulting.
Sam: You’re a Rails-only company?
Hampton: We’re Rails only, yeah. We have a sister company that actually does access, that I’m not really involved in. Ryan, our business guy, runs both companies, so it always puts him in a bit of a spot.
Hampton: We’ve actually had really good luck…. I can’t believe I’m about to say this, because it goes against 90% of the stuff I believe. We’ve actually had some really good experience with using Access as a tool with the Rails application, believe it or not.
Sam: Oh, really?
Hampton: Yeah, as an administrative application. Like, you know when you’re writing for a client, and they’re like, “I want to be able to come in and see how many users were created today.” You know, they want to see that; they want a little report. “Can we do a graph of that, or something like that?”
We’re like, “Oh my goodness, you want a graph from the web?” I mean, we can do it, but it’s going to take us some time, and we do hourly and we’re not cheap. It’s always this weird thing when you have to tell a client, “Well, the web’s not really great at that.” Running reports or saying “what’s the most common first name of all my users” or really stupid things that – well, I think they’re stupid; marketing people love them. But all these stupid things that people want to do with their data.
We’ve actually found that, with MySQL we just open it; we just make sure the ODBC port’s open. Access – it doesn’t take much, but it’ll mate with that. Then we give the client the little Access program, and he can click – we make sure it’s protected – he can sort, he can look through. Some of them, we allow them to change… if somebody wants to change an email address, the client can then, very quickly, go into Access and change it. I mean, Access, there’s a lot of negative things to say about it in the past.
Sam: It seems to work, that’s great.
Hampton: It’s very good at having a user who’s more of an information worker than develop. This is somebody who just works in a company you know can learn very easily how to sort of, sort through data, how to run reports on it, work with that data. That’s you know, what it’s good at, that’s what it’s original sort of intent was you know besides keep…obviously people use it for data entry and stuff like that. We’re sort of using it more the reporting side which can be very you know, our clients love it, I mean and it saves us a lot of time. We don’t have to go in and write 10 boring scaffolds back in for them, to log in and do less than we can do with it. So, yeah Unspace.
Sam: What’s the business model like?
Hampton: So we do everything on an hourly basis, we don’t have any set budgets; we don’t sign contracts; except for the contract that says, ‘Any work we do will get paid for, we will do our best to stay inside the budget we’ve outlined’; but it’s only, we call it estimates not budgets and we always try to, we stay in very close contact with the customer; we tend to grow the applications, we tend to be very, very opinionated about software. Like, very, yeah. But you know clients tend to actually like it, cause we tend to tell them no a lot.
Hampton: Trying to keep, you know clients a lot of times will have an idea, especially clients with money, they tend to have ideas, they tend to go, ‘Oh, what about this?’ And you just have to say, ‘No we think that’s a bad idea.
Hampton: And you can be so surprised, I think most developers have this problem we’re afraid to say no because we’re afraid, what if they’re not happy. Oh, will they think I’m not a good programmer if I say that’s too hard? And that’s how I think most contract-based web work is just, runs massively over budget, well, not over budget, because there’s a set budget, but somebody on some side of the equation is losing, always. Somebody got at deal or somebody got screwed, whether it’s a client or you. When you do a set price, nobody ever really knows what they’re agreeing to in the beginning, you can spend forever doing specs and you’ll never figure out if it’s going to be good or not; so we tend to rapidly prototype. Did the budget, is it really driven by the client, that’s the biggest thing, clients I find do the…you know we tell them you know…
I had a client today, we like, it was a stupid little feature, but it was one we didn’t have and he says, ‘I’m out of, I’m almost out of.’ We knew he was almost out of money. Said, ‘I want to do “forgot”, “remember” me on our, on the login, and also an email for the forget password or something like that and a utility for changing and confirming/reconfirming your email address.’ And I said, you know, my first question was, ‘Have you gotten a lot of support requests for that?’ Like have people been, is this, has this been a main ten…like we can do a…
Sam: Do people want it? Yeah, yeah.
Hampton: Yeah, is this like we’ve been having a problem? And he said, ‘No, I just thought we should have it.’ And I was like, ‘We can do it, it’s probably going to take about half a day.’ And he did a little calculation in his brain on what that cost him and he said, ‘Never mind.”
So it’s sort of this, it actually, but the thing is it’s actually better for the product, I mean it’s a waste of my day if I end up building a, you know, forgot password link that nobody uses and maybe we get one a month right now. Even with a lot of users, we get, one a month, that’s you know, what value is that to him? What value is that to the site? To the quality of the site, know what I mean. Some sites you know need that very quickly, if you have users that commonly go away for a long time and they tend to forget passwords, stuff like that or especially if sites get older they tend to have more and more users who want to come back. These are the sort of things we grow on to it, but there’s no reason to spend a whole half day, you know not working on something else, and working on that and then coming back to it and saying, ‘Oh, you know, well I wasted half a day as a developer.’ You know if we were on contract maybe he’d say, ‘Well, most things have a forgot password, I assumed you put that in.’ and we said, ‘No, that’s not in our budget.’ So I’d have to spend half my day for money we never put in the original budget so I’m just losing you know, I not getting paid because this was never something that I put into the original budget in my own brain. So there’s a…
Sam: Dave Thomas said in his speech at LasComp at London, was that one of the things he said, was to, ‘Try to move the risk, from myself to clients you know…
Sam:...because they’re the one making all the decisions.
Hampton: They’re making the, they’re running the business.
Hampton: Their money to make or lose, you know, it’s, like I think, I think we forget that. I tend, I tend to become friends with my clients, I really do root for the sites; I really do care about them. And you know, even though, still I know if they, part of being non-equity because we don’t do equity with our clients, unless they want to give us a gift, we don’t trade work for equity because we think it’s a weird line to cross. I still feel like I care about the site, and I want it to succeed.
Sam: So tell us about conferences.
Hampton: [laughs] Oh, I could tell you about conferences.
Sam: [laughs] Tell us about conferences, Hampton.
Hampton: OK, so I’ll tell you about conferences. I did the RailsConf in Europe. It went over very well. I had a great time. It’s a good show, as I like to do. So I just was like, “Well, heck, I’ll do the Ubuntu Conference.” I knew ETech would be a huge stretch, but I was like, “ETech, regular RailsConf…”
Hampton: And then, just over the days, it was like, “From O’Reilly Media: proposal accepted, proposal accepted, proposal accepted.” So that was three. And then somebody jokingly said, “Hey, the MySQL Conference, they don’t have a big Rails track.” [laughs] And so I sent Vee McMillan at O’Reilly, I was like, [laughing] “Hey, do you guys need somebody to talk about Rails at the MySQL Conference?” And she’s like, “Sure!”
Hampton: “Why don’t you go?”
Sam: So you’re going to talk about migrations?
Hampton: Let me see. Next week, I’m going to be at ETech doing what’s going to be my last HAML talk, I think, at least for now.
Sam: “A Semantic Rebellion in Template Land.”
Hampton: Yeah, “A Semantic Rebellion in Template Land.” That’s one I’m really hoping to crack into the other technologies. So I’m doing that next week, late March. And then after that is MySQL, where I’m doing a thing about migrations, yeah.
The idea was, I thought, it’s sort of the same idea I was talking about when I said I really want the things we’re doing, the ideas we’re having, the freedoms that Rails has given us, and Ruby, to think out of the box-what are these ideas we’ve come up with, and how can the be applied to other technologies that are perhaps more traditional?
And one of the first thing I thought of that had to do with databases was versioning databases.
Hampton: This is something that they don’t do. These DBAs are out there, and they’re pulling their hair out working with a Perl programmer and going, “Oh, you changed the database while we were going to production? Did you write me a conversion? What’s the SQL for this? How am I going to do this? Oh no!”
Hampton: Or they put up the site and it breaks. And Rails very quickly had migrations added to it, rather early in life. And that was the fantastic addition. That’s really changed the way that we handle our databases.
Sam: Yeah, that’s a key thing.
Hampton: People in other technologies aren’t going to use Ruby on Rails migrations. But it’s that idea; it’s what’s behind it, that’s important. It’s this, we have this idea as a community and we need to share this. I wouldn’t be surprised if the MySQL people-I would love it if they did, this would be my dream-which they came out just being inspired by Rails, they came out with their own way to version MySQL databases.
Just a little utility or something where you can save a file or a series of files that have instructions on converting data or just a way to version SQL conversion files, like files for migrations. Or whatever it is-choose your language-something like that would be really, really powerful. I think that is an idea that could really change other sectors of our…
Sam: Sure. I hear there’s a number of actual Java shops which are just using Ruby for migrations, for their databases.
Hampton: [laughs] Yeah. I really haven’t heard that.
Sam: Yeah, yeah. [laughs] They just take the Ruby and the migrations bit, and just use that in their projects, and it works fine.
Hampton: Yeah. Maybe they won’t have to do that, because-I mean, I’m glad they’re using Ruby, but they should probably be sticking in their own framework, at least when you’re working on something.
Sam: Cool. And so tell us about RailsConf; you’re doing a talk on REST-full abstractions.
Hampton: Yeah. Well, it’s funny. I actually kind of put in two talks. I put in one talk as myself, and that was, I was going to try to do another HAML talk because I figured HAML hasn’t been at the main RailsConf yet, and the international one, so I wanted to give that another try. Unfortunately, I turned it down.
But they did take, Jeff Hardy, one of my friends and coworkers, [laughs] in another talk I wanted to give, we put in his name too. He didn’t even know we were actually putting it his name.
Hampton: And he put me on as a co-speaker. That one ended up being accepted. And it’s for a new REST abstraction that we invented in-house to use on our projects at Unspace. The first thing that happened was, we went to RailsConf Europe and we saw DHH’s keynote, and that was the first time I had been anti-you know, the Internet keeps around opinions you had in the past way too well…
Hampton: I’ll probably be embarrassed by this podcast in a couple years because I’ll be like, “Gosh! I was totally missing that!”
But I didn’t like REST initially, and I saw his talk and I really sort of got it. I was like, “Wow!” Now I see, especially when you have an active resource or whatever, I really got it. It was like, “APIs aren’t just obscure.” To me, they had always this nirvana ideal. They were just like, “Whoa! Wouldn’t this be cute if we could integrate with other applications?”
And people were talking about it. The marketing douches were talking about it. I don’t know. It just never really hit me, until I saw DHH open up, build a quick little resource reader thing, and just started interacting with the database even though he wasn’t directly connecting to the database through the web server. I was like, “He did find!”
Sam: Absolutely, like it was a local thing, yeah, as if there was no server.
Hampton: Yeah, exactly. And that really drove it home for me. I’m like, “This is what we need to do.”
We go back home and we started doing a couple projects; we’re using the resource scaffolding-which I think is dumb, but most of us got started using it. So we started using that, and we started finding we’d want to nest some resources, and there’s almost no security built into that scaffolding at all. We found it really slow to handwrite our own.
I like to be a very, very, very fast programmer; I pride myself on my ability to add features very, very quickly. So to me to want to add comments to something, I’d have to go, “OK. Well, let me go copy and paste my index action, ” or “Let me go look it up, ” or “Let me try to remember and retype the same thing again, ” but build in whatever security I need into it. And I just started seeing these patterns happening.
And so Jeff-he was sort of the initially spark on this-he took it and made something in the lib folder, so you would include a REST controller. And I sort of liked it. I was like, “Sweet! Now I don’t have to keep rewriting this stuff.” But obviously, there was no way to turn off different things. There was no way to customize it. So I started thinking, “Well, what are we really doing?” I started looking at the patterns.
The parts that I was repeating in every single one of the REST calls, generally, it was always the name of the controller-let’s say messages-controller. And then I would know that the message class model is what I wanted, because as long as your controller’s named after the model, you can, without even any special thing, make a very good guess at least at what the model is. And with a little meta-programming magic, we can load up that class and ask it to do a find.
And then every time I want to take whatever that collection is, with a little more meta-programming, I’d like to name it @messages, and I’d like to make that available to my HTML template. Then I’d also like to call to XML on it perhaps, and also make that instantly available as an XML feed. Or maybe I want to tell it to turn on RSS, which would magically change my response block.
Anyhow, I started thinking in that zone, and I started thinking about what am I changing? What is the part that changes? Where is most useful if I had like callbacks perhaps built into something? I sort of thought, “Maybe there’s an after-create or an after-index or a response for index method I could override.” I don’t know. And I went through a couple very experimental prototype versions of the syntax.
Actually, one of the prototypes, we’re actually using in all of our current projects right now. Sort of how Handle started. We started using it internally first for actual projects.
Sam: So in the real world.
Hampton: Yeah, projectbreakout.com is using it. It’s actually full rest resources built. It’s called ‘let it rest’. Is what has ended up coming out of it? The syntax we have come up with now and the way to implement it is. I have to say, I was at first skeptical because I just didn’t know. Nobody has been able so far to take controllers and do anything with them, really.
Hampton: I have yet to see anything that has been like “oh wow, you just improved controllers.” They’ve been that zone that we don’t touch also, along with Action B. I mean active record is this fantastic little library that’s in rails. But action controller, it’s got some nice stuff in it. It’s pretty simple. I just define the actions I want and they just kind of happen. I hand load up most stuff, or I hand code what URL’s I want and I make those work with routes. Action view, I wasn’t really thrilled with our HTMLs. I would do the same thing every time.
It’s worked out really well. What is has ended up doing, is the amount of time it takes to implement now, a controller, something basic or complex is much shorter.
I can implement a comment controller in about three to four minutes and have comments working. Some of the other things, really interesting that it has led me to, is if I by constricting my controller.
I mean there are a lot of hooks in there that do custom things. I made sure there’s lots of hooks, lots of overrides, lots of ways to make sure your variables are scoped so when there’s a nested chain I’m preloading everything in my opinion my rest resource nested URL. Anyhow, I’m preloading it all and I’m doing all this magic.
But it sort of constrains you too, in a way. Every time I have to write an after create or after show index they’re called. Something like that, or after create fails. Any of these call backs and I have to implement them. I always feel a little dirty. My model should be able to make some of these decisions itself. If I tell a model to create itself, whatever I pass in as parameters through the web service, through the controller, by the time I get a create command of this model, I shouldn’t really be needing to do stuff around it.
A very well built model is a model that truly it is intelligent about how it needs to behave. An example of this is that we’re doing an online application system for a Canadian government thing. One of the design ideas we had was these applications, there’s a lot of them and they change often. So we really wanted it to be easy to go in and at will modify the views which would actually, when you view an application page, the moment you hit save is when all these key value pairs are saved, which are what are on the page.
The realization was that if someone wants to put in a fake field, or remove one, they’re either going to get in trouble or make themselves ineligible. Because in the end process, when all this gets printed out and a jury looks at it, it’s a grant system, and they make the decision on it, it disqualifies them.
Just like a normal application. If you have a physical paper application, I can not fill out a field, or write in something on the side at will, right? What I’m trying to say is that we came up with this idea that we should have some dynamic field names, basically. I ended up being able to do something with my parameters by using attribute writer called update attributes.
I was able to do using the [inaudible] by using the rails, parameters way. I was able to have it so that I didn’t have to change the, for running the entire application, the controller is five lines long.
Sam: That’s amazing.
Hampton: That’s for everything. Because the deal is the model takes in the parameters.
Sam: So thin controller, fat model.
Hampton: Right, right. Exactly! Who did it? That was Jamus?
Sam: Exactly, yes.
Hampton: OK, it was the fat model, skinny controller thing. Let it REST encourages you to do that. I could have said I want to pre-process a little. And if I say no, no, no, no, my model needs to be able to make these proper decisions. And it will do auto associations for you – let it REST will. You can also tell it to force an association. So if you create a new message, I can say force association with. That will make sure it assumes a method called current user, which is a pattern we use. I think I blogged about it a while ago. Actually I saw Jamus using it on the Rails wave blog too. Current underscore anything probably means it is pulling it out of the session instead of out of the parameters or some other value. It is something that will exist across the site. So anyhow, you can tell it every time somebody creates a message, it will automatically take current-user and assign it to the user property of that model. It gives you this nice little way of magically… I just wrote one line. Then for every edit, update or create, it makes intelligent decisions that are good defaults.
Sam: So you are just specifying where your design differs from the defaults.
Hampton: Yes, and large convention too. At Unspace, we have done eight Rails projects. Fairly large ones – pretty dang large. You know, not eBay or anything or NASA, but large enough. We have to do projects very quickly. This isn’t counting personal projects, which is probably eight of those too, which we have just launched for fun. Little Web experiments. So you take all that together, and I think we’re in a unique position as a company because there are not a lot of people who have done a lot of Rails applications. And this is just talking since we started at Unspace. Before that we were all doing it too. It’s interesting because it puts us in a unique position to try out and experiment with these solutions and make sure they are production ready.
Sam: You have to use them yourself and eat your own dog food.
Hampton: Absolutely, because I need them. I do so many projects that all of us get very frustrated with having to repeat things. I have noticed that startups that work on one project, and work on it for two years until they launch the site. I know a lot of people that work at places like that. They haven’t even gotten to try HAML because they already have so much legacy code sitting there that they don’t want… they have other developers… they can’t really experiment. Generally they are running off pre Rails 1.0 code because they have been working for about a year. They were doing their emailers the wrong way – the old way. I think every one of our projects at Unspace is 1.2 at least, if not generally on Edge. As a contractor on Rails, it is such a new technology; there are not many people who get to just… I’m starting another project in three weeks. So in the next three weeks, there’s another one. I’ll probably use the second version of let it REST. That’s the one that we’re going to reveal at RailsConf.
Sam: So is this thing out yet? Can I download it and use it in my application?
Hampton: No, no, no, you can’t. We are currently still using the prototype.
Sam: You’re teasing us all. [laughing]
Hampton: I just haven’t had time with all these projects, and HAML 1.5. And I’m now working on a book.
Sam: Yes, tell us about the book. What’s it about?
Hampton: It’s a beginning Rails book for actual true beginners. Most people listening to this will find it quite boring, very slow. The Agile Rails book assumes that you know a lot when you walk into it. You need to know what an object is in general. He gives a very terse introduction, but in general, you are supposed to have some technical knowledge. It’s written for people who have done coding before, and especially Web coding before. So we’re trying to write a book for the actual beginners. If your brother or sister says, “Oh, I want to learn Rails” this is the kind of book to give them, because it just starts very simple…
Sam: “I’ve seen this web development malarkey, and I want to give it a try.”
Hampton: Exactly. We don’t really cover HTML; we assume you at least know some HTML.
Sam: Do you assume people have a Mac? [laughs]
Hampton: No, not at all. Shortest installation instructions are for Ubuntu, because… That’s actually the third talk I’m giving, but whole other subject. It’s about installing Rails on Ubuntu and running Ubuntu servers.
Sam: So it’s a book for beginners.
Hampton: Beginners. I’ve come on it very, very late, like the support batter or something. But I’ve been tangentially involved with it, emotionally and spiritually, for a while now. It’s really shaping up. I’m very, very honored to even get to work on this thing, because it’s really coming out fantastically. Who knows, maybe it’ll be a huge flop, but this is the kind of book I would recommend to somebody else – and I don’t say that lightly, because there’s a lot of really crappy Rails books out there right now. And there are really some great ones too, that’s not to hate on anybody else, but….
You know, I’m totally going to…. Is there defamation laws? You know what’s the worst single Rails book that has ever existed on this planet? I want to send a copy of this to DHH, because I think he would begin to cry, and he would throw it; he would tear it in half and run down the street and strip off his clothes, screaming “Stella!”
Sam: “You have not understood me!”
Hampton: It’s the Wrox Rails book. Wrox.
Sam: I’ve never heard of that one.
Sam: That’s probably a good thing.
Hampton: We’ve been doing a lot of research, trying to find out: what makes a really good beginner’s book? What are the books out there, right now, covering? How can we make sure we cover the right things? What did they do right, and what did they do wrong? We’re way behind schedule, but it should be coming out in May.
We really wanted to concentrate on these ideas, so we bought this book. I don’t think the guy actually knows…. Yeah, Dr. Steven Holzner. I would like to have a conversation with you, Mr. Steven Holzner. The book goes in a completely random order. It doesn’t even cover…. It’s not written with objects, nearly at all. Active record, I don’t even think he covers…. It barely covers associations. The projects, the HTML, is all invalid.
Sam: This is a beginner book?
Hampton: It’s a beginner book, and he doesn’t even seem to know how to code Ruby. It’s not even Ruby. Gosh, I’m being harsh here. W’s going to read our book and just be like, “Oh, look, these guys made a small mistake.” This guy is apparently… the back cover says he’s published, I think, something like 100 books or something like that.
Sam: A prolific writer.
Hampton: Yeah, “prolific” is a nice term for it. Just churns them out. And it’s like, nothing against Windows, but yeah, they’re all Windows screenshots, using actual Windows Notepad. And, oh, he uses IE, which… I’m sorry, you know, there’s no excuse for that. Use Opera…. Actually, use what you want, but don’t write a book about it.
Hampton: I can’t even explain to you how bad it is. Please don’t buy this book.
Sam: So the book you’re writing or you’re helping with…
Hampton: I’ve done with my rant.
Sam: Keep ranting!
Hampton: I could quote it, if you want.
Hampton: Just kidding.
Sam: Where was most of the writing actually taking place? Did you do it at your desk?
Hampton: Right now, Jeff’s wife is a teacher and she’s at work, and I’m taking a break out of our writing today to do this interview. No, we’re mostly…. One of our co-authors, Clovis, is in Dubai, which makes collaborating with him kind of hard.
I’m here in Fonthill, Ontario, which is a huge town of literally hundreds. [laughs] Jeff has a huge sprawling house, of course, because it’s in the middle of nowhere, and they’re cheap. Unlike me in the city, where you pay per inch. No, we just have been writing at home, at his house mostly, every week.
Sam: So do you have any advice for people who want to, potentially, write a book?
Hampton: Don’t do it!
Sam: Don’t do it.
Hampton: No, don’t do it. It really is hard. Especially if you want to do it well. I think I could have written a Holzner-esque book pretty easily: just keep typing, don’t make grammar mistakes, do all the screenshots, type the code. To be honest, he wrote the book while he was learning Rails and Ruby at the same time, it’s pretty clear. We could have done that. If you want to write a crappy book, go for it. You can brag about it to all your friends; your mom will be really impressed and proud of you. You won’t make any money, but it’s all right. Unless you write a hundred – then you might be doing all right.
I’ve heard the term “labor of love” before. Coming onto this book, for me, was actually a hard decision, with all the stuff going on. But you know, in the end it was really: how much value is in it to be able to say “author of” – which is quite a flattering title, except it’s…. What’s that worth, at what point in your life? And can you be proud of that work? How many people can just claim to be an author of a book that’s just not very good?
I think, if you have a passion for writing, start writing it. Write the book before you get a publisher – that’s probably what I’d say, too. Just start writing. If you can do it without a publisher, then it’s about the same as doing it with one. If you walked in to a publisher today with any sort of Rails book and it was half-written, you would instantly be brought on board. But do the first half. Write half of a book before you bring it there, because it’s more fun when you’re doing it yourself.
You’re also realizing how incredibly hard it is to explain yourself well. It’s just stressful; it’s difficult. You worry about it. Like, I’d always take showers and think about my coding. But sometimes now I take a shower and think, “Oh, I can explain this better” or “Maybe this chapter could be cleaned up a little” or “Maybe this should be our example.”
Sam: Constant refactoring process, then, really.
Hampton: If you don’t have a job, or something, and you want something to do, write a book. Go for it. But if you actually have to pay bills and keep working and run open-source projects and travel, speaking…. [laughs] If you want to do all that together, I would not recommend it.
So I don’t know. Whatever – it’s a personal decision everybody has to make. If you can’t write, don’t do it, please! There are enough terrible books out there. Rails – we need to make sure we have good books out there. I’m talking to you, Dr. Steve Holzner, Ph.D.!
Sam: [laughs] Right. Well, that’s for the Ph.D. hatred here.
Hampton: Oh, yeah! Yeah. [laughs] Ph.Ds are great.
Sam: Well, they’re not all.
Hampton: To be a dropout…
Sam: They’re a nightmare. I’m still writing my thesis up, as well, and all the advice you’ve given about “don’t do it” absolutely applies. It’s really very hard.
Hampton: Actually, that’s very true – it’s like getting your doctorate, yeah. It’s something that will never go away. Sure, that makes it better, but so does herpes. I mean, you know?
Sam: [laughs] Absolutely.
Hampton: But was it worth it to get it? That’s the real question. Sometimes it is. [laughs]
Sam: So have you got any thing else to say, anything to shout out whilst you’re on your platform?
Hampton: Yeah, what would I say… I have a lot of things that I’m able to rant about, so I don’t even know what the last one would be – except for “Give HAML a try.” Oh yeah, there we go, that would be my thing. If you think you can do something better, then do it, because I’d love to use it!
Give it a try. Yes, it looks weird for the first couple minutes you look at it, but then very quickly, if you know CSS, your brain will start to parse it, I promise. I can do like a challenge or something, like: if anybody uses it and really can say they actually hate it, after they give it a real good try…
Sam: You’ll give them their money back?
Hampton: A lollipop. Their money back, for my open-source code? But I encourage people – don’t be afraid to actually try something new. It’s easy to change your application layout. That’s the good one, because that will actually make sure your whole page looks better.
Sam: And when will it be out for people to play around?
Hampton: I’m probably going to release it at RailsConf.
Hampton: We didn’t release HAML until we were actually at the conference in London, so I think I’ll probably do the same thing again. It was kind of fun to give it a world debut. There is some syntax you can see on the web about it right now, but it is not the official syntax, and it won’t be what’s in the final release. We’re cleaning it up and doing some crazy new cool Ruby things to it – make it more fun to write out your controllers. So stay tuned for that!
Sam: OK. Nice speaking to you. Take care.
Hampton: Thanks, Sam.