Seibel: And Erlang was one of those new and useful things you expectedthem to use?

Armstrong: Yes. Absolutely. So what happened was, first of all it was justProlog. I sort of made a little language and people started using it. And thenRobert Virding came along and said, “Hey, this looks like fun.” And he’dbeen reading my Prolog and he said, “Can I modify it a bit?” That’s prettydangerous because Robert says that and you end up with one comment atthe top of the program that says, “Joe thought of this stuff and I’ve changeda bit,” and then it’s completely changed. So Robert and I just rewrote thisstuff back and forth and we had great arguments—“Ahhh, I can’t read yourcode, it’s got blanks after all the commas.”

Then we found somebody inside Ericsson who wanted a new programminglanguage or wanted a better way of programming telephony. We met upwith them once a week for about, I can’t remember, six months, ninemonths. And the general idea was we would teach them how to programand they would teach us about telephony—what the problem was. Iremember it was both frustrating and very stimulating. That changed thelanguage because we had real people using it and that resulted in a studywhere they thought, “Yeah, this would be OK but it’s far too slow”—theymeasure the performance of it and said, “It’s gotta be 70 times faster.” Sothen we said, “This phase is now over. We’ll make it go 70 times faster andthey’ll carry on programming it and we have to do this in two years orsomething.”

We had several false starts. And we had several really embarrassingmoments. Big mistake: don’t tell people how fast something is going to bebefore you’ve implemented it. But ultimately we figured out how to do it. Iwrote a compiler in Prolog. And Rob was doing the libraries and things.We’re now kind of two years in. Then I thought I could implement thisabstract machine in C so I started writing my first-ever C. And MikeWilliams came along and looked at my C and said, “This is the worst C I’veever seen in my entire life. This is appallingly bad.” I didn’t think it was thatbad but Mike didn’t like it. So then Mike did the virtual machine in C and Idid the compiler in Prolog. Then the compiler compiled itself and producedbyte-code and you put it in the machine and then we changed the grammarand the syntax and compiled the compiler in itself and came out with animage that would bootstrap and then we’re flying. We’ve lost our Prologroots and we’re now a language.

Seibel: Has there ever been anything that you’ve found difficult to workinto the Erlang model?

Armstrong: Yeah. We abstract away from memory, completely. If youwere turning a JPEG image into a bitmap data, which depends on theplacement of the data in a very exact sense, that doesn’t work very well.Algorithms that depend on destructively upgrading state—they don’t workwell.

Seibel: So if you were writing a big image processing work-flow system,then would you write the actual image transformations in some otherlanguage?

Armstrong: I’d write them in C or assembler or something. Or I mightactually write them in a dialect of Erlang and then cross-compile the Erlangto C. Make a dialect—this kind of domain-specific language kind of idea. Or Imight write Erlang programs which generate C programs rather than writingthe C programs by hand. But the target language would be C or assembleror something. Whether I wrote them by hand or generated them would bethe interesting question. I’m tending toward automatically generating Crather than writing it by hand because it’s just easier.

But I’d use an Erlang structure. I’ve got some stuff that does my familyimages and things. So I use ImageMagik with some shell scripts. But I controlit all from Erlang. So I just write wrappers around it and call os:command andthen the ImageMagik command. So it’s quite nice to wrap up things in.Wouldn’t want to do the actual image processing in Erlang. It’d be foolish towrite that in Erlang. C’s just going to be a lot better.

Seibel: Plus, ImageMagik is already written.

Armstrong: That doesn’t worry me in the slightest. I think if I was doing itin OCaml then I would go down and do it because OCaml can do that kindof efficiency. But Erlang can’t. So if I was an OCaml programmer: “OK, whatdo I have to do? Reimplement ImageMagik? Right, off we go.”

Seibel: Just because it’s fun?

Armstrong: I like programming. Why not? You know, I’ve always beensaying that Erlang is bad for image processing—I’ve never actually tried. Ifeel it would be bad but that might be false. I should try. Hmmm, interesting.You shouldn’t tempt me.

The really good programmers spend a lot of time programming. I haven’tseen very good programmers who don’t spend a lot of time programming. IfI don’t program for two or three days, I need to do it. And you get better atit—you get quicker at it. The side effect of writing all this other stuff is thatwhen you get to doing ordinary problems, you can do them very quickly.

Seibel: Is there anything that you have done specifically to improve yourskill as a programmer?

Armstrong: No, I don’t think so. I learned new programming languages butnot with the goal of becoming a better programmer. With the goal of beinga better language designer, maybe.

I like to figure out how things work. And a good test of that is to implementit yourself. To me programming isn’t about typing code into a machine.Programming is about understanding. I like understanding things. So whywould I implement a JPEG thing like we talked about earlier? It’s because I’dlike to understand wavelet transforms. So the programming is a vehicle tounderstand wavelet transformations. Or why do I try to do an interface toX Windows? Because I wanted to understand how the X protocol worked.

It’s a motivating force to implement something; I really recommend it. If youwant to understand C, write a C compiler. If you want to understand Lisp,write a Lisp compiler or a Lisp interpreter. I’ve had people say, “Oh, wow,it’s really difficult writing a compiler.” It’s not. It’s quite easy. There are a lotof little things you have to learn about, none of which is difficult. You haveto know about data structures. You need to know about hash tables, youneed to know about parsing. You need to know about code generation. Youneed to know about interpretation techniques. Each one of these is notparticularly difficult. I think if you’re a beginner you think it’s big andcomplicated so you don’t do it. Things you don’t do are difficult and thingsyou’ve done are easy. So you don’t even try. And I think that’s a mistake.

Seibel: Several of the folks I’ve talked to have recommended learningdifferent programming languages because it gives you different perspectiveson how to solve problems.

Armstrong: Languages that do different things. There’s no point learninglots of languages that all do the same thing. Certainly I’ve written quite a lotof JavaScript and quite a lot of Tcl and quite a lot of C and quite a lot ofProlog—well, an enormous amount of Prolog and an enormous amount ofFortran and an enormous amount of Erlang. And a bit of Ruby. A bit ofHaskell. I sort of read all languages and I’m not fluent at programming themall. Certainly I can program in quite a lot of languages.

Seibel: No C++?

Armstrong: No, C++, I can hardly read or write it. I don’t like C++; itdoesn’t feel right. It’s just complicated. I like small simple languages. It didn’tfeel small and simple.

Seibel: What languages influenced the design of Erlang?

Armstrong: Prolog. Well, it grew out of Prolog, obviously.

Seibel: There’s not a lot of Prolog discernible in it today.

Armstrong: Well, unification—pattern matching, that comes directly fromProlog. And the kind of data structures. Tuples and lists have slightlydifferent syntax in Prolog but they’re there. Then there was Tony Hoare’sCSP, Communicating Sequential Processes. Also I’d read about Dijkstra’sguarded commands—that’s why I require that some pattern should alwaysmatch, there shouldn’t be a default case—you should explicitly require thatsome branch always match. I think those are the main influences.


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