Donald Knuth: about assembler, translator and competent programming

Original author: Web of Stories
  • Transfer
" Literate programming (literate programming) - the attitude to computer programs, like literature: a computer program is written not so much for a computer as for people so that people can read it. And since I write programs, I’m kind of a teacher. "

image


“Let's change the traditional priorities in creating programs: instead of understanding our task as creating instructions“ What to do? ” for a computer, we’ll concentrate on explaining to other people the descriptions of our vision of what a computer should do under the control of a program. ”

Literate programming (66/97)




Meanwhile, I also decided on the exact version of TeX and the very concept of literate programming. Let me go back a bit to the story of the Weave and Tangle utilities. In general, I think that the greatest benefit of printing was the idea of ​​creating what is called "literate programming."

I like to teach. I do not just train a computer, I teach readers of my programs. I hope that one day they will award the Pulitzer Prize for the most competent program, etc.

image

I started this experiment because a friend of mine, Professor Hoar from Oxford, said: "Don, people don’t even read computer programs."

Oxford University Press was interested in publishing some computer programs, as examples of how they should be written.

And instead of some obscure files that people should also read, it would be a kind of literature, such as musical notation. People publish symphony scores, not just listen to them. So why can't we publish computer programs? And his idea stuck in my head, but at the same time it scared me, because the real computer programs already created are full of compromises. The computer science professor could not allow this.

You can write a small program and compare it with small gems, but when it comes to a large program, we can, of course, pretend that it is a jewel, but that would not be so. And I do not think that many program creators would be glad that other people would read their work in the form in which it was available then. And I began to think how to write a program so that people would like to read it.

So, obviously, this idea of ​​competent programming came up, I found a format in which I could present the program to other people, moreover, as the creator of this program, I could understand it better. And so I got to this system, in which I could write a program in this programming language, then from this one program I created two more - one was converted from a description languageWEB- services Pascal, and the other - from the description language of WEB- services to a document that I could read thanks to layout, cross-references and clear statements.

This system made me very happy. I wrote programs in CWEB - this is the “descendant” of the original WEB system, and it gives me endless happiness to write programs in the form that I find most suitable.

image
Donald E. Knuth: Literate Programming

Learning about Symbolic Optimum Assembly programs (23/97)




My family and I went to the Lynwood Summer Camp for a week, which is located on the shores of Lake Erie. And we were there again a couple of years ago to refresh our memories. So, we spent two weeks on the lake. I played tennis with my uncles and stuff like that, but I also brought along some examples of computer programs that I had heard about. And I had some free time that summer to get to know them. And, in fact, these programs have had a huge impact on my future life.

One of the programs was called assembler - it allowed you to write programs using not a machine language, but a more symbolic one. It made things a lot easier ... I mean, when I started writing programs, I wrote everything in numbers, and if I needed to add a number in section 1 to a number located in section 2, then I had to write something like that 20,0,0,1. I had to write out all these numbers, drive them into cards, and only then use them in my work - that's all I knew about programming at that time.

But that program was an innovation for that time, and it allowed writing programs in a simpler way. Instead of choosing a number for each section in the program, I could give it a name, and the device itself already determined which number corresponds to this name. But in those days, computers could not cope well with letters, they were designed to work with numbers, but capital letters could be used. Up to five letters per word could be used with this assembler.

( Note from safinaskar : “This assembler allowed the use of labels”)

I remember exactly how I used this for my Tic-Tac-Toe program, and I had to figure out which five-letter word would define a specific section of the program. And I remember with enthusiasm how I played tic-tac-toe, and how at the time of winning the program switched to the BINGO site. I used this five-letter word B, I, N, D, O for this section of the program.

Yes, I then learned about assembler and learned how to code. I used this in my work, but at the same time I wondered: “How does it work? What generally happened inside, and how did the word BINGO compare with a number? How did the device immediately understand this? ” I had a listing for this program called SOAP 2 from Stan Paul of IBM. I myself also had a listing of a program called "Translator" (IT-Internal Translator) - a new program that was created by 4 people at Carnegie University of Carnegie Mellon. This translator used an algebraic language, not a machine language. And this is long before Fortran or other high-level programming languages ​​appeared. I’m talking about 1956.1957.

And the essence was that you can write X = A + B, well, actually it wasn’t possible to write, because there was no way to use the “+” symbol, so we wrote, X1, Z, X2, S, X3, where S denoted “+”, and the letter Z was used instead of “=”, and each variable as X1, X2, X3 or something similar. But not less than the topic, you could enter an algebraic formula into the map, and then the apparatus already determined from this how to calculate A + B or what you need to do.

Instead of being denoted by numbers or symbols, there were algebraic symbols. And you could just transfer the program to a computer, and then the lights came on, and after a while you received a device with a computer programming language. Magic. I could not understand how it works at all, so I got a copy of the program that they used to write this translator, and I got a copy of the SOAP program

The Internal Translator (24/97)




I brought this with me and spent the nights studying and trying to figure out how the program works. And, yes, I succeeded ... First, I found out how the translator works, how exactly it translates an algebraic formula into instructions. But then everything was done terribly. There were errors in the program. Each time sharing something, the creators barely managed to bring it to the end.

I then turned to the SOPE program, the one from Stan Paul - this program was accurate, incredible, as if you were listening to a symphony. Everything connected so harmoniously, and this code was simple. I said then: “I would like to write programs like this guy does.” And that second code from other developers, it was bulky and clumsy. “But I can write better than that.”

Therefore, several of my friends and I wrote an improved version and called it RUNCIBLE, because each program had to have an acronym at that time, and it meant something like “Revised Unified New Compiler IT Basic Language Extended ) or something like that. We had several reasons to call the program that way, but we wanted to remake that algebraic language, bring it into a more ordered form, and then we were able to slightly improve the program, and at the same time fit in the same 10kbytes.

That's how I spent my first summer at the Computer Center. And then, after the RUNCIBLE program was written, we also ... I also wrote an instruction manual for this program, and surprisingly, this instruction was used as a guide for students for the next year. And I was in a rather unusual situation: at one of the classes they used the very book that I wrote when I was in my second year.

And RUNCIBLE, we updated this program next summer, added a bunch of all kinds of little things there, fitting them in 10kbytes. But we still had a floating point and other things that needed to be worked on ... Therefore, we again decided to make an improved version. And so I wrote SOAP 3. You know, I liked the SOAP 2 program from IBM. I wrote SOAP 3, which was based on SOAP 2, and later on we used it as assembler to improve software. And Case allowed about a dozen students to write programs that would later be used by other students or faculties.

Fred Way, the director of this program, was very visionary, he trusted students and let us ... well, we had a great time talking with each other about all this. We also received the monthly magazine of the Association of Computing Engineering in 1958. Then we saw that people from all over the world published their ideas on how to write programs, and then we realized that we already know all these things and even more.

So my second post, after the Potrzebie System for Mad Magazine, was an article on RUNCIBLE: turning formulas into machine code. I sent my article to the journal of the Association of Computing Engineering, which was then just beginning to print. I was very naive at that time, did not understand how to print correctly in scientific journals. Yes, I saw magazines, I knew that an article could be sent there, but had no idea about the meaning. The story itself was important to me, so I wrote it.

I considered myself a speaker, a representative of these guys from the Case Computer Center, with whom I worked together on the creation of RUNCIBLE. And I wrote an article about the methods that we used for RUNCIBLE, but nowhere in the article did I mention the names of these guys, and I did not know that I would get the sum for these ideas, I just wanted to describe them.

Only later I realized all this, learned about conventions. And at that moment, I just wrote an article. And we prepared this material correctly when the article was already published, as part of my collected work several years ago.

The publication is supported by the Edison company , which is developing a notification system for traders , as well as creating a system of energy and water metering for a cottage village .

