Seibel: So what languages would you say you’ve really lived and breathedwith enough to claim as your own?

Fitzpatrick: Perl. C. Back in the day, BASIC, but I’m not even sure BASICcounts. I wrote a lot of Logo too. In our Logo class in elementary school,people were doing pen up, pen down and I would be not in graphicsmode—there’s some key to get out of graphics mode—writing functions.My teacher would come over and say, “What are you doing? You’re doingthe wrong thing. You’re supposed to be drawing houses.” “No, I’m writingLogo. Look,” “No, you’re not.” Then at the end of the class I’d dosomething—I had a library that drew every letter of the alphabet, but atarbitrary scales and rotations. So I could print entire messages on wavybanners going into the distance and stuff, and everyone was like, “What thefuck?” I don’t know if that one counts either.

But a lot of Perl and C, and then a lot of C++ in college for work and forWindows stuff. Then I forgot C++, or it atrophied, and now at Google, inthe last year, it’s a lot of C++, Python, and Java. I also wrote a lot of Javaback in the day when it first came out, but then I got sick of it. Now I’mwriting a lot of Java again, and I’m kinda sick of it.

Seibel: Does it matter much to you what language you use?

Fitzpatrick: I’m still not happy with any of them. I don’t know what exactlywould make me totally happy. I hate that for a given project you have tojump around all the time. I want something that lets me have static typesand checks all that stuff at compile time, when I want. Perl gets me prettyclose in that it lets me write in any style I want. It doesn’t let me do enoughstatic checking at compile time but I can make it blow up pretty hard when Iwant to a runtime. But it’s still not good enough.

I want optional static typing. In Perlbal, there’s no reason for half the thingsto be performant except for the core, copying bytes around. I would like togive the runtime hints in certain parts of the code and declare types. But if Iwant to be lazy and mock something out, I want to write in that style.

Seibel: So you want types mostly so the compiler can optimize better?

Fitzpatrick: No. I also want it to blow up at compile time to tell me like,“You’re doing something stupid.” Then sometimes I don’t care and I want itto coerce for me at runtime and do whatever. I don’t want to be toooptimistic about Perl 6, but they’re preaching a lot of things I want to see.But I don’t think it’ll ever come out.

Seibel: Do you like C++?

Fitzpatrick: I don’t mind it. The syntax is terrible and totally inconsistentand the error messages, at least from GCC, are ridiculous. You can get 40pages of error spew because you forgot some semicolon. But—like anythingelse—you quickly memorize all the patterns. You don’t even read thewords; you just see the structure and think, “Oh, yeah, I probably forgot toclose the namespace in a header file.” I think the new C++ spec, eventhough it adds so much complexity, has a lot of stuff that’ll make it lesspainful to type—as far as number of keystrokes. The auto variables and thefor loops. It’s more like Python style. And the lambdas. It’s enough that Icould delude myself into thinking I’m writing in Python, even though it’sC++.

Seibel: And you use C++ for efficiency.

Fitzpatrick: Yeah, pretty much. I mostly use it at Google. Anything that’shalfway performant is in C++ there. I also write a ton of Java at Google.

Seibel: From what I understand, Google has a C++-centric culture becausethat’s what they used originally and they’ve built a whole bunch of softwareinfrastructure around it. While you can’t undo all that history, there’sprobably a lot of code written at Google in C++ where it’s not reallynecessary for performance.

Fitzpatrick: Especially because, over time, Java has gotten faster and theJVM has gotten a lot smarter. The thing that annoys me about Java is thateveryone has such a strong aversion to JNI stuff. Sometimes a library is inC++. The Python people—in the outside community and inside Google—don’tcare. They’re like, “Oh, we’ll, SWIG-wrap it.” They get on their way andthey’re happy. Python gets support for something right away if it’s inC++ because they’re not religious about what the source language is.

Java people are like, “Must be pure Java. We cannot use JNI because then ifthe JVM crashes, we don’t know why.” The problem with that is you end upwriting everything twice, once for C++ and Python and all the otherlanguages, and then once for Java. So if they could come up with a goodembedding story or get over this fear of JNI, then I wouldn’t mind it.

Seibel: What about explicit memory management versus garbagecollection? People still argue about that. Do you have a strong opinion oneway or the other?

Fitzpatrick: No, not really. I’m amused to watch other people’s strongopinions when generally they’re not backed up by anything. I personallydon’t find it that annoying to manage memory, at least in C++ with likescoped pointers. I can write in C++ for days and never actually say “new”or “delete”. It seems to just all kind of work.

I rewrote memcached inside Google to work with Google infrastructureand to add it to App Engine. That was all written in C++ because I needed avery exclusive control of memory to reduce fragmentation. So I reallyappreciated having it there.

Seibel: The original memcached was in C. Did you redo it in C++ becauseC++ is more accepted within Google, or were there other advantages?

Fitzpatrick: I started to take the existing one and port it but it turned outto be more work. Memcached isn’t that much code to begin with, so it wasa lot quicker to just rewrite in C++. It was like half as much code, rewritingit in C++.

Seibel: Do you think that was because of C++ or just because you weresmarter this time around?

Fitzpatrick: It could be. Once, when I was 11 or 12, we were on a triparound the US and I wrote that game Mastermind on a TI-85 calculator. I’mwriting this program—a couple hundred lines—on this tiny little screentrying to remember where I am. I ended up deleting the damn thing twice.So I wrote the thing three times. But then it got so easy. That’s a goodpoint—the second time around it was a lot easier.

Seibel: You’ve done a lot of your work in Perl, which is a pretty high-levellanguage. How low do you think programmers need to go—doprogrammers still need to know assembly and how chips work?

Fitzpatrick: I don’t know. I see people that are really smart—I would saythey’re good programmers—but say they only know Java. The way theythink about solving things is always within the space they know. They don’tthink end-to-end as much. I think it’s really important to know the wholestack even if you don’t operate within the whole stack.

When I was doing stuff on LiveJournal, I was thinking about things fromJavaScript to how things were interacting in the kernel. I was reading Linuxkernel code about epoll and I was like, “Well, what if we have all these longTCP connections and JavaScript is polling with these open TCP connectionsthat are going to this load balancer?” I was trying to think of how muchmemory is in each structure here. That’s still somewhat high-level, but thenwe were thinking about things like, we’re getting so many interrupts on theEthernet card—do we switch to this NAPI thing in the kernel where ratherthan the NIC sending an interrupt on every incoming packet it coalescesthem to boundaries that were equivalent to 100 megabits speed eventhough it was a gigabit NIC. We were collecting numbers to see at whatpoint this made sense and freed up the processor.

We were getting a lot of wins for really low-level stuff. I had somebodyrecently tell me about something: “Java takes care of that; we don’t have todeal with that.” I was like, “No, Java can’t take care of this because I knowwhat kernel version you’re using and the kernel doesn’t support it. Yourvirtual machine may be hiding that from you and giving you someabstraction that makes it look like that’s efficient, but it’s only efficient whenyou’re running it on this kernel.” I get frustrated if people don’t understandat least the surface of the whole stack.


Перейти на страницу:
Изменить размер шрифта: