当前位置: 首页 > news >正文

文艺编程 Literate Programming (原文中英文对照)

转载自:http://legendsland.wordpress.com/2012/06/06/literate-programming-%E6%96%87%E8%89%BA%E7%BC%96%E7%A8%8B/

译注:这篇文章是 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) 程序。

 

相关文章:

  • Windows下PBRT v2 安装指南
  • PBRT 快速入门
  • OpenCV 2.3.1在VS2010下的安装
  • HDR文件格式简介及其读写函数
  • OpenCV 2.4.2在VS2010下的安装(使用预编译库)
  • assert() 断言的用法
  • Ubuntu下安装Matlab
  • Ubuntu下编译安装OpenEXR
  • Ubuntu 12.04 LTS 下安装文件传输远程桌面共享软件Teamviewer
  • Windows下编译安装OpenEXR(x86版本)
  • 使用WinEdt 6 避免跳出注册对话框的一个小技巧
  • 如何在Ubuntu 12.04 LTS中使用低版本gcc/g++
  • Matlab与C/C++联合编程之从Matlab调用C/C++代码
  • Ununtu下在Matlab中读写OpenEXR格式的图片
  • Ubuntu下的Notepad++(SciTE)
  • 【翻译】Mashape是如何管理15000个API和微服务的(三)
  • Angular 4.x 动态创建组件
  • canvas实际项目操作,包含:线条,圆形,扇形,图片绘制,图片圆角遮罩,矩形,弧形文字...
  • docker容器内的网络抓包
  • ES6 学习笔记(一)let,const和解构赋值
  • Javascript基础之Array数组API
  • Rancher-k8s加速安装文档
  • UMLCHINA 首席专家潘加宇鼎力推荐
  • 观察者模式实现非直接耦合
  • 扑朔迷离的属性和特性【彻底弄清】
  • 前端之React实战:创建跨平台的项目架构
  • 如何胜任知名企业的商业数据分析师?
  • 如何选择开源的机器学习框架?
  • 深度学习在携程攻略社区的应用
  • 手机app有了短信验证码还有没必要有图片验证码?
  • 协程
  • [Shell 脚本] 备份网站文件至OSS服务(纯shell脚本无sdk) ...
  • ​ubuntu下安装kvm虚拟机
  • ​数据结构之初始二叉树(3)
  • ​业务双活的数据切换思路设计(下)
  • # 睡眠3秒_床上这样睡觉的人,睡眠质量多半不好
  • #LLM入门|Prompt#2.3_对查询任务进行分类|意图分析_Classification
  • #绘制圆心_R语言——绘制一个诚意满满的圆 祝你2021圆圆满满
  • #知识分享#笔记#学习方法
  • $emit传递多个参数_PPC和MIPS指令集下二进制代码中函数参数个数的识别方法
  • (+3)1.3敏捷宣言与敏捷过程的特点
  • (0)Nginx 功能特性
  • (2)STM32单片机上位机
  • (22)C#传智:复习,多态虚方法抽象类接口,静态类,String与StringBuilder,集合泛型List与Dictionary,文件类,结构与类的区别
  • (51单片机)第五章-A/D和D/A工作原理-A/D
  • (7)svelte 教程: Props(属性)
  • (a /b)*c的值
  • (C#)Windows Shell 外壳编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令...
  • (js)循环条件满足时终止循环
  • (PySpark)RDD实验实战——取最大数出现的次数
  • (八)五种元启发算法(DBO、LO、SWO、COA、LSO、KOA、GRO)求解无人机路径规划MATLAB
  • (论文阅读22/100)Learning a Deep Compact Image Representation for Visual Tracking
  • (四) Graphivz 颜色选择
  • (五)activiti-modeler 编辑器初步优化
  • (一)基于IDEA的JAVA基础10