TAOUP初译稿_HOOK

Preface

前言

 

Unix is not so much an operating system as an oral history.

--

译文Unix与其说是一个操作系统还不如说是一部口述历史

<author>NealStephenson</author>

There is a vast difference between knowledge and expertise. Knowledge lets you deduce the right thing to do; expertise makes the right thing a reflex, hardly requiring conscious thought at all.

译文知识体系与专业技能大相径庭。知识体系让你推演出做什么事是正确的;专业技能使正确的事情成为一种条件反射――跟本不需要刻意去思考。

 

This book has a lot of knowledge in it, but it is mainly about expertise. It is going to try to teach you the things about Unix development that Unix experts know, but aren’t aware that they know. It is therefore less about technicalia and more about shared culture than most Unix books — both explicit and implicit culture, both conscious and unconscious traditions. It is not a ‘how-to’ book, it is a ‘why-to’ book.

译文虽然本书囊括了大量的知识,但它却着力于专业技能。本书试图教给你一些关于Unix开发的技能。尽管Unix专家们在头脑中已经形成这些技能,但他们并没有意识到这一点。因此,相比于大多数Unix书籍而言,本书不会在技术上浓墨重彩,而是更多地论述共享文化,一种既明确又含蓄的文化,一种感知和不可感知相交织的传统。这不是一本关于“如何这样做”的书,而是一本“为什么这样做”的书。

 

The why-to has great practical importance, because far too much software is poorly designed. Much of it suffers from bloat, is exceedingly hard to maintain, and is too difficult to port to new platforms or extend in ways the original programmers didn’t anticipate. These problems are symptoms of bad design. We hope that readers of this book will learn something of what Unix has to teach about good design.

译文由于大多数软件设计拙劣,“为什么这样做”在实践层面上就显得尤为重要。许多软件遭受代码膨胀的困扰,维护起来极端困难,同时难以移植到新的平台上,或者无法以一种当初程序开发者不曾预料的方式扩展。以上罗列的问题正是糟糕设计的症状所在。我们希望本书读者能够领会到一些Unix所必然传授的良好设计思想。

 

This book is divided into four parts: Context, Design, Tools, and Community. The first part (Context) is philosophy and history, to help provide foundation and motivation for what follows. The second part (Design) unfolds the principles of the Unix philosophy into more specific advice about design and implementation. The third part (Tools) focuses on the software Unix provides for helping you solve problems. The fourth part (Community) is about the human-to-human transactions and agreements that make the Unix culture so effective at what it does.

译文本书分为四个部分:背景,设计,工具和社区。第一部分(背景)是关于哲学和历史的讨论,其目的是为以后的论述提供基础和动力。第二部分(设计)把Unix哲学的一些原则展开到更加具体的设计和实现建议之中。第三部分(工具)集中于Unix所提供的软件,他们用来帮助你解决问题。第四部分(社区)是关于人与人之间事务和协商的内容。正是它们使Unix文化体现得如此高效。

 

Because this is a book about shared culture, I never planned to write it alone. You will notice that the text includes guest appearances by prominent Unix developers, the shapers of the Unix tradition. The book went through an extended public review process during which I invited these luminaries to comment on and argue with the text. Rather than submerging the results of that review process in the final version, these guests were encouraged to speak with their own voices, amplifying and developing and even disagreeing with the main line of the text.

译文这是一本关于共享文化的书,因此我从未打算闭门造车。你会注意到字里行间穿梭着著名Unix开发者――Unix传统塑造者的客串。本书经历了大范围的公众审读过程,其间我邀请了以上名人来对文章内容进行评论和讨论。我鼓励他们发表自己的观点,扩充、承接,甚至是否定行文的主线,而不是把审读结果塞到最终版本中去。

 

In this book, when I use the editorial ‘we’ it is not to pretend omniscience but to reflect the fact that it attempts to articulate the expertise of an entire community. Because this book is aimed at transmitting culture, it includes much more in the way of history and folklore and asides than is normal for a technical book. Enjoy; these things, too, are part of your education as a Unix programmer. No single one of the historical details is vital, but the gestalt of them all is important. We think it makes a more interesting story this way. More importantly, understanding where Unix came from and how it got the way it is will help you develop an intuitive feel for the Unix style.

译文书中我所使用的“我们”这一字眼不是对上帝的虚饰,而是反映这样一个事实,即力图准确地表述整个社区内的专家观点。因为本书旨在传播文化,相对通常的技术文献而言,它涵盖了更多历史,民俗和花边故事。尽情地去欣赏吧!这些文章,也是你作为一名Unix程序开发者教育的一部分。历史细节元素不是那么重要,但他们的合集却威力无比。我们认为以这种方式才能产生出更加有趣的历史。尤其重要的是,理解Unix的何去何从可以帮助你形成一种对Unix风格的直觉感受。

 

For the same reason, we refuse to write as if history is over. You will find an unusually large number of references to the time of writing in this book. We do not wish to pretend that current practice reflects some sort of timeless and perfectly logical outcome of preordained destiny. References to time of writing are meant as an alert to the reader two or three or five years hence that the associated statements of fact may have become dated and should be double-checked.

