- Web (sistem pemrograman)
- TeX
- Daftar ilmuwan komputer
- Org-mode
- MATLAB
- Donald Knuth
- Mohammad Ali
- Literate programming
- Software documentation
- Programming language
- Donald Knuth
- Web (programming system)
- R (programming language)
- Comment (computer programming)
- Leo (text editor)
- TeX
- Programming paradigm
- Literate programming vs reasonably documenting your code
- Literate programming, good/bad design methodology
- Why isn't literate programming mainstream? [closed]
- documentation - What is the connection between literate …
- literate programming - Software Engineering Stack Exchange
- Questions tagged [literate-programming] - Software Engineering …
- comments - Style and recommendations of commenting code
- Questions tagged [literate-programming] - Software Engineering …
- Using π, φ, λ etc. as variable names while programming?
- Why is there such limited support for Design by Contract in most …
M3GAN (2022)
Literate programming GudangMovies21 Rebahinxxi LK21
Literate programming is a programming paradigm introduced in 1984 by Donald Knuth in which a computer program is given as an explanation of how it works in a natural language, such as English, interspersed (embedded) with snippets of macros and traditional source code, from which compilable source code can be generated. The approach is used in scientific computing and in data science routinely for reproducible research and open access purposes. Literate programming tools are used by millions of programmers today.
The literate programming paradigm, as conceived by Donald Knuth, represents a move away from writing computer programs in the manner and order imposed by the compiler, and instead gives programmers macros to develop programs in the order demanded by the logic and flow of their thoughts. Literate programs are written as an exposition of logic in more natural language in which macros are used to hide abstractions and traditional source code, more like the text of an essay.
Literate programming (LP) tools are used to obtain two representations from a source file: one understandable by a compiler or interpreter, the "tangled" code, and another for viewing as formatted documentation, which is said to be "woven" from the literate source. While the first generation of literate programming tools were computer language-specific, the later ones are language-agnostic and exist beyond the individual programming languages.
History and philosophy
Literate programming was first introduced in 1984 by Donald Knuth, who intended it to create programs that were suitable literature for human beings. He implemented it at Stanford University as a part of his research on algorithms and digital typography. The implementation was called "WEB" since he believed that it was one of the few three-letter words of English that had not yet been applied to computing. However, it resembles the complicated nature of software delicately pieced together from simple materials. The practice of literate programming has seen an important resurgence in the 2010s with the use of computational notebooks, especially in data science.
Concept
Literate programming is writing out the program logic in a human language with included (separated by a primitive markup) code snippets and macros. Macros in a literate source file are simply title-like or explanatory phrases in a human language that describe human abstractions created while solving the programming problem, and hiding chunks of code or lower-level macros. These macros are similar to the algorithms in pseudocode typically used in teaching computer science. These arbitrary explanatory phrases become precise new operators, created on the fly by the programmer, forming a meta-language on top of the underlying programming language.
A preprocessor is used to substitute arbitrary hierarchies, or rather "interconnected 'webs' of macros", to produce the compilable source code with one command ("tangle"), and documentation with another ("weave"). The preprocessor also provides an ability to write out the content of the macros and to add to already created macros in any place in the text of the literate program source file, thereby disposing of the need to keep in mind the restrictions imposed by traditional programming languages or to interrupt the flow of thought.
= Advantages
=According to Knuth,
literate programming provides higher-quality programs, since it forces programmers to explicitly state the thoughts behind the program, making poorly thought-out design decisions more obvious. Knuth also claims that literate programming provides a first-rate documentation system, which is not an add-on, but is grown naturally in the process of exposition of one's thoughts during a program's creation. The resulting documentation allows the author to restart their own thought processes at any later time, and allows other programmers to understand the construction of the program more easily. This differs from traditional documentation, in which a programmer is presented with source code that follows a compiler-imposed order, and must decipher the thought process behind the program from the code and its associated comments. The meta-language capabilities of literate programming are also claimed to facilitate thinking, giving a higher "bird's eye view" of the code and increasing the number of concepts the mind can successfully retain and process. Applicability of the concept to programming on a large scale, that of commercial-grade programs, is proven by an edition of TeX code as a literate program.
Knuth also claims that literate programming can lead to easy porting of software to multiple environments, and even cites the implementation of TeX as an example.
= Contrast with documentation generation
=Literate programming is very often misunderstood to refer only to formatted documentation produced from a common file with both source code and comments – which is properly called documentation generation – or to voluminous commentaries included with code. This is the converse of literate programming: well-documented code or documentation extracted from code follows the structure of the code, with documentation embedded in the code; while in literate programming, code is embedded in documentation, with the code following the structure of the documentation.
This misconception has led to claims that comment-extraction tools, such as the Perl Plain Old Documentation or Java Javadoc systems, are "literate programming tools". However, because these tools do not implement the "web of abstract concepts" hiding behind the system of natural-language macros, or provide an ability to change the order of the source code from a machine-imposed sequence to one convenient to the human mind, they cannot properly be called literate programming tools in the sense intended by Knuth.
Workflow
Implementing literate programming consists of two steps:
Weaving: Generating a comprehensive document about the program and its maintenance.
Tangling: Generating machine executable code
Weaving and tangling are done on the same source so that they are consistent with each other.
Example
A classic example of literate programming is the literate implementation of the standard Unix wc word counting program. Knuth presented a CWEB version of this example in Chapter 12 of his Literate Programming book. The same example was later rewritten for the noweb literate programming tool. This example provides a good illustration of the basic elements of literate programming.
= Creation of macros
=The following snippet of the wc literate program shows how arbitrary descriptive phrases in a natural language are used in a literate program to create macros, which act as new "operators" in the literate programming language, and hide chunks of code or other macros. The mark-up notation consists of double angle brackets (<<...>>) that indicate macros. The @ symbol which, in a noweb file, indicates the beginning of a documentation chunk. The <<*>> symbol stands for the "root", topmost node the literate programming tool will start expanding the web of macros from. Actually, writing out the expanded source code can be done from any section or subsection (i.e. a piece of code designated as <
The unraveling of the chunks can be done in any place in the literate program text file, not necessarily in the order they are sequenced in the enclosing chunk, but as is demanded by the logic reflected in the explanatory text that envelops the whole program.
= Program as a web
=Macros are not the same as "section names" in standard documentation. Literate programming macros hide the real code behind themselves, and be used inside any low-level machine language operators, often inside logical operators such as if, while or case. This can be seen in the following wc literate program.
The macros stand for any chunk of code or other macros, and are more general than top-down or bottom-up "chunking", or than subsectioning. Donald Knuth said that when he realized this, he began to think of a program as a web of various parts.
= Order of human logic, not that of the compiler
=In a noweb literate program besides the free order of their exposition, the chunks behind macros, once introduced with <<...>>=, can be grown later in any place in the file by simply writing <
The grand totals must be initialized to zero at the beginning of the program.
If we made these variables local to main, we would have to do this initialization
explicitly; however, C globals are automatically zeroed. (Or rather,``statically
zeroed.'' (Get it?)
<
long tot_word_count, tot_line_count,
tot_char_count;
/* total number of words, lines, chars */
@
= Record of the train of thought
=The documentation for a literate program is produced as part of writing the program. Instead of comments provided as side notes to source code a literate program contains the explanation of concepts on each level, with lower level concepts deferred to their appropriate place, which allows for better communication of thought. The snippets of the literate wc above show how an explanation of the program and its source code are interwoven. Such exposition of ideas creates the flow of thought that is like a literary work. Knuth wrote a "novel" which explains the code of the interactive fiction game Colossal Cave Adventure.
= Remarkable examples
=Axiom, which is evolved from Scratchpad, a computer algebra system developed by IBM. It is now being developed by Tim Daly, one of the developers of Scratchpad, Axiom is totally written as a literate program.
Literate programming practices
The first published literate programming environment was WEB, introduced by Knuth in 1981 for his TeX typesetting system; it uses Pascal as its underlying programming language and TeX for typesetting of the documentation. The complete commented TeX source code was published in Knuth's TeX: The program, volume B of his 5-volume Computers and Typesetting. Knuth had privately used a literate programming system called DOC as early as 1979. He was inspired by the ideas of Pierre-Arnoul de Marneffe. The free CWEB, written by Knuth and Silvio Levy, is WEB adapted for C and C++, runs on most operating systems, and can produce TeX and PDF documentation.
There are various other implementations of the literate programming concept as given below. Many of the newer among these do not have macros and hence do not comply with the order of human logic principle, which makes them perhaps "semi-literate" tools. These, however, allow cellular execution of code which makes them more along the lines of exploratory programming tools.
Other useful tools include:
See also
Documentation generator – the inverse on literate programming where documentation is embedded in and generated from source code
Notebook interface – virtual notebook environment used for literate programming
Sweave and Knitr – examples of use of the "noweb"-like Literate Programming tool inside the R language for creation of dynamic statistical reports
Self-documenting code – source code that can be easily understood without documentation
References
Further reading
External links
LiterateProgramming at WikiWikiWeb
Literate Programming FAQ at CTAN
Kata Kunci Pencarian:
WCaKPMA-U-MTzp5tLBRwyJiYiXgd_Wnpe_kVxoZmyOd01KgURlqw-ZQ924P8IZCNQWd ...

Literate Programming - Assignment Point

GitHub - Literate-DevOps/literate-programming-tutorials: Literate ...

Literate programming - Alchetron, The Free Social Encyclopedia

KNUTH LITERATE PROGRAMMING PDF

The {targets} R package user manual - 12 Literate programming

Literate Programming

Literate Programming

Buy Literate Programming Book By: Donald Knuth

Literate Programming - Thedro Neely

Download Literate programming PDF by Donald E. Knuth

- Literate programming with Jupyter notebooks + nbdev + Quarto
literate programming
Daftar Isi
Literate programming vs reasonably documenting your code
Jul 22, 2020 · README.md is the modern day heir to literate programming is a bit different than it is possible to partially emulate literate programming by symlinking README.md to a source code file (i.e. having a polyglot of e.g. markdown and Java). –
Literate programming, good/bad design methodology
Literate Programming tools can be quite simple if they're focused on modern, high-level object-oriented (or functional) programming languages. There is less need for elaborate workarounds because of the limitations of C (or Pascal or Assembler).
Why isn't literate programming mainstream? [closed]
The Literate Programming system that Knuth designed did much, much more than immediately meets the eye, namely it overcome many shortcomings in the underlying programming language that the code generation tool generated from Knuths source document, namely standard Pascal.
documentation - What is the connection between literate …
May 17, 2012 · Literate programming - Wikipedia article. The literate programming paradigm, as conceived by Knuth, represents a move away from writing programs in the manner and order imposed by the computer, and instead enables programmers to develop programs in the order demanded by the logic and flow of their thoughts.
literate programming - Software Engineering Stack Exchange
Oct 13, 2016 · This sort of literate programming is really nice to document your rules together with exactly those executing rules and helps a lot in not getting outdated documentation. My question is not necessarily limited to asciidoc(tor), but inspired by the above. If there is a solution via asciidoc though, I'm quite interested to learn about it.
Questions tagged [literate-programming] - Software Engineering …
May 17, 2012 · Stack Exchange Network. Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
comments - Style and recommendations of commenting code
Literate programming tools are used to obtain two representations from a literate source file: one suitable for further compilation or execution by a computer, the "tangled" code, and another for viewing as formatted documentation, which is said to be "woven" from the literate source.
Questions tagged [literate-programming] - Software Engineering …
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Using π, φ, λ etc. as variable names while programming?
As for me, all the languages are pretty similar in this aspect, because I'm using a latex-based literate programming. – SK-logic Commented Mar 4, 2014 at 15:43
Why is there such limited support for Design by Contract in most …
You can adopt literate programming-style tools so that you write a document which includes your DbC information and which generates clean Python plus unit test scripts. The literate programming approach allows you to write a nice piece of literature which includes the contracts and the complete source.