译注:这篇文章是 Donald Knuth 一篇1983年的论文:Literate Programming 的介绍部分。有人翻译为“字面编程”,是极其错误的说法,literate 根本就没有“字面”这个意思,字面的英文单词是 literal, literate 意指能读能写,Donald Knuth 同时也认为编程是一门艺术,因此将其译为“文艺编程”,甚为妥当。论文发表近30年,未见谁真正用好了LP。译此文,希望能更正至今都错误的中文译法。保守估计,10年内 LP 仍然不会流行起来,因为没有谁既是伟大的作家,又是伟大的程序员 —— 除了 Donald Knuth)

The past ten years have witnessed substantial improvements in programming methodology. This advance, carried out under the banner of “structured programming,” has led to programs that are more reliable and easier to comprehend; yet the results are not entirely satisfactory. My purpose in the present paper is to propose another motto that may be appropriate for the next decade, as we attempt to make further progress in the state of the art. I believe that the time is ripe for significantly better documentation of programs, and that we can best achieve this by considering programs to be works of literature. Hence, my title: “Literate Programming.”

过去十年见证了编程方法学上重要的进步。这个进步是在“结构化编程”的大旗下发展起来的,尽管结果并非完美,但它让程序变得更可靠也更易读。当我们努力推进编程技术进一步发展时,本论文的目的就是提出下一个十年口号。我相信,在文档化程序方面,更好更重要的时机已经成熟。为达此目标,最好的方法是将程序当作文学作品。故此,标题为:“文艺编程”。

Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.

让我们改改传统上构建程序的态度:不要认为程序的主要任务是指导计算机怎么做,相反,程序要致力于向人们解释,它想让计算机做什么。

The practitioner of literate programming can be regarded as an essayist, whose main concern is with exposition and excellence of style. Such an author, with thesaurus in hand, chooses the names of variables carefully and explains what each variable means. He or she strives for a program that is comprehensible because its concepts have been introduced in an order that is best for human understanding, using a mixture of formal and informal methods that reinforce each other.

文艺编程人士可被视为作家,他们首要考虑的任务是如何清楚地阐述、如何形成优秀的风格。这样的作者胸有成竹,会仔细地挑选变量名,并给予解释。为力求程序之可读,他/她使用形式和非形式互补的混合手法,将各种概念按照人们能理解的方式顺序编排下来。

I dare to suggest that such advances in documentation are possible because of the experiences I’ve had during the past several years while working intensively on software development. By making use of several ideas that have existed for a long time, and by applying them systematically in a slightly new way, I’ve stumbled across a method of composing programs that excites me very much. In fact, my enthusiasm is so great that I must warn the reader to discount much of what I shall say as the ravings of a fanatic who thinks he has just seen a great light.

之所以胆敢对文档化提出这样的要求,那是因为我过去多年的高强度软件开发经验。依靠人们长久以来形成的诸多想法,我系统而又略带新意地应用它们,最终摸索出一套让我兴奋不已的创作程序的方法。事实上,我太热情太痴迷于此,我要警告读者朋友们,对我那些窥见圣光之类的狂言乱语,你们要适听而止。

Programming is a very personal activity, so I can’t be certain that what has worked for me will work for everybody. Yet the impact of this new approach on my own style has been profound, and my excitement has continued unabated for more than two years. I enjoy the new methodology so much that it is hard for me to refrain from going back to every program that I’ve ever written and recasting it in “literate” form. I find myself unable to resist working on programming tasks that I would ordinarily have assigned to student research assistants; and why? Because it seems to me that at last I’m able to write programs as they should be written. My programs are not only explained better than ever before; they also are better programs, because the new methodology encourages me to do a better job. For these reasons I am compelled to write this paper, in hopes that my experiences will prove to be relevant to others.

新方法对我自己风格的影响极其深远,而且这种兴奋感持续两年多,未曾减退。但编程是非常个人化的行为,对我适合的,我并不确定是否适合所有人。我强烈地爱上了这套新方法,对过去写的每一个程序,我都抑制不住地想将它们“文艺”化。我发现自己忍不住去编那些布置给学生助教们的作业程序,为何?因为对我而言,我最终能写出那些程序,而那正是本该被写成的样子。新方法促使我写出比以往更可读、也更好的程序。基于上述原因,特拟此文,希望其他人能分享到我的经验。

I must confess that there may also be a bit of malice in my choice of a title. During the 1970s I was coerced like everybody else into adopting the ideas of structured programming, because I couldn’t bear to be found guilty of writing unstructured programs. Now I have a chance to get even. By coining the phrase “literate programming,” I am imposing a moral commitment on everyone who hears the term; surely nobody wants to admit writing an illiterate program.

必须承认,标题有点恶搞。在70年代,若被发现用了非结构化编程,我会心生惭愧而难堪忍受,于是像所有人一样,被迫接受了结构化编程的思想。现有有机会扳平了。我构造出“文艺编程”这个说法,于是每个听到此说法的人,会被迫作出道德上的承诺。毕竟,绝没有人会承认自己在编写文盲 (illiterate) 程序。

wikipedia关于文艺编程的解释:

文学编程英语:Literate programming)是由高德纳提出的编程方法,希望能用来取代结构化编程范型。[1]

正如高德纳所构想的那样,文学编程范型不同于传统的由计算机强加的编写程序的方式和顺序,而代之以让程序员用他们自己思维内在的逻辑和流程所要求的顺序开发程序。[2]文学编程自由地表达逻辑,而且它用人类日常使用的语言写出来,就好像一篇文章一样,文章里包括用来隐藏抽象的和传统的源代码。文学编程工具用来从文学源文件中获得两种表达方式,一种用于计算机进一步的编译和执行,称作“绕出”(tangled)的代码,一种用于格式化文档,称作从文学源代码中“织出”(woven)。[3]。虽然第一代文学编程工具特定于计算机语言,但后来的工具可以不依赖具体语言,并且存在于比编程语言更高的层次中。

