an introduction kernighan brian w

58
Brian W. Kernighan An Introduction Daniel M. Berry

Upload: others

Post on 13-Nov-2021

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Introduction Kernighan Brian W

Brian W.KernighanAn Introduction

Daniel M. Berry

2004 D.M. Berry Introduction Brian Kernighan Pg. 1

Page 2: An Introduction Kernighan Brian W

Why I am Introducing BWK

I wanted to introduce Brian because I am one ofthe few people on Earth that is still using hisDevice-Indpendent Typesetter Run-Off (ditroff )program.

I use ditroff for almost all of my typesetting.

Even these slides were done by ditroff ; I ditroff toPOSTSCRIPT and then distill that POSTSCRIPT

to pdf so that I can use the slide-show features ofacroread to display them now.

2004 D.M. Berry Introduction Brian Kernighan Pg. 2

Page 3: An Introduction Kernighan Brian W

Why do I stick to this ancient program that hasn’tbeen changed since 1985?

2004 D.M. Berry Introduction Brian Kernighan Pg. 3

Page 4: An Introduction Kernighan Brian W

Why do I stick to this ancient program that hasn’tbeen changed since 1985?

Well, why should I switch?

2004 D.M. Berry Introduction Brian Kernighan Pg. 4

Page 5: An Introduction Kernighan Brian W

Why do I stick to this ancient program that hasn’tbeen changed since 1985?

Well, why should I switch?

Has the set of things one does to a printeddocument changed since 1985?

2004 D.M. Berry Introduction Brian Kernighan Pg. 5

Page 6: An Introduction Kernighan Brian W

Why do I stick to this ancient program that hasn’tbeen changed since 1985?

Well, why should I switch?

Has the set of things one does to a printeddocument changed since 1985?

Also, compare the first paragraph of Brian’sabstract done with ditroff, Microsoft’s word, andTEX.

2004 D.M. Berry Introduction Brian Kernighan Pg. 6

Page 7: An Introduction Kernighan Brian W

ditroff VersionThis talk is based on my experience teaching“Computers in Our World,” a course for studentsin the humanities and social sciences. The coursedescribes how computing works–hardware, soft-ware, networks, and systems built upon them–for avery non-technical audience. The intent, or per-haps just fond hope, is to help students understandspecific technologies better, but also how to reasonabout how systems work and how to be intelli-gently skeptical about technology and technologi-cal claims.

2004 D.M. Berry Introduction Brian Kernighan Pg. 7

Page 8: An Introduction Kernighan Brian W

word Version This talk is based on my experience teaching “Computers in Our World,” a course for students in the humanities and social sciences. The course describes how computing works–hardware, software, networks, and systems built upon them–for a very non-technical audience. The intent, or perhaps just fond hope, is to help students understand specific technologies better, but also how to reason about how systems work and how to be intelligently skeptical about technology and technological claims.

Page 9: An Introduction Kernighan Brian W

TEX VersionThis talk is based on my experience teaching “Computers inOur World,” a course for students in the humanities and so-cial sciences. This course describes how computing works–hardware, software, networks, and systems built upon them–for a very non-technical audience. The intent, or perhaps justfond hope, is to help students understand specific technolo-gies better, but also how to reason about how systems workand how to be intelligently skeptical about technology andtechnological claims.

Page 10: An Introduction Kernighan Brian W

In the MS word version, notice the hockeyplayer’s mouth effect and the two beady eye ballsstaring at you from the word “specific”.

2004 D.M. Berry Introduction Brian Kernighan Pg. 10

Page 11: An Introduction Kernighan Brian W

In the MS word version, notice the hockeyplayer’s mouth effect and the two beady eye ballsstaring at you from the word “specific”.

Notice how much nicer the ditroff and TEXversions are.

2004 D.M. Berry Introduction Brian Kernighan Pg. 11

Page 12: An Introduction Kernighan Brian W

Admittedly TEX, with its multipass, optimizingplacement algorithm, does a nicer job of spacingand line breaking than ditroff.

2004 D.M. Berry Introduction Brian Kernighan Pg. 12

Page 13: An Introduction Kernighan Brian W

Admittedly TEX, with its multipass, optimizingplacement algorithm, does a nicer job of spacingand line breaking than ditroff.

However, ditroff ’s simple one-pass greedyplacement algorithm makes it much easier tocontrol the placement of footnotes and floatingfigures.

2004 D.M. Berry Introduction Brian Kernighan Pg. 13

Page 14: An Introduction Kernighan Brian W

You are guaranteed that if there is enough roomfor a footnote on the current page, it will be placedthere, …

2004 D.M. Berry Introduction Brian Kernighan Pg. 14

Page 15: An Introduction Kernighan Brian W

You are guaranteed that if there is enough roomfor a footnote on the current page, it will be placedthere, …

and if you change text that follows a figure, thereis no chance that the figure will move up fromwhere it was placed before you changed the text,…

2004 D.M. Berry Introduction Brian Kernighan Pg. 15

Page 16: An Introduction Kernighan Brian W

You are guaranteed that if there is enough roomfor a footnote on the current page, it will be placedthere, …

and if you change text that follows a figure, thereis no chance that the figure will move up fromwhere it was placed before you changed the text,…

unlike in TEX.

2004 D.M. Berry Introduction Brian Kernighan Pg. 16

Page 17: An Introduction Kernighan Brian W

You are guaranteed that if there is enough roomfor a footnote on the current page, it will be placedthere, …

and if you change text that follows a figure, thereis no chance that the figure will move up fromwhere it was placed before you changed the text,…

unlike in TEX.

The latter problem is known to happen also withMS word.

2004 D.M. Berry Introduction Brian Kernighan Pg. 17

Page 18: An Introduction Kernighan Brian W

Moreover, since ditroff has not been modifiedsince 1985, its speed doubles every 18 months,…

2004 D.M. Berry Introduction Brian Kernighan Pg. 18

Page 19: An Introduction Kernighan Brian W

Moreover, since ditroff has not been modifiedsince 1985, its speed doubles every 18 months,…

and its size is still only 272K! Yes, 272K and not8.39M and growing!

2004 D.M. Berry Introduction Brian Kernighan Pg. 19

Page 20: An Introduction Kernighan Brian W

Moreover, since ditroff has not been modifiedsince 1985, its speed doubles every 18 months,…

and its size is still only 272K! Yes, 272K and not8.39M and growing!

ditroff now formats a 100-page document fasterthan MS word updates the page you are lookingat!

2004 D.M. Berry Introduction Brian Kernighan Pg. 20

Page 21: An Introduction Kernighan Brian W

More about BWK

I note that in our Distinguished Lecturer Series,we have had Alfred Aho, and today we have BrianKernighan. You could say that we have had boththe front end and the back end of awk.

Our visitor’s login is bwk, just one letter up fromawk !

2004 D.M. Berry Introduction Brian Kernighan Pg. 21

Page 22: An Introduction Kernighan Brian W

Local Roots

Brian is a local boy, born in Toronto, teenager inMilton, educated at UT, with relatives inCambridge, Mississauga, and even at UW!

As Brian says, “waterloo is friends and family.”

2004 D.M. Berry Introduction Brian Kernighan Pg. 22

Page 23: An Introduction Kernighan Brian W

A Promise

I promised not to do the standard boringintroduction, reading from his biography.

You can read it yourself on the flyer announcingthis lecture or at his website.

I will talk, as I always do when I am introducingsomeone, about the lessons I have learned fromthe speaker’s work!

I sort of promised also to be short.. Oh well..

2004 D.M. Berry Introduction Brian Kernighan Pg. 23

Page 24: An Introduction Kernighan Brian W

Lessons Learned from BWK

What did I learn from Brian?

To explain them, let’s look at a pic-generateddiagram of the architecture and dataflow of theentire ditroff system. (pic is another of Brian’sprograms that I still use!)

2004 D.M. Berry Introduction Brian Kernighan Pg. 24

Page 25: An Introduction Kernighan Brian W

file psfig refer et_al grap pic tbl eqn alg*dotchart

scatmat

drag

dformat

dag

chem

flo

music

swizzle

dtroff

macros

indx

indexterms

ffortid bditroff pm psdit laserprinter

screen

phototype-setter

2004 D.M. Berry Introduction Brian Kernighan Pg. 25

Page 26: An Introduction Kernighan Brian W

I have learned from Brian the concepts of

2004 D.M. Berry Introduction Brian Kernighan Pg. 26

Page 27: An Introduction Kernighan Brian W

I have learned from Brian the concepts of

g piped architectures,

2004 D.M. Berry Introduction Brian Kernighan Pg. 27

Page 28: An Introduction Kernighan Brian W

I have learned from Brian the concepts of

g piped architectures,

g editable input and output, and

2004 D.M. Berry Introduction Brian Kernighan Pg. 28

Page 29: An Introduction Kernighan Brian W

I have learned from Brian the concepts of

g piped architectures,

g editable input and output, and

g little languages.

2004 D.M. Berry Introduction Brian Kernighan Pg. 29

Page 30: An Introduction Kernighan Brian W

The first two permit highly modular systems thatcan be extended easily by the third, written avariety of languages, including the language of ahuman-operated editor.

2004 D.M. Berry Introduction Brian Kernighan Pg. 30

Page 31: An Introduction Kernighan Brian W

The first two permit highly modular systems thatcan be extended easily by the third, written avariety of languages, including the language of ahuman-operated editor.

The first and third really separate the concerns;each kind of document element, e.g., tables orformulae, has its own little language andprocessor, which can be modified independentlyof all others, including the main module ditroff.

2004 D.M. Berry Introduction Brian Kernighan Pg. 31

Page 32: An Introduction Kernighan Brian W

file psfig refer et_al grap pic tbl eqn alg*dotchart

scatmat

drag

dformat

dag

chem

flo

music

swizzle

dtroff

macros

indx

indexterms

ffortid bditroff pm psdit laserprinter

screen

phototype-setter

2004 D.M. Berry Introduction Brian Kernighan Pg. 32

Page 33: An Introduction Kernighan Brian W

file psfig refer et_al grap pic tbl eqn alg*dotchart

scatmat

drag

dformat

dag

chem

flo

music

swizzle

dtroff

macros

indx

indexterms

ffortid bditroff pm psdit laserprinter

screen

phototype-setter

2004 D.M. Berry Introduction Brian Kernighan Pg. 33

Page 34: An Introduction Kernighan Brian W

By adding the boxes with red-colored outline, mystudents and I were able to add the followingfunctions to the ditroff system:

2004 D.M. Berry Introduction Brian Kernighan Pg. 34

Page 35: An Introduction Kernighan Brian W

By adding the boxes with red-colored outline, mystudents and I were able to add the followingfunctions to the ditroff system:

g Right-to-left formatting for Arabic, Hebrew,Persian, and Urdu, with stretchable letters

2004 D.M. Berry Introduction Brian Kernighan Pg. 35

Page 36: An Introduction Kernighan Brian W

By adding the boxes with red-colored outline, mystudents and I were able to add the followingfunctions to the ditroff system:

g Right-to-left formatting for Arabic, Hebrew,Persian, and Urdu, with stretchable letters

g Top-to-bottom formatting for Chinese,Japanese, and Korean

2004 D.M. Berry Introduction Brian Kernighan Pg. 36

Page 37: An Introduction Kernighan Brian W

By adding the boxes with red-colored outline, mystudents and I were able to add the followingfunctions to the ditroff system:

g Right-to-left formatting for Arabic, Hebrew,Persian, and Urdu, with stretchable letters

g Top-to-bottom formatting for Chinese,Japanese, and Korean

g Back-of-the-book indexes without clutteringthe source of the book with indexingcommands

2004 D.M. Berry Introduction Brian Kernighan Pg. 37

Page 38: An Introduction Kernighan Brian W

By adding the boxes with red-colored outline, mystudents and I were able to add the followingfunctions to the ditroff system:

g Right-to-left formatting for Arabic, Hebrew,Persian, and Urdu, with stretchable letters

g Top-to-bottom formatting for Chinese,Japanese, and Korean

g Back-of-the-book indexes without clutteringthe source of the book with indexingcommands

g Flowcharting: Pascal → flowchart

2004 D.M. Berry Introduction Brian Kernighan Pg. 38

Page 39: An Introduction Kernighan Brian W

By adding the boxes with red-colored outline, mystudents and I were able to add the followingfunctions to the ditroff system:

g Right-to-left formatting for Arabic, Hebrew,Persian, and Urdu, with stretchable letters

g Top-to-bottom formatting for Chinese,Japanese, and Korean

g Back-of-the-book indexes without clutteringthe source of the book with indexingcommands

g Flowcharting: Pascal → flowchartg Replacing all but first author in a

bibliographical reference by “et al ”

2004 D.M. Berry Introduction Brian Kernighan Pg. 39

Page 40: An Introduction Kernighan Brian W

We were able to do all this without modifying thefunctionality of any program in the existingcollection.

We did correct a few bugs that were exposed byour use of rarely used features; these correctionswere passed on to Brian for distribution to ditrofflicensees.

Each of the additions is effectively a littlelanguage processor that sits in the pipe withother programs.

2004 D.M. Berry Introduction Brian Kernighan Pg. 40

Page 41: An Introduction Kernighan Brian W

So I can still do

g graphsg line drawingsg tablesg formulae

In the midst of a tri-directional, multilingualdocument with flowcharts, and index, andreduced author lists in the bibliography!

2004 D.M. Berry Introduction Brian Kernighan Pg. 41

Page 42: An Introduction Kernighan Brian W

The extreme modularity of the ditroff systemallowed my group to finish building thebidirectional ditroff one year before the TEXgroup finished building the bidirectional TEX,even though we started one year after they did.

2004 D.M. Berry Introduction Brian Kernighan Pg. 42

Page 43: An Introduction Kernighan Brian W

Because the input and output of all of theseprograms is simple, editable ASCII, it is very easyto prototype a new little language processor

2004 D.M. Berry Introduction Brian Kernighan Pg. 43

Page 44: An Introduction Kernighan Brian W

Because the input and output of all of theseprograms is simple, editable ASCII, it is very easyto prototype a new little language processor

g manually, using a human-operated editor thatis invoked by one command in the pipe insidea makefile,

2004 D.M. Berry Introduction Brian Kernighan Pg. 44

Page 45: An Introduction Kernighan Brian W

Because the input and output of all of theseprograms is simple, editable ASCII, it is very easyto prototype a new little language processor

g manually, using a human-operated editor thatis invoked by one command in the pipe insidea makefile,

g with a scripting language, such as sed, awk, orperl, or

2004 D.M. Berry Introduction Brian Kernighan Pg. 45

Page 46: An Introduction Kernighan Brian W

Because the input and output of all of theseprograms is simple, editable ASCII, it is very easyto prototype a new little language processor

g manually, using a human-operated editor thatis invoked by one command in the pipe insidea makefile,

g with a scripting language, such as sed, awk, orperl, or

g with C or C++.

2004 D.M. Berry Introduction Brian Kernighan Pg. 46

Page 47: An Introduction Kernighan Brian W

Also, I have been known to cheat!

If a processor lacks a feature I need, I arrange fora placeholder to be output by the processor, and Iedit the output manually to produce the outputthat would be there if the feature were available.

I have done this to the output of refer, pic, andeqn.

2004 D.M. Berry Introduction Brian Kernighan Pg. 47

Page 48: An Introduction Kernighan Brian W

Is This All Useful?

2004 D.M. Berry Introduction Brian Kernighan Pg. 48