译文出于同样的理由,我们拒绝书写历史的终结。你会发现本书中不寻常地大量引用写作时间。我们不希望掩饰当今行业反映的一些永恒、完美的逻辑上注定的命运。写作时间作为一个警铃,提醒读者在23年后,一些相关事实表述有可能过时,需要你反复掂量。

 

Other things this book is not is neither a C tutorial, nor a guide to the Unix commands and API. It is not a reference for sed or Yacc or Perl or Python. It’s not a network programming primer, nor an exhaustive guide to the mysteries of X. It’s not a tour of Unix’s internals and architecture, either. Other books cover these specifics better, and this book points you at them as appropriate.

译文另外要说明的是,本书不是一本C语言教程,也不是一本Unix命令和API导论。它不是sedYaccPerl或者Python的参考手册。它既不是一本网络初级读本,也不是全面揭示X之迷的导向。它更不是一本Unix内部机制和结构体系的“导游册”。其实有很多书更好地涵盖了以上细节。本书仅在适当的地方给你指出他们。

 

Beyond all these technical specifics, the Unix culture has an unwritten engineering tradition that has developed over literally millions of man-years1[1] of skilled effort. This book is written in the belief that understanding that tradition, and adding its design patterns to your toolkit, will help you become a better programmer and designer.

译文Unix文化超越了所有技术细节,拥有一个发展了数百万年的,不成文的工程传统。帮助理解这样一个传统,扩充Unix设计模式到你的工具箱,本书正是在这样一种信念下孕育而生。它能帮助你成为一名更加出色的程序员和设计者。

 

Cultures consist of people, and the traditional way to learn Unix culture is from other people and through the folklore, by osmosis. This book is not a substitute for person-to-person acculturation, but it can help accelerate the process by allowing you to tap the experience of others.

译文文化由人组成,传统的研习Unix文化方式即是从别人那,浅移默化地,通过民俗加以学习。本书不是人对人的文化传承的替代品,但它能帮助你加速利用别人经验的过程。

 

Who Should Read This Book

谁应该读这本书

 

You should read this book if you are an experienced Unix programmer who is often in the position of either educating novice programmers or debating partisans of other operating systems, and you find it hard to articulate the benefits of the Unix approach.

译文如果你是一名老练的Unix程序员,经常扮演教育初出茅庐的新手或与其他派别争辩的角色,同时你又发现很难准确的表述使用Unix的种种好处,那么你应该阅读本书。

 

You should read this book if you are a C, C++, or Java programmer with experience on other operating systems and you are about to start a Unix-based project.

译文如果你是一名CC++,或Java程序员,有过在其他操作系统上的编程经验,却马上要开始一个基于Unix的项目时,你应该阅读本书。

 

You should read this book if you are a Unix user with novice-level up to middle-level skills in the operating system, but little development experience, and want to learn how to design software effectively under Unix.

译文如果你是一名Unix使用者,正处于从操作系统的初级水平到中级水平的过渡,但开发经验匮乏,希望学一学在Unix下如何高效地设计软件,那么你应该阅读本书。

 

You should read this book if you are a non-Unix programmer who has figured out that the Unix tradition might have something to teach you. We believe you’re right, and that the Unix philosophy can be exported to other operating systems. So we will pay more attention to non-Unix environments (especially Microsoft operating systems) than is usual in a Unix book; and when tools and case studies are portable, we say so.

译文如果你是一名非Unix平台程序员,却意识到Unix传统能给你一些启发,你应该阅读本书。我们坚信你是对的,因为Unix哲学能够嫁接到其它操作系统上。因此,我们会花比在通常情况上更多的注意力到非Unix环境(特别是微软Microsoft的操作系统)之中;当工具和案例研习可以移植时,这一点能够证明。

 

You should read this book if you are an application architect considering platforms or implementation strategies for a major general-market or vertical application. It will help you understand the strengths of Unix as a development platform, and of the Unix tradition of open source as a development method.

译文如果你是一名应用软件设计师,正在考虑平台问题,或者一个首要综合市场或垂直应用的实现策略,你应该阅读本书。它能够让你领略到Unix作为一个开发平台,开源Unix传统作为一个开发方案所具备的强大动力。

 

You should not read this book if what you are looking for is the details of C coding or how to use the Unix kernel API. There are many good books on these topics; Advanced Programming in the Unix Environment [Stevens92] is classic among explorations of the Unix API, and The Practice of Programming [Kernighan-Pike99] is recommended reading for all C programmers (indeed for all programmers in any language).

译文如果你正在寻找编写C代码细节或是如何使用Unix核心API的读物,你没有必要阅读本书。关于此主题有很多好书;Advanced Programming in the Unix Environment [Stevens92] 是在Unix API探索方面的经典力作。我们还要推荐The Practice of Programming [Kernighan-Pike99] 给所有C程序员(事实上对使用任何语言的所有程序员都适合)。

 

How to Use This Book

如何使用本书

 

