Wednesday, August 22, 2007

Literate Programming

在看Dr. Lee Wenjun的编译原理教学大纲时,看到有对Knuth的简介。里面有一项东西我从来没听过,那就是Literate Programming。于是上网搜索了一下,得到的结果如下。

中文:
中文翻译为"作文式程序设计",总的来说就是在编译的过程中同时产生文档和代码的一种程序设计系统和方法.你可以参考高教刚刚出版的《ACM图灵奖:计算机发展史的缩影》P72。

英文(From wikipedia):
Literate programming is a philosophy of computer programming based on the premise that a computer program should be written similar to literature, with human readability as a primary goal. According to this philosophy, programmers should aim for a “literate” style in their programming just as writers aim for an intelligible and articulate style in their writing. This philosophy contrasts with the mainstream view that the programmer’s primary or sole objective is to create source code and that documentation should only be a secondary objective.

In practice, literate programming is achieved by combining human-readable documentation and machine-readable source code into a single source file, in order to maintain close correspondence between documentation and source code. The order and structure of this source file are specifically designed to aid human comprehension: code and documentation together are organized in logical and/or hierarchical order (typically according to a scheme that accommodates detailed explanations and commentary as necessary). At the same time, the structure and format of the source files accommodate external utilities that generate program documentation and/or extract the machine-readable code from the same source file(s) (e. g., for subsequent processing by compilers or interpreters).



实际上,javadoc,doxygen就是类似的工具。但是按照wikipedia上的说明,这些工具并没有完全反映出该种哲学思想(philosophy),因为毕竟它们只是简单地给出了一种自动生成文档注释的方法。

No comments: