前言
For nearly a decade within Bell Laboratories, I labored at implementing C++. First it was on cfront, Bjarne Stroustrup's original C++ implementation (from Release 1.1 back in 1986 through Release 3.0, made available in September 1991). Then it was on what became known internally as the Simplifier, the C++ Object Model component of the Foundation project. It was during the Simplifier's design period that I conceived of and began working on this book.
十年可以磨一劍;《十年》可以愛一個(gè)人;而我,Stanley Lippman, 用十年的時(shí)間,在貝爾實(shí)驗(yàn)室攻克C++編譯器。
剛開始我做的是cfront。這款編譯器代表了Bjarne Stroustrup(你們一般稱其為“C++之父”,我們當(dāng)時(shí)的領(lǐng)導(dǎo)之一)最初的C++設(shè)計(jì)思想。我們從1986年的1.1發(fā)布版陸續(xù)干到最終的1991年9月的3.0發(fā)布版。
cfront項(xiàng)目結(jié)束后,我繼而投身于研發(fā)一個(gè)內(nèi)部稱為Simplifier的組件。它是Foundation項(xiàng)目中的C++對(duì)象模型。正是在設(shè)計(jì)Simplifier期間,我開始醞釀并起草(conceived of and began working on)這本書。
What was the Foundation project? Under Bjarne's leadership, a small group of us within Bell Laboratories was exploring solutions to the problems of large-scale programming using C++. The Foundation was an effort to define a new development model for the construction of large systems (again, using C++ only; we weren't providing a multilingual solution). It was an exciting project, both for the work we were doing and for the people doing the work: Bjarne, Andy Koenig, Rob Murray, Martin Carroll, Judy Ward, Steve Buroff, Peter Juhl, and myself. Barbara Moo was supervising the gang of us other than Bjarne and Andy. Barbara used to say that managing a software group was like herding a pride of cats.
地球人也許會(huì)好奇,F(xiàn)oundation項(xiàng)目在做些什么工作呢?在Bjarne班長(zhǎng)的帶領(lǐng)下,我們一群小伙伴在貝爾實(shí)驗(yàn)室里研究怎樣讓C++具備廣泛的適用性,從而可以應(yīng)用于大型(large-scale)編程開發(fā)中。Foundation項(xiàng)目致力于確立(define)一種新的構(gòu)建大型系統(tǒng)的開發(fā)模式。再次說(shuō)明,我們只使用C++,并不提供其他語(yǔ)言的解決方案。
這個(gè)項(xiàng)目屌炸天。令人激動(dòng)的不僅是項(xiàng)目所做的工作本身,也包括參與其中的大牛:Bjarne, Andy Koenig, Rob Murray, Martin Carroll, Judy Ward, Steve Buroff, Peter Juhl, 當(dāng)然還有我;)。Barbara Moo負(fù)責(zé)管理這群小伙伴,除了Bjarne和Andy(這倆特權(quán)分子:p)。Barbara常說(shuō)管理這個(gè)團(tuán)隊(duì)"真讓本宮操碎了心"(like herding a pride of cats)。
We thought of the Foundation as a kernel upon which others would layer an actual development environment for users, tailoring it to a UNIX or Smalltalk model as desired. Internally, we called it Grail, as in the quest for, etc. (It seems a Bell Laboratories tradition to mock one's most serious intentions.)
我們把Foundation視為一個(gè)內(nèi)核。這樣開發(fā)人員就能把一個(gè)開發(fā)環(huán)境搭建在這個(gè)內(nèi)核之上,并能對(duì)這個(gè)內(nèi)核進(jìn)行適當(dāng)裁剪(tailor)從而匹配UNIX或SmallTalk的數(shù)據(jù)模型。我們內(nèi)部把Foundation比作我們一直在追尋的(as in the quest for)耶穌的圣杯(Grail)。貝爾實(shí)驗(yàn)室的光榮傳統(tǒng)就是拿嚴(yán)肅的意圖開涮(It seems a Bell Laboratories tradition to mock one's most serious intentions)。
Grail provided for a persistent, semantic-based representation of the program using an object-oriented hierarchy Rob Murray developed and named ALF. Within Grail, the traditional compiler was factored into separate executables. The parser built up the ALF representation. Each of the other components (type checking, simplification, and code generation) and any tools, such as a browser, operated on (and possibly augmented) a centrally stored ALF representation of the program. The Simplifier is the part of the compiler between type checking and code generation. (Bjarne came up with the name Simplifier; it is a phase of the original cfront implementation.)
Rob Murray提出了面向?qū)ο竽P筒⒅麨锳LF。Foundation可創(chuàng)建持久耐用的基于語(yǔ)義的面向?qū)ο蟮膽?yīng)用程序?qū)嶓w。我們使用Foundation把傳統(tǒng)的編譯器部分抽出,放在了一些專屬可執(zhí)行文件中。語(yǔ)法解析器構(gòu)建了當(dāng)前應(yīng)用程序的符合面向?qū)ο竽P偷腁LF層級(jí)結(jié)構(gòu)。其他的組件(包括類型檢查器、簡(jiǎn)化器、代碼生成器等)以及一些工具(例如瀏覽器)會(huì)對(duì)應(yīng)用程序的這個(gè)創(chuàng)建好并被集中存放(stored centrally)的ALF實(shí)體執(zhí)行相關(guān)操作。簡(jiǎn)化器在類型檢查和代碼生成之間的階段工作。Bjarne將它命名為Simplifier;它是最初的cfront編譯器的一個(gè)重要組成部分。