This book is both practical and philosophical. Some parts are aphoristic and general, others will examine specific case studies in Unix development. We will precede or follow general principles and aphorisms with examples that illustrate them: examples drawn not from toy demonstration programs but rather from real working code that is in use every day.

译文本书实用性与哲理性兼备。某些部分着力于格言式和普适化的论述,其它部分则考察了Unix的具体开发案例。在普遍原则和格言前后,我们会提供一些实例来阐述它们:这些例子并非摘取那些自娱自乐的演示程序,而是来自每天都在运行着的实际工作代码。

 

We have deliberately avoided filling the book with lots of code or specification-file examples, even though in many places this might have made it easier to write (and in some places perhaps easier to read!). Most books about programming give too many low-level details and examples, but fail at giving the reader a high-level feel for what is really going on. In this book, we prefer to err in the opposite direction.

译文我们在书中有意回避了大量代码和规范文档实例,尽管在许多场合下这一写作方式相对容易(也许在某地方更容易阅读!)大量关于程序设计的著作在底层细节和实例上花太多的墨水,却无法使读者在高层次上感受到究竟在做什么。我们宁可此书在反方向上犯错误。

 

Therefore, while you will often be invited to read code and specification files, relatively few are actually included in the book. Instead, we point you at examples on the Web.

译文因此,虽然你经常应邀阅读代码和规范文档,相对而言,本书却很少包含它们。可是我们会为你提供在互联网上的例子。

 

Absorbing these examples will help solidify the principles you learn into semi-instinctive working knowledge. Ideally, you should read this book near the console of a running Unix system, with a Web browser handy. Any Unix will do, but the software case studies are more likely to be preinstalled and immediately available for inspection on a Linux system. The pointers in the book are invitations to browse and experiment. Introduction of these pointers is paced so that wandering off to explore for a while won’t break up exposition that has to be continuous.

译文吸收实例有助于夯实你所学到的基本原则,并且把它们转化成半直觉化的工作知识。理想情况下,你应该在一个运行着Unix系统的控制台前阅读本书,还要准备个互联网浏览器。所有Unix都能胜任我们的学习任务,但是软件案例研习则应该预先在Linux系统下装好,并且随时可用。书中的提示引导你去浏览和实验。这些提示的介绍安排合适(译注:见目录后实例列表),你随意的浏览并不会打断本书连续的叙述。

 

Note: while we have made every effort to cite URLs that should remain stable and usable, there is no way we can guarantee this. If you find that a cited link has gone stale, use common sense and do a phrase search with your favorite Web search engine. Where possible we suggest ways to do this near the URLs we cite.

译文注意:尽管我们花了大量的精力来引用这些应该保持稳定和可用的URL链接,但我们没法确保这一点。如果你发现了一个引用为死链接,运用常识并且使用你偏爱的搜索引擎,通过一次短语查找来解决这个问题。

Most abbreviations used in this book are expanded at first use. For convenience, we have also provided a glossary in an appendix.

大多数缩略语第一次是以全称出现的。为了方便,我们在附录中提供了一个词汇表。

 

References are usually by author name. Numbered footnotes are for URLs that would intrude on the text or that we suspect might be perishable; also for asides, war stories, and jokes[2].

译文参考文献以作者姓名编排。带数字的脚注注释了那些会破坏正文连贯的URL链接,或者是那些我们怀疑可能过时的内容;或者是些道听途说,《星球大战》的故事,笑话之类2

 

To make this book more accessible to less technical readers, we invited some non-programmers to read it and identify terms that seemed both obscure and necessary to the flow of exposition. We also use footnotes for definitions of elementary terms that an experienced programmer is unlikely to need.

译文为了使本书能让更多的非技术读者阅读,我们邀请了一些非程序开发读者。我们让他们定义那些显得既模糊但对今后的阐述很必要的术语。我们还运用脚注来定义基础词汇,老练的程序员或许并不需要它们。

 

Related References

相关参考书目(译注:目前已在大陆出版的书籍,配上了相应的中文译名,便于查阅,其余的保持原文。后同)

 

Some famous papers and a few books by Unix’s early developers have mined this territory before. Kernighan & Pike’s The Unix Programming Environment [Kernighan-Pike84] stands out among these and is rightly considered a classic. But today it shows its age a bit; it doesn’t cover the Internet, and the World Wide Web or the new wave of interpreted languages like Perl, Tcl, and Python.

译文一些早期开发者的著名论文和著作曾在这一领域收获颇丰。Kernighan & Pike’s The Unix Programming Environment(Unix编程环境》) [Kernighan-Pike84]鹤立鸡群,被尊为经典。但如今却略显陈旧。此书没有讨论因特网(Internet),万维网(World Wide Web)或类似PerlTclPython解释语言的新浪潮。

About halfway into the composition of this book, we learned of Mike Gancarz’s The Unix Philosophy [Gancarz]. This book is excellent within its range, but did not attempt to cover the full spectrum of topics we felt needed to be addressed. Nevertheless we are grateful to the author for the reminder that the very simplest Unix design patterns have been the most persistent and successful ones.

译文本书大概完成一半之际,我们读到了Mike Gancarz The Unix Philosophy [Gancarz]。此书在其领域内相当出色,但是没有试图讨论我们认为有必要提到的完整话题类型。不过我们还是要感谢作者给我们指出:那些看似极其简单的Unix设计模式一直都是最持久和成功的。

 

The Pragmatic Programmer [Hunt-Thomas] is a witty and wise disquisition on good design practice pitched at a slightly different level of the software-design craft (more about coding, less about higher level partitioning of problems) than this book. The authors’ philosophy is an outgrowth of Unix experience, and it is an excellent complement to this book.

译文The Pragmatic Programmer 《程序员修炼之道》 [Hunt-Thomas]是一本诙谐而又智慧的专著。与本书不同的是,它更倾向于软件设计工艺层面(大量的关于编写代码,很少注意高层次的问题划分)。作者们的哲学理念随着Unix经验的丰富而递增。它是一本很好的辅助读物。

 

The Practice of Programming [Kernighan-Pike99] covers some of the same ground as The Pragmatic Programmer from a position deep within the Unix tradition.

译文The Practice of Programming [Kernighan-Pike99] The Pragmatic Programmer《程序员修炼之道》)所讨论主题的基本类似,不过是从深入到Unix传统中的地位来创作的

 

Finally (and with admitted intent to provoke) we recommend Zen Flesh, Zen Bones [Reps-Senzaki], an important collection of Zen Buddhist primary sources. References to Zen are scattered throughout this book. They are included because Zen provides a vocabulary for addressing some ideas that turn out to be very important for software design but are otherwise very difficult to hold in the mind. Readers with religious attachments are invited to consider Zen not as a religion but as a therapeutic form of mental discipline—which, in its purest non-theistic forms, is exactly what Zen is.

译文最后(带着不可辩驳的煽动冲动),我们推荐Zen Flesh, Zen Bones [Reps-Senzaki],一部关于禅宗本源的重要著作。禅宗的引用散布在全书中。把它们包含其中是因为禅宗提供了一个词汇库,它们能很恰当的表达一些在软件设计看来尤其重要的概念,如果不是这样的话,这些概念就很难在你脑海里留下印象。有宗教背景的读者请不要把禅宗看作是一种信仰,它是一种智力训练法。这种纯粹的无神论形式也正是""之所在。

 

Conventions Used in This Book

本书的约定

 

The term “UNIX” is technically and legally a trademark of The Open Group, and should formally be used only for operating systems which are certified to have passed The Open Group’s elaborate standards-conformance tests. In this book we use “Unix” in the looser sense widely current among programmers, to refer to any operating system (whether formally Unix-branded or not) that is either genetically descended from Bell Labs’s ancestral Unix code or written in close imitation of its descendants. In particular, Linux (from which we draw most of our examples) is a Unix under this definition.

译文术语"UNIX"从技术上和法律上来说是Open Group的注册商标。只有那些通过了Open Group的细化标准一致性测试认证的操作系统才仅允许正式地使用。本书中,我们使用在程序员中广泛流通的"Unix"的更加宽松的含义,来指代任何直接继承自贝尔实验室的原始Unix代码的,或是以非常类似它的后代的代码的方式写出的操作系统(不管它是不是正式的以Unix为商标)。特别地,Linux(我们从它身上抽取了大部分作为示例)就是在这种定义下的一个Unix

 

This book employs the Unix manual page convention of tagging Unix facilities with a following manual section in parentheses, usually on first introduction when we want to emphasize that this is a Unix command. Thus, for example, read “munger(1)” as “the ‘munger’ program, which will be documented in section 1 (user tools) of the Unix manual pages, if it’s present on your system.” Section 2 is C system calls, section 3 is C library calls, section 5 is file formats and protocols, section 8 is system administration tools. Other sections vary among Unixes but are not cited in this book. For more, type man 1 man at your Unix shell prompt (older System V Unixes may require man –s 1 man).

译文本书采用Unix手册中的标记约定,即在Unix功能紧跟的括号里标明手册的节数,通常出现在第一次介绍时,我们想强调这是个Unix命令。因此,举例来说,把“munger(1)”读作“ ‘munger’ 程序,其文档应在Unix手册的第一节(用户工具)中,如果你系统有此程序的话”第二节是C系统调用,第三节是C库调用,第五节是文件格式和协议,第八节是系统管理工具。其余章节随 Unix的不同而不同,本书没有引它们。要了解更多,请在你的Unix shell提示下键入man l man(老的System V Unix可能需要用man -s l man)。

 

Sometimes we mention a Unix application (such as Emacs, without a manual-section suffix and capitalized. This is a clue that the name actually represents a well-established family of Unix with essentially the same function, and we are discussing generic properties of all of them. Emacs, for example, includes xemacs.

译文有时我们提到一个Unix应用程序时(例如Emacs),后面没有带手册章节号和大写表示。这通常暗示着这个名字代表了一个源远流长的Unix程序家族,本质上拥有同样的功能,而且我们是在讨论它们的共有属性。例如,Emacs包括了xemacs

 

Our Case Studies

我们的案例研习

 

cdrtools/xcdroast   These two separate projects are usually used together. The cdrtools package is a set of CLI tools for writing CD-ROMs; Web search for “cdrtools”. The xcdroast application is a GUI front end for cdrtools; see the xcdroast project site [http://www.xcdroast.org/].

译文cdrtools/xcdroast   这两个独立开发的项目通常联在一块儿使用。cdrtools 包是CLI工具的集合,用于刻录CD-ROMSWeb关键字为"cdrtools"xcdroastcdrtools的图形用户界面应用程序;xcdroast项目的网址是[http://www.xcdroast.org/]

fetchmail          The fetchmail program retrieves mail from remote-mail servers using the POP3 or IMAP post-office protocols. See the fetchmail home page [http://www.catb.org/~esr/fetchmail] (or search for “fetchmail” on the Web).

译文fetchmail         fetchmail程序通过POP3IMAP邮局协议从远程邮件服务器获取电子邮件。fetchmail主页地址:[http://www.catb.org/~esr/fetchmail](或在Web搜索“fetchmail”

GIMP            The GIMP (GNU Image Manipulation Program) is a full-featured paint, draw, and image-manipulation program that can edit a huge variety of graphical formats in sophisticated ways. Sources are available from the GIMP home page [http://www.gimp.org/] (or search for "GIMP" on the Web).

译文GIMP            GIMPGNU图像处理程序)是一个绘制、图画和图形处理程序,能够以精确的方式编辑各种图形格式。可从GIMP主页[http://www.gimp.org/]上取得原代码(或在Wen搜索"GIMP"

 

Author’s Acknowledgements

作者致谢

 

The guest contributors (Ken Arnold, Steven M. Bellovin, Stuart Feldman, Jim Gettys, Steve Johnson, Brian Kernighan, David Korn, Mike Lesk, Doug McIlroy, Marshall Kirk McKusick, Keith Packard, Henry Spencer, and Ken Thompson) added a great deal of value to this book. Doug McIlroy, in particular, went far beyond the call of duty in the thoroughness of his critique and the depth of his contributions, displaying the same care and dedication to excellence which he brought to managing the original Unix research group thirty years ago.

译文 客座撰稿者们(Ken Arnold, Steven M. Bellovin, Stuart Feldman, Jim Gettys, Steve Johnson, Brian Kernighan, David Korn, Mike Lesk, Doug McIlroy, Marshall Kirk McKusick, Keith Packard, Henry Spencer, and Ken Thompson)给本书增添了巨大的价值。尤其是Doug McIlroy他在保持评论的严谨性和所作贡献的深度方面大大超出了他的义务范围,表现出了与他在三十年前管理初期的Unix研究组时同样的关切和对追求卓越所作的贡献。

 

Special thanks go to Rob Landley and to my wife Catherine Raymond, both of whom delivered intensive line-by-line critiques of manuscript drafts. Rob’s insightful and attentive commentary actually inspired more than one entire chapter in the final manuscript, and he had a lot to do with its present organization and range; if he had written all the text he pushed me to improve, I would have to call him a co-author. Cathy was my test audience representing non-technical readers; to the extent this book is accessible to people who aren’t already programmers, that’s largely her doing.

译文特别要感谢Rob Landley和我的妻子Catherine Raymond,他俩逐行对原稿进行了细致入微地评价。Rob那富有洞察力和周到的注释促成了足足超过最终手稿中一整章的内容。他也为本书的结构安排做相当多的工作。假使他把那些鼓励我不断改进的言语记录下来的话,我应该把他称为合作者。Cathy代表非技术背景读者参与了试读。本书能够让那些非程序编写人员接受,在很大程度都上归功于她。

 

This book benefited from discussions with many other people over the five years it took me to write it. Mark M. Miller helped me achieve enlightenment about threads. John Cowan supplied some insights about interface design patterns and drafted the case studies of wily and VM/CMS, and Jef Raskin showed me where the Rule of Least Surprise comes from. The UIUC System Architecture Group contributed useful feedback on early chapters. The sections on What Unix Gets Wrong and Flexibility in Depth were directly inspired by their review. Russell J. Nelson contributed the material on Bernstein chaining in Chapter 7. Jay Maynard contributed most of the material in the MVS case study in Chapter 3. Les Hatton provided many helpful comments on the Languages chapter and motivated the portion of Chapter 4 on Optimal Module Size. David A. Wheeler contributed many perceptive criticisms and some case-study material, especially in the Design part. Russ Cox helped develop the survey of Plan 9. Dennis Ritchie corrected me on some historical points about C.

译文本书受益于这5年成书时间的互相讨论。Mark M. Miller在线程方面给予我很大的启发。John Cowan给我提供了一些在界面设计模式上的深入见解,并且起草了wilyVM/CMS的案例研习。Jef Raskin为我指明了"最少惊奇原则"的出处。UIUC系统架构组提供了前几章有用的反馈。他们的审读直接促成了“Unix犯了什么错误”和“深入探索可伸缩性”这两节的产生。Russell J. Nelson为第七章的伯恩斯坦链提供了素材。Jay Maynard则为第三章的MVS案例研习提供了大部分材料。Les Hatton给了“语言”这章许多很有帮助的评注,并且促进了第四章“优化模式规格”的完成。David A. Wheeler贡献了许多入微的批评,还包括一些案例分析素材。尤其是关于设计那一部分。Russ Cox协助展开了“Plan 9”的调查。Dennis Ritchie纠正了我在一些C语言历史观点上所犯的错误。

 

Hundreds of Unix programmers, far too many to list here, contributed advice and comments during the book’s public review period between January and June of 2003. As always, I found the process of open peer review over the Web both intensely challenging and intensely rewarding. Also as always, responsibility for any errors in the resulting work remains my own.

译文成百名Unix程序员,由于太多而不能列于此,在公众审阅期间(2003年的一月到六月)提供了大量的建议和评论。我总能发现,在互联网的公众监督之下,激烈的挑战和热烈的奖赏并存其间。一如既往地,我自己仍然担当着修改本书任何错误的责任。

 

The expository style and some of the concerns of this book have been influenced by the design patterns movement; indeed, I flirted with the idea of titling the book Unix Design Patterns. I didn’t, because I disagree with some of the implicit central dogmas of the movement and don’t feel the need to use all its formal apparatus or accept its cultural baggage. Nevertheless, my approach has certainly been influenced by Christopher Alexander’s work[3] (especially The Timeless Way of Building and A Pattern Language), and I owe the Gang of Four and other members of their school a large debt of gratitude for showing me how it is possible to use Alexander’s insights to talk about software design at a high level without merely uttering vague and useless generalities. Interested readers should see Design Patterns: Elements of Reusable Object-Oriented Software [GangOfFour] for an introduction to design patterns.

译文说明风格和书中的一些理念受到了设计模式运动的影响;实际上,我在是否把这本书名改为Unix Design Patterns(Unix设计模式》)上举棋不定。但我没这么做,因为我不赞同这场运动中所流露出来的盲目中心教条化,另外我也不想使用设计模式的正规装备,同时接受它的文化包袱。然而,我的手法不可避免地受到了Christopher Alexander著作的影响(特别是 The Timeless Way of Building(《建筑的永恒之道》)与 A Pattern Language(《建筑模式语言》))我由此欠下了四剑客(Gang of Four)和这个学派其他成员大量的感激之情,是他们给我展示了如何运用Alexander的深入观点在高层次上讨论软件设计,而且没有丝毫的含糊和空泛。 感兴趣的读者可以参阅 Design Patterns: Elements of Reusable Object-Oriented Software 《设计模式:可复用面向对象软件的基础》

 

The title of this book is, of course, a reference to Donald Knuth’s The Art of Computer Programming. While not specifically associated with the Unix tradition, Knuth has been an influence on us all. Editors with vision and imagination aren’t as common as they should be. Mark Taub is one; he saw merit in a stalled project and skillfully nudged me into finishing it. Copy editors with a good ear for prose style and enough ability to improve writing that isn’t like theirs are even less common, but Mary Lou Nohr makes that grade. Jerry Votta seized on my concept for the cover and made it look better than I had imagined. The whole crew at Prentice-Hall gets high marks for making the editorial and production process as painless as possible, and for cheerfully accommodating my control-freak tendencies not just over the text but deep into the details of the book’s visual design, art, and marketing.

译文俨然,这本书地标题是参考Donald Knuth The Art of Computer Programming (《计算机程序设计艺术》)而取的。Knuth虽然和Unix传统没有特别的联系,但他影响了我们所有的人。富有远见和想象力的编辑们不种是很常见的。Mark Taub就是其中之一;他洞察到一个搁浅的项目,然后极富技巧地说服我去完成它。对散文风格有敏锐听觉,同时善于修改那些与他们风格截然不同文章的责任编辑更是凤毛羚角,但是Mary Lou Nohr符合这一水准。Jerry Votta把我的概念把握于封面之中,它比我原先设想的要好得多。Prentice-Hall的全体员工都给我留下了深刻的印象,因为他们努力使编辑和出版流程尽量顺畅,并且很乐意地接受了我的不仅付诸文字中,甚至深入到了书的视觉设计、艺术、市场等等细节中的操纵癖倾向。

 

 

 

 

 

 

 

 

 

Chapter 1. Philosophy

第一章、哲学

Philosophy Matters

哲学问题

Those who do not understand Unix are condemned to reinvent it, poorly.

--

译文不懂UNIX的人将被惩罚去再发明一个出来。

<author>Henry Spencer</author>

Usenet signature, November 1987

 

Culture? What Culture?

译文文化?何种文化??

 

This is a book about UNIX programming, but in it we’re going to toss around the words ‘culture’, ‘art’, and ‘philosophy’ a lot. If you are not a programmer, or you are a programmer who has had little contact with the Unix world, this may seem strange. But UNIX has a culture; it has a distinctive art of programming; and it carries with it a powerful design philosophy. Understanding these traditions will help you build better software, even if you’re developing for a non-Unix platform.

译文这是一本关于Unix程序设计的书,但是在书中我们将着重讨论“文化”、“艺术”和“哲学”几个词语。如果你不是一个程序设计者,或就算是程序设计者,但你对Unix程序设计鲜有接触,那么这本书的主题可能会显得很陌生。但Unix有自己的文化,其编程有一门独特的艺术;而且自身也蕴涵着强大的设计思想的哲学理念。了解了这些传统,即使你正在设计一个非Unix平台,都将会对你设计更好的软件大有裨益。

 

Every branch of engineering and design has technical cultures. In most kinds of engineering, the unwritten traditions of the field are parts of a working practitioner’s education as important as (and, as experience grows, often more important than) the official handbooks and textbooks.

译文工程与设计的每个分支学科都有其自身的技术文化。在大多工程领域内,未成文的行业传统和正式的手册与教科书同等(并且随经验增长会变地更加)重要。他们都属于程序员培养内容的一部分。

 

Senior engineers develop huge bodies of implicit knowledge, which they pass to their juniors by (as Zen Buddhists put it) “a special transmission, outside the scriptures”.

译文高级工程师创造出大量含蓄的知识,然后凭借(一种像禅宗教徒传道一样的)一种“特殊的传道方式—非经文的方式”将知识传授给资历较浅的工程人员。

 

Software engineering is generally an exception to this rule; technology has changed so rapidly, software environments have come and gone so quickly, that technical cultures have been weak and ephemeral. There are, however, exceptions to this exception. A very few software technologies have proved durable enough to evolve strong technical cultures, distinctive arts, and an associated design philosophy transmitted across generations of engineers.

译文软件工程通常是这个规则的一个例外;因为技术和软件环境更新太快以致于技术性的文化都变得脆弱且短暂。然而也有例外中的例外。一些极少数的软件工程已经证明具有足够的耐久力,形成了强大的技术文化,特异的艺术形式以及与之联系的设计哲学,并通过向一代一代的工程师传授而发展。

 

The UNIX culture is one of these. The Internet culture is another — or, in the twenty-first century, arguably the same one. The two have grown increasingly difficult to separate since the early 1980s, and in this book we won’t try particularly hard.

译文Unix文化就是上述文化中的一种。互联网文化是另外一种——或者在21世纪里,按理说都一样。这两种文化打从上个世纪80年代起就已经变地越来越难区分了,而且在这本书中我们也不打算怎么努力地去区分它们。

 

The Durability of UNIX

译文Unix的持久力

 

UNIX was born in 1969 and has been in continuous production use ever since. That’s several geologic eras by computer-industry standards — older than the PC or workstations or microprocessors or even video display terminals, and contemporaneous with the first semiconductor memories. Of all production timesharing systems today, only IBM’s VM/CMS can claim to have existed longer, and Unix machines have provided hundreds of thousands of times more service hours; indeed, Unix has probably supported more computing than all other timesharing systems put together.

译文Unix诞生于1969年,并一直作为产品化应用持续至今。按计算机工业标准来看,Unix跨越了几个“地质”时代,其远远久远于个人计算机、工作站和微处理器甚至视频显示终端。Unix其实和第一块半导体存储器是同时代的。在今天的所有分时系统产品中,只有IBM公司的VM/CMS能声称自己存在得更久;而且装有Unix的机器已提供了成百上千的更多服务时;事实上,Unix提供了比其他分时系统总和更多的计算。

 

UNIX has found use on a wider variety of machines than any other operating system can claim. From supercomputers to handhelds and embedded networking hardware, through workstations and servers and PCs and minicomputers, UNIX has probably seen more architectures and more odd hardware than any three other operating systems combined.

译文Unix的使用领域比其他操作系统宣称的还要广泛。从超级计算机到手提电脑再到嵌入式网络硬件,横跨服务器,工作站,个人计算机和小型机领域,Unix比其他三类操作系统所见的体系结构和特异的硬件加起来还要多。

 

UNIX has supported a mind-bogglingly wide spectrum of uses. No other operating system has shone simultaneously as a research vehicle, a friendly host for technical custom applications, a platform for commercial-off-the-shelf business software, and a vital component technology of the Internet.

译文Unix也应用于很多难以想象的领域。有哪个系统能够同时作为一个研究工具,……一个友好界面的技术应用,一个柜台外交易软件的平台,一个因特网上的重要技术组成呢?

 

Confident predictions that UNIX would wither away, or be crowded out by other operating systems, have been made yearly since its infancy. And yet UNIX, in its present-day avatars as Linux and BSD and Solaris and MacOS X and half a dozen other variants, seems stronger than ever today.

译文有把握的分析预测认为Unix不是渐渐消亡,就是被其他的操作系统挤出市场。自从Unix诞生,这些颇具微辞的预言们就年复一年,不断涌出。然而当今的化身如Linux BSDSolarisMacOS X以及其他几个变种产品一样,它们看起来是前所未有的强大。

 

Robert Metcalf [the inventor of Ethernet] says that if something comes along to replace Ethernet, it will be called “Ethernet”, so therefore Ethernet will never die[4].Unix has already undergone several such transformations.

译文Robert Metcalf(以太网的发明人)说过,如果有东西代替了以太网,那么它还是应该叫做“以太网”,这样以太网就永远不会消失。Unix就是经历了几次这样的变革。

<author>Ken Thompson</author>

 

At least one of Unix’s central technologies — the C language — has been widely naturalized elsewhere. Indeed it is now hard to imagine doing software engineering without C as a ubiquitous common language of systems programming. Unix also introduced both the now-ubiquitous tree shaped file namespace with directory nodes and the pipeline for connecting programs.

译文至少Unix的一个核心技术—C语言—已被广泛地移植到了其他领域。事实上很难想象,如今假使没有像C语言一样普及的通用系统编程语言,软件工程会变成什么样。Unix同样也引进了时下流行的带目录节点的树型文件名字空间和程序相连的管道。

 

UNIX’s durability and adaptability have been nothing short of astonishing. Other technologies have come and gone like mayflies. Machines have increased a thousand fold in power, languages have mutated, industry practice has gone through multiple revolutions — and Unix hangs in there, still producing, still paying the bills, and still commanding loyalty from many of the best and brightest software technologists on the planet.

译文Unix的持久力及适应性已经足以让人惊讶了。其它技术就像蜉蝣一样匆匆的出现又死亡。机器的力量有了千倍的增长,语言发生了变化,工业也经历了多样的变革—Unix却立于其中,依然生产着,依然付账单,依然要求这个星球最智慧的软件技师对其忠诚。

 

One of the many consequences of the exponential power-versus-time curve in computing, and the corresponding pace of software development, is that 50% of what one knows becomes obsolete over every 18 months. Unix does not abolish this phenomenon, but does do a good job of containing it. There’s a bedrock of unchanging basics—languages, system calls, and tool invocations—that one can actually keep using for years, even decades. Elsewhere it is impossible to predict what will be stable; even entire operating systems cycle out of use. Under Unix, there is a fairly sharp distinction between transient knowledge and lasting knowledge, and one can know ahead of time (with about 90% certainty) which category something is likely to fall in when one learns it. Thus the loyalty Unix commands.

译文在计算领域成级数方式增长的能量对时间曲线,以及相应的软件开发步伐,带来的影响之一就是一个人的知识每18个月就被淘汰掉50%。Unix也无法剔除这种现象,而是做了很好的工作来容纳它。一个不变的基石——语言,系统调用和工具的援用,——这些东西人们都可以一直使用好几年甚至是好几十年。换在别处,就不可能预知哪个部分能保持稳定,甚至整个操作系统在循环中都会被淘汰出局。在Unix环境下,对短暂的知识和持续的知识间就有一个相对明显的区别,而且当我们学的时候,可以提前知道(大约有90%的把握)哪一种可能会过时。可以说Unix统治着忠诚。

 

Much of Unix’s stability and success has to be attributed to its inherent strengths, to design decisions Ken Thompson, Dennis Ritchie, Brian Kernighan, Doug McIlroy, Rob Pike and other early Unix developers made back at the beginning; decisions that have been proven sound over and over. But just as much is due to the design philosophy, art of programming, and technical culture that grew up around UNIX in the early days. This tradition has continuously and successfully propagated itself in symbiosis with UNIX ever since.

译文Unix很大部分的稳定性和成功都归功于它自身的继承力量,归功于Ken Thompson, Dennis Ritchie, Brian Kernighan, Doug McIlroy, Rob Pike和其他Unix早期开发者所做的,经过了反复论证而较为稳妥的设计决策。同时也还要归功于设计哲学,编程技巧以及早期在Unix中渐渐形成的技术文化。从那时起这一传统就和Unix以一种相辅相成的关系,不断成功的进行了自我增殖。



[1] The three and a half decades between 1969 and 2003 is a long time. Going by the historical trend curve in number of Unix sites during that period, probably somewhere upwards of fifty million man-years have been plowed into Unix development worldwide.

译文19692003年这35年确实很长。根据那段时间的Unix站点数目的历史趋势曲线来看,全球大概有5千万人每年投身于Unix开发阵地上。

[2] This particular footnote is dedicated to Terry Pratchett, whose use of footnotes is quite...inspiring.

  译文这个特别的脚注是献给Terry Pratchett的,他使用的脚注真是。。。令人鼓舞。

[3] An appreciation of Alexander’s work, with links to on-line versions of significant portions, may be found at Some Notes on Christopher Alexander [http://www.math.utsa.edu/sphere/salingar/Chris.text.html].

译文Alexander作品的鉴赏,以及一些重要内容的在线版本链接,可在“Some Notes on Christopher Alexander”网站[http://www.math.utsa.edu/sphere/salingar/Chris.text.html]找到。

[4] In fact, Ethernet has already been replaced by a different technology with the same name — twice. Once when coax was replaced with twisted pair, and a second time when gigabit Ethernet came in.

译文事实上,以太网已经被不同的技术迭代了两次,虽然名字相同。第一次是用双绞线替换了同轴线,而第二次是千兆位网卡的引进而发生了变革。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值