An Introduction Kernighan Brian W

Preview:

Citation preview

Brian W.KernighanAn Introduction

Daniel M. Berry

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

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

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

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

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

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

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

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

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.

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

I have learned from Brian the concepts of

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

I have learned from Brian the concepts of

g piped architectures,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Is This All Useful?

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

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

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

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

Fax: +1-519-746-5422E-mail: dberry@uwaterloo.ca

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

ברי דניאל

Fax: +1-519-746-5422E-mail: dberry@uwaterloo.ca

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

ברי דניאל

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

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

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

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.

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.

Recommended