Read more



List of 97 Donald Knuth videos
Youtube playlist

1. Family history
2. Learning to read and school
3. My mother
4. My parents' finances
5. Interests in high school
6. Being a nerd of nerds at high school
7. My sense of humor
8. The Potrzebie System of Weights and Measures
9. Feeling the need to prove myself
11. University life: my basketball management system
12. University life: the fraternity system
13. Meeting my wife Jill
14. Bible study at university and a time of personal challenge
15. Extra-curricular activities at Case
16. Taking graduate classes at Case
17. Physics, welding, astronomy and mathematics
18. My maths teacher at Case and a difficult problem
19. My interest in graphs and my first experience of a computer
20. How I got interested in programming
21. Learning how to program on the IBM 650
22. Writing a tic-tac-toe program
23. Learning about Symbolic Optimum Assembly programs
24. The Internal Translator
25. Adding more features to RUNCIBLE
26. Wanting to be a teacher and why I chose to go to Caltech
27. Writing a compiler for the Burroughs Corporation
28. Working for the Burroughs Corporation
29. Burroughs Corporation
30. My interest in context-free languages
31. Getting my PhD and the problem of symmetric block designs with ...
32. Finding a solution to an open problem about projective planes
33. Inception of The Art of Computer Programming
34. 1967: a turbulent year
35. Work on attribute grammars and the Knuth-Bendix Algorithm
36. Being creative in the forest
37. A new field: analysis of algorithms
38. The Art of Computer Programming: underestimating the size of the ...
39. The successful first release of The Art of Computer Programming
40. Inspiration to write Surreal Numbers
41.Writing Surreal Numbers in a hotel room in Oslo
42. Finishing the Surreal Numbers
43. The emergence of computer science as an academic subject
44. I want to do computer science instead of arguing for it
45. A year doing National Service in Princeton
46. Moving to Stanford and wondering whether I'd made the right choice
47. Designing the house in Stanford
48. Volume Three of The Art of Computer Programming
49. Working on Volume Four of The Art of Computer Programming
50. Poor quality typesetting on the second edition of my book
51. Deciding to make my own typesetting program
52. Working on my typesetting program
53. Mathematical formula for letter shapes
54. Research into the history of typography
55. Working on my letters and problems with the S
56. Figuring out how to typeset and the problem with specifications
57. Working on TeX
58. Why the designer and the implementer of a program should be the ...
59. Converting Volume Two to TeX
60. Writing a users' manual for TeX
61. Giving the Gibbs lecture on my typography work
62. Developing Metafont and TeX
63. Why I chose not to retain any rights to TeX and transcribed it to ...
64. Tuning up my fonts and getting funding for TeX
65. Problems with Volume Two
66. Literate programming
67. Re-writing TeX using the feedback I received
68. The importance of stability for TeX
69. LaTeX and ConTeXt
70. A summary of the TeX project
71. A year in Boston
72. Writing a book about the Bible
73. The most beautiful 3:16 in the world
74. Chess master playing at Adobe Systems
75. Giving a lecture series on science and religion at MIT
76. Back to work at Stanford and taking early retirement
77. Taking up swimming to help me cope with stress
78 My graduate students and my 64th birthday
79. My class on Concrete Mathematics
80. Writing a book on my Concrete Mathematics class
81.Updating Volumes One to Three of The Art of Computer Programming
82. Getting started on Volume Four of “The Art of Computer ...
83. Two final major research projects
84. My love of writing and a lucky life
85. Coping with cancer
86 Honorary doctorates
87. The importance of awards and the Kyoto Prize
88. Pipe organ music is one of the great pleasures of life
89. The pipe organ in my living room
90. Playing the organs
91. An international symposium on algorithms in the Soviet Union
92. The Knuth-Morris-Pratt algorithm
93. My advice to young people
94. My children: John
95. My children: Jenny
96. Working on a series of books of my collected papers
97. Why I chose analysis of algorithms as a subject

Also popular now: