Arantium Maestum

プログラミング、囲碁、読書の話題

PerlisとDijkstraとBauerとAPL

かなり前に、DijkstraとWirthがAPLの話をIversonから聞いて「俺たちの目が黒いうちはこんな言語は絶対流行らせない」と言ったという話をどこかで読んだ気がしていてソースを探していたのだけど、なかなか見つからずに残念に思っていた。

DijkstraがAPLのことを嫌っていたのは結構有名で

APL is a mistake, carried through to perfection. It is the language of the future for the programming techniques of the past: it creates a new generation of coding bums. - EWD498 - How do we tell truths that might hurt?

I thought that programmers should not be puzzle-minded, which was one of the criteria on which IBM selected programmers. We would be much better served by clean, systematic minds, with a sense of elegance. And APL, with its one-liners, went in the other direction. I have been exposed to more APL than I’d like because Alan Perlis had an APL period. I think he outgrew it before his death, but for many years APL was “it.” - CACM Interview 2001

などの発言が散見される。2番目のCACMインタビューではPerlisがAPLが好きだったという話も出てくる。Perlisが好んだ言語だったので不本意ながらAPLに接触する機会があったとDijkstraが言っているのは、この二人はどのような関係だったのだろうと想像してしまって面白い。

(ちなみに1番目のEWD498はDijkstra版Epigramsとも言えそうだが、Perlisのそれに比べてあまりにも毒が強烈)

さて前日の記事でPerlisの話をしたので、少しPerlis関連でネットを漁っていたら

www.jsoftware.com

というPerlis自身によるAPLの話が出てきた。APL'78 Conferenceでの講義録らしい。

PerlisにとってのAPLの良さ、言語の進化、思考を表現するツールとしてのプログラミング言語ワンライナーの功罪、プログラミング教育におけるBASICの危険性などいろいろと楽しい話が出てくる。またEpigramsの作者らしく非常に文章が洗練されている。

DijkstraとBauer、APLを嫌う

そしてこの文章の冒頭でようやくDijkstraの「俺の目の黒いうちは・・・」発言のソースを見つけた。ただしDijkstraの相方はWirthではなくてFritz Bauerだった。

I was at a meeting in Newcastle, England, where I’d been invited to give a talk, as had Don Knuth of Stanford, Ken Iverson from IBM, and a few others as well. I was sitting in the audience sandwiched between two very esteemed people in computer science and computing — Fritz Bauer, who runs computing in Bavaria from his headquarters in Munich, and Edsger Dijkstra, who runs computing all over the world from his headquarters in Holland.

"Edsger Dijkstra, who runs computing all over the world from his headquarters in Holland."というのはなんだかBond villainっぽくていい感じではある。

Bauer, on my left, ... muttered under his breath to me, in words I will never forget, “As long as I am alive, APL will never be used in Munich.” And Dijkstra, who was sitting on my other side, leaned toward Bauer and said, “Nor in Holland.”

そしてまた発言も非常に悪役らしくていい。まあこの話はAPL好きのPerlisがAPL Conferenceで講義した時に出たものだから、まさにBauerとDijkstraは悪役として出てるわけだが。

しかし1960年にALGOLが制定されるとき、再帰を言語仕様に入れるかどうかで喧嘩して騙し討ちに近いAmsterdam plotにまでなったBauerとDijkstraが仲良くAPLの悪口を言っているのは感慨深いものがある。

PerlisとDijkstra、BASICを嫌う

Perlisの講義の終わりのほうで、少し唐突にBASIC批判が始まる:

...we’ve got to get BASIC out of the public school system. BASIC is really harmful for young people. It’s all right for old-timers. But for young people in the 11th and 12th grades of high school, in junior colleges, and in universities, the belief that by writing BASIC programs they are appreciating the beauty of programming at the exercise level that they do, and can do, in the amount of time available to them — that idea is pernicious. It is very dangerous, to boot. We are creating a set of semiliterates...

言語仕様がいけてないとかそういう話ではなく、「BASICで教育することは危険だ」とまで断言している。この発言はDijkstraのBASIC批判を彷彿とさせる:

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. - EWD498 - How do we tell truths that might hurt?

ただ、Dijkstraの発言は「いつものDijkstraだ」("arrogance in computer science is measured in nano-dijkstras" - Alan Kay)と安心して聞けるが、Perlisも同じようなことを言っているというのは面白い。一体BASICのどういうところがここまで忌み嫌われるのだろうか。

Epigrams

あとはいくつか面白い部分を抜粋してみる。

APLが多彩な表現を可能にする、という話:

If Shakespeare were alive today, he’d be a programmer, and he’d be writing one-liners in APL.

ある意味Perlに似ているのかもしれない。There's more than one way to do it。そういえばIf Hemmingway Wrote JavaScriptって本があったな・・・

プログラミング言語が思考を表現できるか、という話:

Some years back, we had a visit at Carnegie from a person at MIT whose name I’ve forgotten. He started to give us a lecture in a little office about some programming issues in LISP. He went up to the blackboard and he spoke LISP. Everything he wanted to describe, he described in terms of parentheses and CONS and CARS and CDRS. He found himself quite capable of expressing his ideas in the language in which he programmed. Not once during the half hour or so that he lectured to us did I see the inevitable block diagram, the flow charts that show up on the blackboard with things written in semi-English. He didn’t need them. And at the time I said to myself, ”LISP has a very precious character, if indeed there are some people who can express programming ideas to other people in the language in which they program.” I can’t do that with ALGOL; never have I been able to do it with ALGOL.

ここでいう思考というのはプログラミングの概念なのでそこまで神秘的な話ではないが、それにしても現代からするとALGOLの表現力が弱かったのか?という気もしなくもない。まあUMLで説明したくなるっていうのは似たような話だろうか?

プログラミング言語にいくら機能を追加しても完璧にはならない、という話:

...programming, by its very nature, is a kind of bootstrapping activity. What Iverson and God give you today, you’ll find insufficient tomorrow.

ここでGodが出てくるのがいい。

APLを理解すればプログラミング言語全部理解したことになるという話:

once you’ve learned APL, you know BASIC, you know FORTRAN, you know ALGOL, indeed, I think you know all programming languages. You don’t know how you know them, but you know them.

なんだかめんどくさい言語オタクみたいなことを言い出してる・・・

しかしバランスをとって、プログラミング言語の布教の話:

And it certainly shouldn’t be a goal of people who use APL to stand forth and say, “Why do you jackasses use these inferior linguistic vehicles when we have something here that’s so precious, so elegant, which gives me so much pleasure? How can you be so blind and so foolish?” That debate you’ll never win, and I don’t think you ought to try.

これは好きな言語がAPLであれ、ML、LispHaskell、Rustなどなどであれ、余計な一言を言いたくなる気持ちをうまく捉えた箴言だと思う。肝に銘じたい。