http://zh.wikipedia.org/wiki/%E6%96%87%E5%AD%A6%E7%BC%96%E7%A8%8B

文艺编程 Literate Programming的更多相关文章

  1. .Net中的反应式编程(Reactive Programming)

    系列主题:基于消息的软件架构模型演变 一.反应式编程(Reactive Programming) 1.什么是反应式编程:反应式编程(Reactive programming)简称Rx,他是一个使用LI ...

  2. Unity基于响应式编程(Reactive programming)入门

    系列目录 [Unity3D基础]让物体动起来①--基于UGUI的鼠标点击移动 [Unity3D基础]让物体动起来②--UGUI鼠标点击逐帧移动 时光煮雨 Unity3D让物体动起来③—UGUI DoT ...

  3. 2018-02-27 "Literate Programming"一书摘记之一

    书到后才发现是Knuth的论文集, 第一篇就在网上: Computer programming as an art (1974). 其中"Taste and Style"(品味和风 ...

  4. 算法编程Algos Programming

    算法编程Algos Programming 不同算法的集合,用于编程比赛,如ACM ICPC. 算法按主题划分.大多数算法都可以从文件中按原样运行.每种算法都有一个参考问题,并对其时间和空间复杂度作了 ...

  5. Java 中的函数式编程(Functional Programming):Lambda 初识

    Java 8 发布带来的一个主要特性就是对函数式编程的支持. 而 Lambda 表达式就是一个新的并且很重要的一个概念. 它提供了一个简单并且很简洁的编码方式. 首先从几个简单的 Lambda 表达式 ...

  6. 关于函数式编程(Functional Programming)

    初学函数式编程,相信很多程序员兄弟们对于这个名字熟悉又陌生.函数,对于程序员来说并不陌生,编程对于程序员来说也并不陌生,但是函数式编程语言(Functional Programming languag ...

  7. 学习笔记之编程珠玑 Programming Pearls

    Programming Pearls (2nd Edition): Jon Bentley: 0785342657883: Amazon.com: Books https://www.amazon.c ...

  8. iOS运行时编程(Runtime Programming)和Java的反射机制对比

    运行时进行编程,类似Java的反射.运行时编程和Java反射的对比如下:   1.相同点   都可以实现的功能:获取类信息.属性设置获取.类的动态加载(NSClassFromString(@“clas ...

  9. 面向函数范式编程(Functional programming)

    函数编程(简称FP)不只代指Haskell Scala等之类的语言,还表示一种编程思维,软件思考方式,也称面向函数编程. 编程的本质是组合,组合的本质是范畴Category,而范畴是函数的组合. 首先 ...

随机推荐

  1. QML的渲染方式相较于之前的版本也有了重大的更新(CPU线程负责绘制,GPU线程负责渲染),还有好多经常评论 good

    作者:qyvlik链接:http://www.zhihu.com/question/38867614/answer/78583440来源:知乎著作权归作者所有,转载请联系作者获得授权. 做UI啊.如果 ...

  2. 激活前一个程序(注册全局消息,使用Mutex探测,如果已经占用就广播消息通知第一个程序,然后第一个程序做出响应)

    unit MultInst; interface const MI_QUERYWINDOWHANDLE = ; MI_RESPONDWINDOWHANDLE = ; MI_ERROR_NONE = ; ...

  3. xen vhd操作工具source code研读

    推出最新的VHD操作工具VHD-UTIL 实现源码,超强,Ruiy只为学习高手的设计思路

  4. 【转】C++实现RTMP协议发送H.264编码及AAC编码的音视频

    RTMP(Real Time Messaging Protocol)是专门用来传输音视频数据的流媒体协议,最初由Macromedia 公司创建,后来归Adobe公司所有,是一种私有协议,主要用来联系F ...

  5. mysql的主从复制原理

    一个简单完整的 Mysql 主从复制,读写分离的示意图. 1. 首先搭建 Mysql 主从架构,实现 将 mater 数据自动复制到 slave MySQL 复制的工作方式很简单,一台服务器作为主机, ...

  6. cmd用到的基本操作

    dir #显示当前目录中的文件和子目录 dir /a #显示当前目录中的文件和子目录,包括隐藏文件和系统文件 a = all dir c: /a:d #显示 C 盘当前目录中的目录 d = direc ...

  7. Phoenix中Sequence的用法

    Phoenix--HBase的JDBC驱动 序列(Sequence)是Phoenix提供的允许产生单调递增数字的一个SQL特性,序列会自动生成顺序递增的序列号,以实现自动提供唯一的主键值.   使用C ...

  8. A Corrupt Mayor's Performance Art(线段树区间更新+位运算,颜色段种类)

    A Corrupt Mayor's Performance Art Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 100000/100 ...

  9. STL之nth_element()(取容器中的第n大值)

    nth_element()函数 头文件:#include<algorithm> 作用:nth_element作用为求第n大的元素,并把它放在第n位置上,下标是从0開始计数的,也就是说求第0 ...

  10. HTML 5 全局属性和事件属性

    1.HTML 5 全局属性 HTML 属性能够赋予元素含义和语境. 下面的全局属性可用于任何 HTML5 元素. NEW:HTML 5 中新的全局属性. 属性 描述 accesskey 规定访问元素的 ...