Page 49: An Introduction Kernighan Brian W

Is This All Useful?

Well, I have a publication from each of the firstfour added functionalities, and I typeset the paperabout each processor in the journal’s own format,using the software we wrote and the ditroffcollection!

2004 D.M. Berry Introduction Brian Kernighan Pg. 49

Page 50: An Introduction Kernighan Brian W

Is This All Useful?

Well, I have a publication from each of the firstfour added functionalities, and I typeset the paperabout each processor in the journal’s own format,using the software we wrote and the ditroffcollection!

I published, in a rabbinical journal, a commentaryabout the first sentence of Genesis; this paperquotes the original Hebrew.

2004 D.M. Berry Introduction Brian Kernighan Pg. 50

Page 51: An Introduction Kernighan Brian W

Is This All Useful?

Well, I have a publication from each of the firstfour added functionalities, and I typeset the paperabout each processor in the journal’s own format,using the software we wrote and the ditroffcollection!

I published, in a rabbinical journal, a commentaryabout the first sentence of Genesis; this paperquotes the original Hebrew.

Also I made my own visiting card using thissoftware!

2004 D.M. Berry Introduction Brian Kernighan Pg. 51

Page 52: An Introduction Kernighan Brian W

Fax: +1-519-746-5422E-mail: [email protected]

HTTP://se.uwaterloo.ca/˜dberry/

Daniel M. Berry, Ph.D.Professor

+ � K � 9 J

Daoiem~ M. Aeri

∆ανιηλ Μ. Μπερι

DÅNÅÑyÅL bÅárÑ

T

,

X

¢¹q �¹�BN

ברי דניאל

Page 53: An Introduction Kernighan Brian W

Fax: +1-519-746-5422E-mail: [email protected]

HTTP://se.uwaterloo.ca/˜dberry/

Daniel M. Berry, Ph.D.Professor

+ � K � 9 J

Daoiem~ M. Aeri

∆ανιηλ Μ. Μπερι

DÅNÅÑyÅL bÅárÑ

T

,

X

¢¹q �¹�BN

ברי דניאל

Page 54: An Introduction Kernighan Brian W

Brian’s Code

In the process of doing all what I have described, Ihappened to read a lot of Brian’s code.

His code is the most readable I have ever seen,and this is in spite of his use of short identifiers.

Real works of art!

2004 D.M. Berry Introduction Brian Kernighan Pg. 54

Page 55: An Introduction Kernighan Brian W

Conclusion

This is what I have learned from Brian!

Thank you, Brian!

Now, we shall find out if this is what I should havelearned from him!

2004 D.M. Berry Introduction Brian Kernighan Pg. 55

Page 56: An Introduction Kernighan Brian W

ditroff VersionThis talk is based on my experience teaching“Computers in Our World,” a course for studentsin the humanities and social sciences. The coursedescribes how computing works–hardware, soft-ware, networks, and systems built upon them–for avery non-technical audience. The intent, or per-haps just fond hope, is to help students understandspecific technologies better, but also how to reasonabout how systems work and how to be intelli-gently skeptical about technology and technologi-cal claims.

2004 D.M. Berry Introduction Brian Kernighan Pg. 56

Page 57: An Introduction Kernighan Brian W

word Version This talk is based on my experience teaching “Computers in Our World,” a course for students in the humanities and social sciences. The course describes how computing works–hardware, software, networks, and systems built upon them–for a very non-technical audience. The intent, or perhaps just fond hope, is to help students understand specific technologies better, but also how to reason about how systems work and how to be intelligently skeptical about technology and technological claims.

Page 58: An Introduction Kernighan Brian W

TEX VersionThis talk is based on my experience teaching “Computers inOur World,” a course for students in the humanities and so-cial sciences. This course describes how computing works–hardware, software, networks, and systems built upon them–for a very non-technical audience. The intent, or perhaps justfond hope, is to help students understand specific technolo-gies better, but also how to reason about how systems workand how to be intelligently skeptical about technology andtechnological claims.