Skip to content
Lex Fridman PodcastLex Fridman Podcast

Brian Kernighan: UNIX, C, AWK, AMPL, and Go Programming | Lex Fridman Podcast #109

Brian Kernighan is a professor of computer science at Princeton University. He co-authored the C Programming Language with Dennis Ritchie (creator of C) and has written a lot of books on programming, computers, and life including the Practice of Programming, the Go Programming Language, his latest UNIX: A History and a Memoir. He co-created AWK, the text processing language used by Linux folks like myself. He co-designed AMPL, an algebraic modeling language for large-scale optimization. Support this podcast by supporting our sponsors: - Eight Sleep: https://eightsleep.com/lex - Raycon: http://buyraycon.com/lex EPISODE LINKS: Brian's website: https://www.cs.princeton.edu/~bwk/ Unix: A History and a Memoir (book): https://amzn.to/3fFJ1yM Understanding the Digital World (book): https://amzn.to/30ktBJI PODCAST INFO: Podcast website: https://lexfridman.com/podcast Apple Podcasts: https://apple.co/2lwqZIr Spotify: https://spoti.fi/2nEwCF8 RSS: https://lexfridman.com/feed/podcast/ Full episodes playlist: https://www.youtube.com/playlist?list=PLrAXtmErZgOdP_8GztsuKi9nrraNbKKp4 Clips playlist: https://www.youtube.com/playlist?list=PLrAXtmErZgOeciFP3CBCIEElOJeitOr41 OUTLINE: 0:00 - Introduction 4:24 - UNIX early days 22:09 - Unix philosophy 31:54 - Is programming art or science? 35:18 - AWK 42:03 - Programming setup 46:39 - History of programming languages 52:48 - C programming language 58:44 - Go language 1:01:57 - Learning new programming languages 1:04:57 - Javascript 1:08:16 - Variety of programming languages 1:10:30 - AMPL 1:18:01 - Graph theory 1:22:20 - AI in 1964 1:27:50 - Future of AI 1:29:47 - Moore's law 1:32:54 - Computers in our world 1:40:37 - Life CONNECT: - Subscribe to this YouTube channel - Twitter: https://twitter.com/lexfridman - LinkedIn: https://www.linkedin.com/in/lexfridman - Facebook: https://www.facebook.com/LexFridmanPage - Instagram: https://www.instagram.com/lexfridman - Medium: https://medium.com/@lexfridman - Support on Patreon: https://www.patreon.com/lexfridman

Lex FridmanhostBrian Kernighanguest
Jul 18, 20201h 43mWatch on YouTube ↗

EVERY SPOKEN WORD

  1. 0:004:24

    Introduction

    1. LF

      The following is a conversation with Brian Kernighan, a professor of computer science at Princeton University. He was a key figure in the computer science community in the early UNIX days, alongside UNIX creators Ken Thompson and Dennis Ritchie. He co-authored the C programming language with Dennis Ritchie, the creator of C, and has written a lot of books on programming, computers, and life, including The Practice of Programming, The Go Programming Language, and his latest, UNIX: A History and a Memoir. He co-created awk, the text processing language used by Linux folks like myself. He co-designed AMPL, an algebraic modeling language that I personally love and have used a lot in my life for large scale optimization. I think I can keep going for a long time with his creations and accomplishments, which is funny, because given all that, he's one of the most humble and kind people I've spoken to on this podcast. Quick summary of the ads. Two new sponsors. The amazing self-cooling Eight Sleep mattress and Raycon earbuds. Please consider supporting the podcast by going to EightSleep.com/Lex and going to BuyRaycon.com/Lex. Click the links, buy the stuff. It really is the best way to support this podcast and the journey I'm on. If you enjoy this thing, subscribe on YouTube, review it with five stars on Apple Podcasts, support it on Patreon, or connect with me on Twitter @LexFridman. As usual, I'll do a few minutes of ads now, and never any ads in the middle that can break the flow of the conversation. This show is sponsored by Eight Sleep and its incredible Pod Pro mattress that you can check out at EightSleep.com/Lex to get $200 off. The mattress controls temperature with an app and can cool down to as low as 55 degrees. Research shows that temperature has a big impact on the quality of our sleep. Anecdotally, it've been a game changer for me. I love it. The Pod Pro is packed with sensors that track heart rate, heart rate variability, and respiratory rate, showing it all on their app once you wake up. Plus, if you have a partner, you can control the temperature of each side of the bed. I don't happen to have one, but the Eight Sleep app reminds me that I should probably get on that. So ladies, if a temperature controlled mattress isn't a good reason to apply, I don't know what is. The app's health metrics are amazing, but the cooling alone is honestly worth the money. As some of you know, I don't always sleep, but when I do, I choose the Eight Sleep Pod Pro mattress. Check it out at EightSleep.com/Lex to get $200 off. This show is also sponsored by Raycon earbuds. Get them at BuyRaycon.com/Lex. They've quickly become my main method of listening to podcasts, audiobooks, and music when I run, do the push-ups and pull-ups that I've begun to hate at this point, or just living life. In fact, I often listen to brown noise with these when I'm thinking deeply about something. It helps me focus the mind. They're super comfortable, pair easily, great sound, great bass, six hours of playtime. In fact, for fun, I have one of the earbuds in now and I'm listening to Europa by Santana, probably one of my favorite guitar songs. It kind of makes me feel like I'm in a music video. So, they told me to say that a bunch of celebrities use these, like Snoop Dogg, Melissa Etheridge, and Cardi B. I don't even know who Cardi B is, but her earbud game is on point. To mention celebrities I actually care about, I'm sure if Richard Feynman was still with us, he'd be listening to The Joe Rogan Experience with Raycon earbuds. Get them at BuyRaycon.com/Lex. It's how they know I sent you and increases the chance they'll support this podcast in the future. So for all of the sponsors, click all of the links. It really helps this podcast. And now, here's my conversation with Brian Kernighan.

  2. 4:2422:09

    UNIX early days

    1. LF

      UNIX started being developed 50 years ago, maybe more than 50 years ago. Can you tell the story, like you describe in your new book, of how UNIX was created?

    2. BK

      Huh. If I can remember that far back. (laughs) It was, it was some while ago. Um, so I think the gist of it is that at Bell Labs, eh, in 1969, there were a group of people who had just finished working on the MULTICS project, which was in self-follow on to CTSS. So, we can go back sort of an infinite regress in time, but the, uh, CTSS was a very, very, very nice time sharing system. It was very nice to use. I actually used it as that summer I spent in Cambridge in 1966.

    3. LF

      What was the hardware there? Right, so what's the operating system? What's the hardware there? What's the CTS look like?

    4. BK

      So CTSS looked like, uh, kind of like a standard time sharing system. Certainly at the time, it was the only time sharing of note. (laughs)

    5. LF

      Let's go back to the basic.

    6. BK

      (laughs) Sorry, Okay. In the beginning was the word, and the word- (laughs) So-

    7. LF

      And then there was time sharing systems.

    8. BK

      (laughs) Yeah. If we go back into, let's call it the 1950s and early 1960s, most computing was done on very big computers, physically big, although not terribly powerful by, you know, today's standards, that were maintained in very large rooms, and you used things like punch cards to write your programs on and talk to them. So you would take a deck of cards, write your program on it, send it over a counter, hand it to an operator, and some while later, back would come something that said, "Oh, you made a mistake." And then you'd recycle. And so it was very, very slow. So the idea of time sharing was that you take basically that same computer, but...... connect to it with something that looked like an electric typewriter. They could be a long distance away, it could be close. But fundamentally, what the operating system did was to give each person who was connected to it and wanting to do something a small slice of time on, um, to do a particular job. So, I might be editing a file, so I would be typing, and every time I hit a keystroke, the operating system would wake up and said, "Oh, he typed a character, let me remember that." Then it'd go back to doing something else. So, it'd be going around and around a group of, uh, people who were trying to get something done, giving each a small slice of time and giving them each the illusion that they pretty much had the whole machine to themselves, and hence, time-sharing, that is sharing the computing time resource of the computer among a number of people who are doing it.

    9. LF

      Without the individual people being aware that there's others, in a sense, the illusion, the feelings, that you have the machine as, uh, y- your own.

    10. BK

      Pretty much that was the idea, yes. You had, if it were well done, a- and if it were fast enough and other people weren't doing too much, you did have the illusion that you had the whole machine to yourself, and it was very much better than the punch card model. And so CTSS, the Compatible Time-Sharing System-

    11. LF

      (laughs)

    12. BK

      ... was, I think, arguably the first of these. It was done, I guess, technically '64 or something like that. It ran on an IBM 7094, slightly modified to have twice as much memory as the norm. It had two banks of 32K words instead of one. So (laughs) -

    13. LF

      32K words, yeah, that's-

    14. BK

      Each word was 36 bits so call it, you know, about 150KB times two. So, by today's standards, that's down in the noise.

    15. LF

      Yeah.

    16. BK

      But at the time, that was a lot of memory and memory was expensive. So, uh, CTSS was just a wonderful environment to work on. It was done by the people at MIT led by, uh, Fernando Corbató, Corby, who died just earlier this year, um, and a bunch of other folks. And then, so I spent the summer of '66 working on that. Had a great time. Uh, met a lot of really nice people and indirectly, uh, knew of people at Bell Labs who were also working on a follow-on to CTSS that was called Multics. So, Multics was meant to be the system that would do everything that CTSS did, but do it better for a larger population, all the usual stuff.

    17. LF

      Now, the actual time-sharing, the scheduling, uh, how much... What's the algorithm that performs the scheduling? What's that look like? How much magic is there? What are the metrics? How does it all work in the beginning?

    18. BK

      I- So, the answer is I don't have a clue. I think the basic idea was nothing more than who all wants to get something done. Suppose things are very quiet in the middle of the night, then I get all the time that I want. Suppose that you and I are contending at high noon for something like that, then probably the simplest algorithm is a round-robin one that gives you a bit of time, gives me a bit of time, and then we could adapt to that, like, what are you trying to do? Are you text editing or are you compiling or something? And then we might adjust the scheduler according to things like that.

    19. LF

      So, okay, so Multics was trying to just do some of the, uh, clean it up a little bit.

    20. BK

      Well, it was, it was meant to be much more than that. So, Multics was the Multiplexed Information and Computing Service, and it was meant to be a very large thing that would provide computing utility, something that where you could actually think of it as just a plug-in-the-wall service, sort of like cloud computing today.

    21. LF

      Yeah.

    22. BK

      Same idea, but 50 odd years earlier. And so, uh, what Multics offered was a richer operating system environment, a piece of hardware that was better designed for doing the kind of sharing of resources and presumably lots of other things.

    23. LF

      Do you think people at that time had the dream of what cloud computing is starting to become now, which is computing is everywhere, that you can just plug in almost no- you know, and you never know how the magic works. You just kind of plug in, add your little computation that you need to perform, and it does it. Was that the dream?

    24. BK

      I don't know whether that was the dream. I wasn't part of it at that point, remember, I was an intern for a summer. But my sense is, given that it was over 50 years ago, yeah, they had that idea that it was an information utility, that it was something where if you had a computing task to do, you could just go and do it. Now, I'm betting that they didn't have the same view of computing for the masses, let's call it, the idea that, you know, your grandmother would be shopping on Amazon. I don't think that was part of it. But if your grandmother were a programmer, it might be very easy for her to go and use this kind of utility.

    25. LF

      What was your dream of computers at that time? What did you see as the future of computers 'cause you have predicted what computers are today, in a sense?

    26. BK

      Right. Oh, short answer, absolutely not (laughs) . I have no clue. I'm not sure I had a dream. I- it was a dream job in the sense that I really enjoyed what I was doing. I was surrounded by really, really nice people. Cambridge is a very fine city to live in, in the summer, less so in the winter when it snows, but in the summer, it was a delightful time. And so I really enjoyed all of that stuff and I learned things, and I think the good fortune of being there for a summer led me then to get a summer job at Bell Labs the following summer, and that was going to useful for the future.

    27. LF

      So, this Bell Labs is this magical, legendary place. So, first of all, where is Bell Labs? And can you start talking about that journey towards Unix at Bell Labs?

    28. BK

      Yeah. So, Bell Labs is physically, um, scattered around, uh, at the time, scattered around New Jersey. The primary location was in a town called Murray Hill, or a location called Murray Hill. It was actually the- across the boundary between two small towns in New Jersey called New Providence and Berkeley Heights. Uh, think of it as about 15, 20 miles straight west of New York City.... and therefore about an hour north of here in Princeton. Um, and at that time, it had, make up a number, 3 or 4,000 people there, many of whom had PhDs and mostly doing physical sciences, uh, chemistry, physics, uh, materials kinds of things, but very strong math and it... rapidly growing interest in computing as people realized you could do things with computers that you might not have been able to do before. You could replace labs with computers that had worked on models of what was going on. So, that was, that was the essence of Bell Labs, and again, I wasn't a permanent employee there, I was... that was another internship.

    29. LF

      Yeah.

    30. BK

      I got lucky in internships. (laughs)

  3. 22:0931:54

    Unix philosophy

    1. LF

      do you have a sense of what the philosophy that characterizes Unix's, the design, not just the initial, but just carry through the years, just b- being there, being around it, what's the fundamental philosophy behind the system?

    2. BK

      I think one aspect of the fundamental philosophy was to provide an environment that made it easy to write or easier, productive to write programs. So it was meant as a programmer environment. It wasn't meant specifically as something to do some other kind of job. For example, it was used extensively for word processing, but it wasn't designed as a word processing system. It was used extensively for lab control, but it wasn't designed for that. It was used extensively as a front end for big other systems, big dumb systems, but it wasn't designed for that. It was meant to be an environment where it was really easy to write programs. And so the programmers could be highly productive. And part of that was to be a community, and there's some observation from Dennis Ritchie I, I think at the end of the book that says that in, that from his standpoint, the real goal was to, uh, create a community where people could work, uh, as programmers on the system. And I think in that sense, certainly for many, many years, it succeeded quite well at that. And part of that is the technical aspects of because it made it really easy to write programs, people did write interesting programs, and those programs tended to be used by other programmers, and so it was kind of a virtuous circle, uh, of more and more stuff coming out that was really good for programmers.

    3. LF

      And you're part of that community of programmers. So what was it like writing programs in that early Unix?

    4. BK

      It was a blast. It really was. (laughs) You know, I like to program. I'm not a terribly good programmer, but it was a lot of fun to write code, and in the early days, there was an enormous amount of what you would today, I suppose, call low-hanging fruit. People hadn't done things before, and this was this new environment, and the, the whole combination of nice tools and very responsive system and tremendous colleagues made it possible to write code. You could, you could have an idea in the morning. You could do a, a, you know, an experiment with it. You could have something limping along that night or the next day, and people would react to it, and they would say, "Oh, that's wonderful, but you really screwed up here."... and, and the feedback loop was then very, very short and tight. And so a lot of things got developed fairly quickly that, um, in many cases still exist today, and I think that was part of what made it fun. Because programming itself is fun, it's puzzle-solving in a variety of ways. But I think it's even more fun when you do something that somebody else then uses, even if they whine about it not working, the fact that they used it is, is part of the reward mechanism.

    5. LF

      And what was the method of in- interaction, the communication when you, that feedback loop? I mean, this is before the internet.

    6. BK

      Certainly before the internet. Um, it was mostly physical right there, you know, somebody would come into your office and say something, um-

    7. LF

      So these places are all close by, like offices-

    8. BK

      Oh, yeah.

    9. LF

      ... or nearby, so you-

    10. BK

      Oh, yeah.

    11. LF

      ... had really lively inter- interaction?

    12. BK

      Yeah, yeah. No, Bell Labs was fundamentally one giant building, and most of the people were involved in this Unix stuff were in two or three corridors, and there was a room... Oh, how big was it? Probably, call it 50 feet by 50 feet. Make up a number of that, which had some access to computers there as well as in offices, and people hung out there and it had a coffee machine. And so th- there was a, it was mostly very physical. We did use email, of course, um, and, but it was fundamentally all, for a long time, all on one machine, so there was no need for internet.

    13. LF

      It's fascinating to think about what computing would be today without Bell Labs, 'cause it seems so many... The people being in the vicinity of each other, the sort of getting that quick feedback, working together, so, so many brilliant people. It, I don't know where else that could've existed in the world, um, given how that came together. What... (laughs) Yeah, wh- how does that make you feel that that's, that little element of history?

    14. BK

      Well, I think that's very nice, but i- in a sense it's survivor bias, and if-

    15. LF

      (laughs) Right.

    16. BK

      ... it hadn't happened at Bell Labs, there were other places that were doing really interesting work as well. Xerox PARC is perhaps the most-

    17. LF

      That's right. Yeah.

    18. BK

      ... obvious one. Xerox PARC contributed an enormous amount of good material, um, and many of the things we take for granted today in the same way came from Xerox PARC experience. I don't think they capitalized in the long run as much. Their parent company was perhaps not as lucky in capitalizing on this. Who knows? But that would, that's certainly another place where there was a tremendous amount of, uh, influence. There were a lot of good university activities. MIT was (laughs) obviously no slouch in this kind of thing-

    19. LF

      Yeah.

    20. BK

      ... and, and others as well. Um...

    21. LF

      So Unix turned out to be open source because of the various ways that AT&T operated and sort of it had to, um, it was, the focus was on telephones. So w-

    22. BK

      I think that's a mischaracterization in a sense. It absolutely was not open source. It was-

    23. LF

      Mm-hmm.

    24. BK

      ... very definitely proprietary, licensed, but it was licensed freely to universities in source code-

    25. LF

      Ah.

    26. BK

      ... form for many years. And because of that, generations of university students and their faculty people, uh, grew up knowing about, uh, Unix, and there was enough expertise in the community that it then became possible for people to kind of go off in their own direction and build something that looked Unix-like. Um, the Berkeley version of Unix started with that licensed code and gradually picked up enough of its own, uh, code contributions, notably from people like Bill Joy, that, uh, eventually it was able to become completely free of any T- AT&T code. Now, there was an enormous amount of legal jockeying around this that, in the late, early to late '80s, early '90s, something like that. Um, and then, um, not... Some, the, I guess the open source movement might have started when Richard Stallman started to think about this in the late '80s, and by 1991 when Torvalds decided he was going to do a Unix-like operating system, there was enough expertise that, uh, in the community that first he had a target. He could see what to do because the S- the, kind of the Unix system call interface and the tools and so on were there, um, and so he was able to build a, an operating system that, at this point, when you say Unix, m- in many cases what you're really thinking is Linux.

    27. LF

      Linux, yeah. But it's, it's funny that from my distant perception, I felt that Unix was open source without actually knowing it, but what y- you're really saying it was just, uh, freely licensed. So-

    28. BK

      It was freely licensed, yeah.

    29. LF

      So it felt open source in a se- because universities are not trying to make money so they're, it felt open source in a sense that you can get access if you wanted.

    30. BK

      Right, and, and, and a very, very, very large number of universities had the license and they were able to talk to all the other universities who had the license, and so technically not open, technically belonging to AT&T, pragmatically pretty open.

  4. 31:5435:18

    Is programming art or science?

    1. BK

    2. LF

      So you said you're not a very good programmer. (laughs)

    3. BK

      Uh, true.

    4. LF

      You're, you're the world's most modest human being, okay, but you'll continue saying that. I understand how this works. But you do radiate a sort of love for programming, so let me ask, uh, do you think programming's more an art or a science? Is it creativity or kind of rigor?

    5. BK

      I think it's some of each and it's some combination. Um, some of the art is figuring out what it is that you really want to do, what should that program be, what, what would make a good program, and that's s- some understanding of what the, the task is, what the people who might use this program want, and I think that's, that's art, uh, in many respects. The science part is trying to figure out how to do it well, and some of that is, uh, real computer science-y stuff like what algorithm should we use at some point, mostly in the sense of being careful to use algorithms that will actually work properly, scale properly, avoiding quadratic algorithms when a linear algorithm should be the right thing, that kind of more formal view of it. Um, same thing for data structures. But also it's, I think, an engineering field as well, and engineering's not quite the same as science because engineering you're working with constraints. You have to, um, figure out not only to what is a good algorithm for this kind of thing, but what's the most appropriate algorithm given the amount of time we have to compute, the amount of time we have to program, what's likely to happen in the future with maintenance, who's gonna pick this up in the future, all of those kind of things that if you're an engineer you get to worry about, whereas if you think of yourself as a scientist, well, you can maybe push them over the horizon in a way. And if you're an artist, what's that?

    6. LF

      (laughs) So just on your own personal level, what's your process like of writing a program, say, a small and large sort of tinkering with stuff, uh, do you just start coding right away and just kind of evolve iteratively with a loose notion or do you plan on a sheet of paper first and then kind of design in a, in a what they teach you in the kind of, uh, software engineering courses in undergrad or something like that? What's your process like?

    7. BK

      Uh, it's certainly much more the informal incremental first. I don't write big programs at this point. Uh, it's been a long time since I wrote a program that was more than, I call it a few hundred or more lines, something like that. Many of the programs I write are experiments for, uh, either something I'm curious about or often for something that I want to talk about in a class, and so those necessarily tend to be relatively small. Um, a lot of the kind of code I write these days tends to be for sort of exploratory data analysis where I've got some collection of data and I want to try and figure out what on earth is going on in it, and for that those programs tend to be very small. Sometimes you're not even programming, you're just using existing tools like counting things, or sometimes you're writing AWK scripts because two or three lines will tell you something about a piece of data and then when it gets bigger, well, then I will probably write something in Python, um, because that scales better up to, call it a few hundred lines or something like that. And it's been a long time since I wrote programs that were much more than that.

  5. 35:1842:03

    AWK

    1. BK

    2. LF

      Speaking of data exploration and AWK, uh, first, what is AWK?

    3. BK

      So AWK is a scripting language that was done, um, by myself, Al Aho, and Peter Weinberger. Uh, we did that originally in the late '70s. It was a language that was meant to make it really easy to do quick and dirty, uh, tasks like counting things or selecting interesting, uh, information from basically all text files, rearranging it in some way or summarizing it.

    4. LF

      It runs a command on each line of a file. I mean, there's, um, it's still exceptionally widely used today.

    5. BK

      Oh, absolutely, yeah, it's, it's-

    6. LF

      And it's so simple and elegant, sort of the way to explore data turns out you can just write a script that does something seemingly trivial on a single line and that, uh, giving you that slice of the data somehow reveals something fundamental about the data.

    7. BK

      Yeah.

    8. LF

      And that keeps... (laughs) that, that seems to work still.

    9. BK

      Yeah, it's, it's, uh, very good for that kind of thing, you know, which, uh, that's sort of what it was meant for. I think what we didn't appreciate was that the model was actually quite good for, uh, a lot of data processing kinds of tasks, and that it's, it's kept going as long as it has, 'cause at this point it's over 40 years old and it's still-... I think a useful tool and it, well, this is paternal interest, I guess, but I think in terms of programming languages, you get the most bang for the buck by learning AWK. And it doesn't scale the big programs, but it does pretty, pretty darn well on these little things where you just want to see all the somethings in something. And so, yeah, I find, I probably write more AWK than anything else at this point. (laughs)

    10. LF

      (laughs) Uh, so what, what kind of stuff do you love about AWK? Like is there... He- if you can comment on sort of things, uh, that give you joy when you can in, in a simple program reveal something about the data. Is there something that stands out, some particular features?

    11. BK

      I think it's mostly the, the selection, the, of default behaviors, that you sort of hinted at it a moment ago. What AWK does is to read through a set of files and then within each file, it reads through a- each of the lines, and then on each of the lines, it has a set of patterns that it looks for, that's your AWK program. And if one of the patterns matches, there is a corresponding action that you might perform. And so it's kind of a quadruply nested loop or something like that.

    12. LF

      (laughs)

    13. BK

      Um, and that's all completely automatic. You don't have to say anything about it, you just write the pattern and the action and then run the data by it. And, and so that paradigm for programming is very natural and effective one. And I think we captured that reasonably well in AWK. And it does other things for free as well. It splits the data into fields, so that on each line there is fields separated by white space or something. And so it does that for free, you don't have to say anything about it. Um, and it collects information as it goes along, like what line are we on, how many fields are there on this line. So, lots of things that just make it so that a program which in another language, let's say Python, would be five, 10, 20 lines, in AWK it's one or two lines.

    14. LF

      And so because it's one or two lines, you can do it on the shell, like you don't have to open up another whole thing, you can just do it right there in the interaction with the, with the operating system-

    15. BK

      Yeah. Just type. Yeah.

    16. LF

      ... directly. Is there other shell commands that you love over the years, like you really enjoy using?

    17. BK

      Oh, grep.

    18. LF

      I mean, just gre- (laughs)

    19. BK

      Grep's the only one. (laughs)

    20. LF

      (laughs)

    21. BK

      Yeah, grep does everything. Uh-

    22. LF

      So grep is a kind of a, what is it? A simpler version of AWK I would say?

    23. BK

      In, in some, um, some sense yeah, right, because-

    24. LF

      What is grep?

    25. BK

      So grep is, it basically searches the input for particular patterns, regular expressions technically of a certain class. Um, and it has that same paradigm that AWK does, it's a pattern action thing, it reads through all the files and then all the lines in each file, but it has a single pattern which is the regular expression you're looking for, and a single action printed if it matches. So it's a, in that sense it's a much simpler version and you could write grep in AWK as, as a one-liner. Um, and I use grep probably more than anything else at this point, uh, just because it, it's so convenient and natural.

    26. LF

      Why do you think it's such a powerful tool, grep and AWK, why do you think operating systems like Windows, for example, don't have it? Sort of you can of course, I use the, the, which is amazing now, there's, uh, Windows for Linux, so, uh, like the, which you could basically use all the fun stuff like AWK and grep in- inside of Windows. But Windows naturally sort of in the, as part of the graphical interface, the simplicity of grep, sort of searching through a bunch of files and just popping up naturally. What, why don't you think that, why do you think that's unique to the Unix and, uh, Linux environment?

    27. BK

      I don't know and it's not strictly unique but it's certainly focused there and I think some of it's the weight of history, um, that Windows came from MS-DOS. MS-DOS was a pretty pathetic operating system, although common on an, you know, unboundedly large number of machines. But somewhere in roughly the '90s, uh, Windows became a graphical system and I think Microsoft spent an- uh, a lot of their energy on making that graphical interface what it is. Um, and that's a different model of computing and it's a model of computing that where you point and click and sort of experiment with menus, it's a model of computing works right, rather well for people who are not programmers, who just want to get something done. Whereas teaching something like the command line to non-programmers turns out to sometimes be an uphill struggle. And so I think Microsoft probably was right in what they did. Now, you mentioned WSL or whatever it's called, the Linux, Linux-

    28. LF

      WSL. I wonder how it's pronounced. W-S-L is what? I've never actually pronounced a WSL, I like it.

    29. BK

      I have no idea. (laughs)

    30. LF

      WSL.

  6. 42:0346:39

    Programming setup

    1. LF

      Okay, what's your perfect programming setup? What computer, what operating system, what keyboard, what editor?

    2. BK

      Yeah. Perfect is too strong a word. (laughs) It's way too strong a word. Um, what I use by default, I have a, uh, at this point a 13-inch MacBook Air which I use because it's kind of a reasonable balance of the various things I need, I can carry it around, it's got enough computing horsepower, screen's big enough, keyboard's okay. Um, and so I basically do most of my computing on that. Um, I have a big iMac in my office that I use from time to time as well, especially when I need a big screen, but otherwise tends not to be used that much. Um, uh...

    3. LF

      ... editor?

    4. BK

      I use mostly Sam, which is an editor that Rob Pike wrote long ago, uh, at Bell Labs, and, and-

    5. LF

      Did that, sorry to interrupt, does that precede VI? Does that precede EMAX?

    6. BK

      Uh, it posts, it postdates both VI and EMAX. Um, it is derived from Rob's experience with ED and VI. Um-

    7. LF

      What's ED?

    8. BK

      That's the original Unix editor. (laughs)

    9. LF

      Oh, wow. Um-

    10. BK

      Dated probably before you were born. (laughs)

    11. LF

      (laughs) So, uh, what's, uh, actually what's the history of editors? Can you, can you briefly... 'cause it's such a fac- I used EMAX, I'm sorry to say. So- sorry to come out with that. But, uh, what's, what's the kind of interplay there? So Sam and EMAX and VI?

    12. BK

      So, in an- so in ancient ti- ancient times, uh, like call it the first time sharing systems going back to what-

    13. LF

      Yeah.

    14. BK

      ... we were talking about, there were editors, there was an editor on CTSS that I don't even remember what it was called, although it might've been edit, um, where you could type text, program text and it would do something, or doc- document text.

    15. LF

      You could save the text?

    16. BK

      And save it. You could edit it, you know, the usual thing that you would get in an editor. Um, and Ken Thompson wrote an editor called QED, which, uh, was very, very powerful, but these were all totally a command based. They were not mouse or cursor based, because it was before mice and even before cursors, 'cause they were running on terminals that printed on paper.

    17. LF

      Mm-hmm.

    18. BK

      Okay? No, no CRT type displays, let alone LEDs. Um, and so then when Unix came along, Ken took QED and stripped it way, way, way, way down, and that became an editor that he called ED. And it was very simple, but it was a line-oriented editor. And so you, you could load a file, and then you could talk about the lines one through the last line, and you could, um, you know, print ranges of lines. You could add text, you could delete text, you could change text, or you could do a substitute command that would change things within a line or within groups of lines.

    19. LF

      So you could work on a parts of a file, essentially?

    20. BK

      Yeah, you could work on any part of it, the whole thing or whatever, but it was entirely command line based and it was-

    21. LF

      Oh.

    22. BK

      ... entirely on paper.

    23. LF

      Okay.

    24. BK

      Paper. And that meant that you changed-

    25. LF

      Actual paper.

    26. BK

      Yeah, right, real paper. And so if you changed a line, you had to print that line using up another line of paper to see what the change caused, okay?

    27. LF

      (laughs) Yeah. That's amazing.

    28. BK

      So when, when CRT displays came along-

    29. LF

      Yeah.

    30. BK

      ... then, uh, you could start to use cursor control and you could sort of move where you were on the screen in, um-

  7. 46:3952:48

    History of programming languages

    1. LF

      can you take on the impossible task and give a brief history of programming languages from your perspective?

    2. BK

      So, I guess you could say programming languages started probably in, what, the late '40s or something like that. People used to program computers by basically putting in zeros and ones, using something like switches on a console. Uh, and then, uh, or maybe holes in paper tapes, something like that. So extremely tedious, awful, whatever. And so I think the first programming languages were, uh, relatively crude assembly languages, where people would basically write a program that would convert mnemonics like add, A-D-D, into whatever the bit pattern was that corresponded to an add instruction, and they would do the clerical work of figuring out where things were, so you could put a name on a location in a program and the assembler would figure out where that corresponded to when the thing was all put together and dropped into memory. Um, and they w- m- early on, and this would be the late '40s, uh, and very early '50s, there were assemblers written for the various machines that people used. You may have seen in the paper just a couple of days ago Tony Burkard died. He did this thing in Manchester called the, called Autocode, a language which I knew only by name. Um, but it sounds like it was a flavor of assembly language, sort of a little higher in some ways. Um, and it replaced a language that Alan Turing wrote, which you put in zeros and ones, but you put them in backwards order because that was how the hardware worked. Very strange.

    3. LF

      That's right.

    4. BK

      (laughs)

    5. LF

      Yeah, yeah. That's right, it's backwards.

    6. BK

      So assembly languages then, let's call that the early 1950s. And so every different flavor of computer has its own assembly language. So the EDSAC had its, and the Manchester had its, and the IBM whatever, 70-90 or 704 or whatever had its, and, and so on. So everybody had their own assembly language.

    7. LF

      And assembly languages have a few commands, addition, subtraction, and branching of some kind, if then type of situation.

    8. BK

      Right. They have exactly, in their simplest form at least, one instruction per, or one, uh, assembly language instruction per instruction in the machine's repertoire.

    9. LF

      Right.

    10. BK

      ... and so you have to know the machine intimately to be able to write programs in it. And if you write an assembly language program for one kind of machine, and then you say, "Geez, it's nice. I'd like it in a different machine," start over.

    11. LF

      (laughs)

    12. BK

      Okay.

    13. LF

      Yeah.

    14. BK

      So very bad. And so what happened in the late '50s was people realized you could play this game again and you could move up a level in writing or creating languages that were closer to the way that real people might think about how to write code. Um, and there were, I guess, arguably three or four at that time period. There was Fortran, which came from IBM, which was formula translation, meant to make it easy to do scientific and engineering computations.

    15. LF

      I didn't know that. Formula translation, that's wow.

    16. BK

      That's what it stood for.

    17. LF

      Yeah.

    18. BK

      And there was COBOL, which is the common business-oriented language that, uh, Grace Hopper and others worked on, uh, which was aimed at business kinds of tasks. Uh, there was ALGOL, which was mostly meant to describe algorithmic computations. Um, I guess you could argue Basic was in there somewhere. I think it's just a little later. Um, and so all of those moved a level up, and so they were closer to what you and I might think of as we were trying to write a program, and they were focused on different domains. Fortran for formula translation, engineering computations, let's say, COBOL for business, that kind of thing.

    19. LF

      Mm. Still used today, at least Fortran-

    20. BK

      Still used today.

    21. LF

      ... probably.

    22. BK

      Oh, yeah. COBOL too.

    23. LF

      COBOL.

    24. BK

      But the deal was that once you moved up that level, then you... let's call it Fortran, you had a language that was not tied to a particular kind of hardware because a different compiler would compile for a different kinda hardware, and that meant two things. It meant you only had to write the program once, which was very important, and it meant that you could in fact, if you were a random engineer, physicist, whatever, you could write that program yourself. You didn't have to hire a programmer to do it for you. Might not be as good as you'd get with a real programmer, but it was pretty good, and so it democratized and made much more broadly available the ability to write code.

    25. LF

      So it puts the power of programming into the hands of people like you?

    26. BK

      Yeah. Anybody who wants t- who u- who under- is willing to invest some time in learning a programming language and is not then tied to a particular kind of computer, and then in the '70s you get system programming languages of which C is the survivor, and-

    27. LF

      What, what, what does system programming languages mean?

    28. BK

      Lang- programs that... Programming languages that would take on the kinds of things that were necessary to write so-called system programs, things like text editors or assemblers or compilers or operating systems themselves, those kinds of things. And s- uh, Fortran-

    29. LF

      They have to be feature-rich. They have to be able to do a lot of stuff, a lot of memory management, uh, the access processes, all that kind of stuff-

    30. BK

      They have to-

  8. 52:4858:44

    C programming language

    1. BK

    2. LF

      So what's, to you... so you wrote a book, The C Programming Language, what... and C is probably one of the most important languages in the history of programming languages if, if you kind of look at impact. W- what do you think is the most elegant or powerful part of C? Why did it survive? Why did it have such a long-lasting impact?

    3. BK

      I think it found a sweet spot that... in... of expressiveness, that you could rewrite things in a pretty natural way, and efficiency, which was particularly important when computers were not nearly as powerful as they are today, you know, put yourself back 50 years, uh, almost in terms of what computers could do and that's, you know, roughly four or five generations, uh, decades of Moore's Law, right? Um, so expressiveness and efficiency and, I don't know, perhaps the environment that it came with as well, which was Unix, so that meant if you wrote a program, it could be used on all those computers that ran Unix and that was all of those computers because they were all written in C and that way it was Unix the operating system itself was portable as were all the tools. So it all worked together, a- again, in one of these things where things fed on each other in a positive cycle.

    4. LF

      What did it take to write sort of a definitive book, probably a definitive book on all of programming, like, it's more definitive to a particular language than any other book on any other language, and did two really powerful things which is popularized the language, at least from my perspective, maybe you can correct me, and second is created a standard of how, you know, the, the, how this language is supposed to be used and applied. So what did it take? Did you have those kinds of ambitions in mind when working on that?

    5. BK

      Is this some kind of joke?

    6. LF

      (laughs)

    7. BK

      (laughs) No, of course not. Um... (clears throat)

    8. LF

      So it's an acc- it's an accident of, uh, of timing, skill, and just luck?

    9. BK

      A lot of it is, uh, uh, clearly. Uh, timing was good. Uh, Dennis and I wrote the book in 1977, uh-

    10. LF

      Dennis Ritchie.

    11. BK

      Yeah, right. Um, and at that point, Unix was starting to spread. I don't know how many there were but it would be dozens to hundreds of Unix systems, um, and C was also available on other kinds of computers that had nothing to do with Unix, and so the language had some potential. Um-And there were no other books on C, uh, and Bell Labs was really the only source for it, and Dennis, of course, was authoritative because it was his language, and he had written the, uh, reference manual, which is a marvelous example of how to write a reference manual. Really, really very, very well done. So I twisted his arm until he agreed to write a book, and then we wrote a book. And the virtue or advantage at least, I guess, of going first is that then, uh, other people have to follow you if they're gonna do anything. (laughs) Um, and I think it worked well because Dennis was a superb writer. I mean, he really, really did, and the, the reference manual in that book is his, period. I had nothing to do with that at all. Um, so just crystal clear prose and very, very well expressed. Um, and then he and I... I, I wrote most of the expository material, and then he and I sort of did the usual ping-ponging back and forth, um, you know, refining it. But I spent a lot of time trying to find examples that would sort of hang together and that would tell people what they might need to know at about the right time that they should be thinking about needing it. Um, and I'm not sure it completely succeeded, but it mostly worked out fairly well.

    12. LF

      What do you think is the power of example? I mean, you're, you're the creator, uh, at least one of the first people to do the Hello World program-

    13. BK

      (laughs)

    14. LF

      ... (laughs) which is like the example. If, if aliens discover our civilization hundreds of years from now, it'll probably be-

    15. BK

      (laughs)

    16. LF

      ... Hello World programs, just like a, a half-broken robot communicating with them with a Hello World. So what... And that's a representative example, so what, what do you find powerful about examples?

    17. BK

      Uh, I think a good example will tell you how to do something, and it will be representative of, of you might not want to do exactly that, but you will want to do something that's at least in that same general vein. Um, and so a lot of the examples in the C book were picked for these very, very simple, straightforward text processing problems that were typical of Unix. I want to read input and write it out again. There's a copy command. I wanna read input and do something to it and write it out again. There's a grab. And so that kind of find things that are representative of what people want to do and spell those out so that they can then take those and see the, the core parts and modify them to their taste. And I think that a lot of programming books that I... I, I don't look at programming books a tremendous amount these days, but when I do, a lot of them don't do that. They don't give you examples that are both realistic and something you might want to do. Some of them are pure syntax. Here's how you add three numbers. Well, come on, I could figure that out. Tell me how I would get those three numbers into the computer and how I would do something useful with them and then how I put them back out again, neatly formatted.

    18. LF

      And especially if you follow that example, there is something magical of doing something that feels useful.

    19. BK

      Yeah, right? And I think it's the attempt, and it, it's absolutely not perfect, uh, but the attempt in all cases was to get something that was going to be either directly useful or would be very representative of useful things that a programmer might want to do. But within that vein of fundamentally text processing, reading text, doing something, writing text.

  9. 58:441:01:57

    Go language

    1. BK

    2. LF

      So you've also written a book on, uh, Go language. Uh, I'd have to admit, so I worked at Google for a while, and I've never used Go.

    3. BK

      Well, you missed something. (laughs)

    4. LF

      Oh, I know I missed something, for sure. I mean, and so Go and Rust are two languages that I hear very, uh, spoken very highly of, and I wish... I would like to try. Well, there's a lot of them. There's Julia, there's, there's all these incredible-

    5. BK

      (laughs)

    6. LF

      ... modern languages. But i- if you can comment, before... Or maybe comment on what do you find... Where does Go sit in, in this broad spectrum of languages, and also how do you yourself feel about this wide range of powerful, interesting languages that you might never even get to try to explore-

    7. BK

      Yeah.

    8. LF

      ... just because of time?

    9. BK

      So I, I think... So Go, um... Go first comes from that same Bell Labs tradition in part, not exclusively, but two of the three creators, Ken Thompson and Rob Pike-

    10. LF

      Oh, so literally the people-

    11. BK

      Yeah, the people.

    12. LF

      Yeah.

    13. BK

      Um, and then with this very, very useful, uh, influence from the European school, uh, in particular, uh, the Claus Firth influence, uh, through Robert Griesemer, um, who was, I guess, a second generation down student r- uh, at ETH. Um, and so that's an interesting combination of things. And so some ways, uh, Go captures the good parts of C. It looks sort of like C, it's sometimes characterized as C for the 21st century.

    14. LF

      Mm-hmm.

    15. BK

      Um, on the surface, it looks very, very much like C, but at the same time, it has some interesting, uh, data structuring capabilities, and then I think the part that I would say is particularly useful, and again, I'm not a Go expert, um, in spite of co-authoring the book. About 90% of the work was done by Alan Donovan, my co-author, who is a Go expert. Um, but Go provides a very nice model of concurrency. It's basically the cooperating, uh, communicating sequential processes that Tony Hoare-

    16. LF

      (laughs)

    17. BK

      ... uh, set forth, geez, I don't know, 40-plus years ago.

    18. LF

      (laughs)

    19. BK

      Um, and Go routines are, to my mind, a very natural way to talk about, um, parallel computation, and in the few experiments I've done with them, they're easy to write, and typically it's gonna work and very efficient as well. So I think that's one place where Go stands out at that model of, of parallel computation, uh, is very, very easy and nice.... to, to work with.

    20. LF

      J- just to comment on that, do you think C foresaw, or the early Unixes foresaw, uh, threads and massively parallel computation?

    21. BK

      I would guess not really. I mean, maybe it was seen, but not at the level where it was something you had to do anything about. Um, for a long time, processors got faster, and then processors stopped getting faster because of things like power consumption and heat generation. And so what happened instead was that instead of processors getting faster, there started to be more of them. And that's where that parallel thread stuff comes in.

    22. LF

      (laughs)

  10. 1:01:571:04:57

    Learning new programming languages

    1. LF

      So if you can comment on the, all the other languages-

    2. BK

      (laughs)

    3. LF

      ... does it, uh, break your heart that you'll never get to explore them? Or s- how do you feel about all-

    4. BK

      Uh-

    5. LF

      ... the full variety?

    6. BK

      It, it's not breaking my heart, but it, but it, I would love to be able to try more of these languages. The closest I've come is in a class that I often teach in the spring here, um, it's a programming class-

    7. LF

      Mm-hmm.

    8. BK

      ... uh, and I often give... I, I have one sort of small example that I will write in as many languages as I possibly can. I've got it in 20-odd languages at this point. And, um, and that's... So I do a minimal experiment with a language just to say, "Okay, I have this trivial task, which I understand the task, and it should... it takes 15 lines in AWK and not much more in a variety of other languages. So how big is it? How fast does it run? And what pain did I go through to learn how to do it?" Um, and that's a... f- it's like anecdata, right? It's very, very, very narrowly focused.

    9. LF

      Anecdata (laughs) , I like that term. So yeah, but still, it's a little sample 'cause you get to... I think the hardest step of the programming language is probably the first step, right?

    10. BK

      Yeah.

    11. LF

      So there you're taking the first step.

    12. BK

      Yeah. And so my experience, um, with some languages is very positive. Like Lua, a scripting language I had n- never used, um, and I took my pro- little program... The program is a, a trivial formatter. It just takes in lines of text of, of varying lengths and it puts 'em out in lines that have no more than 60 characters on each line. So think of it as just-

    13. LF

      Yeah.

    14. BK

      ... kind of the flow, uh, process in a browser or something. Um, so it's, it's very short program. And, um, in Lua, I downloaded Lua, and in an hour I had it working, never having written Lua in my life-

    15. LF

      (laughs)

    16. BK

      ... just going with online documentation. I did the same thing in Scala, which you can think of as a flavor of Java, equally trivial. Um, I did it in Haskell, it took me several weeks.

    17. LF

      (laughs)

    18. BK

      (laughs) But it did run like a turtle. Um, and-

    19. LF

      (laughs)

    20. BK

      ... and I, I did it in Fortran 90, and it-

    21. LF

      Wow.

    22. BK

      ... painful, but it worked.

    23. LF

      Yeah.

    24. BK

      And I tried it in Rust, and it took me several days to get it working because the model of memory management was just a little unfamiliar to me. And the problem I had with Rust, and it's back to what we were just talking about, I couldn't find good consistent documentation on Rust. Now, this was several years ago, and I'm sure things have stabilized, but at the time, everything in the Rust world seemed to be changing rapidly. And so you would find what looked like a working example, and it wouldn't work with the version of the language that I had. So it took longer than it should have. Um, Rust is a language I would like to get back to, but probably won't. I think one of the issues, you have to have something you want to do. And if you don't have-

    25. LF

      Yeah.

    26. BK

      ... something that is the right combination of, "I want to do it and yet I have enough disposable time," whatever, "to make it worth learning a new language at the same time," it's never gonna

  11. 1:04:571:08:16

    Javascript

    1. BK

      happen.

    2. LF

      So what do you think about another language of JavaScript that's... This... Uh, well, let me just sort of comment on what...

    3. NA

      (laughs)

    4. LF

      Because when I was brought up, sort of JavaScript was seen as, uh, the (laughs) probably, like, the ugliest language possible.

    5. BK

      (clears throat)

    6. LF

      And yet it's quite arguably, quite possibly taking over not just the front end and the back end of the internet, but possibly in the future taking over everything because they've now learned to make it very efficient.

    7. BK

      Yeah.

    8. LF

      And, and so what do you think about this? (laughs)

    9. BK

      Yeah. Well, I think you captured it in a lot of ways. When it first came out, JavaScript was deemed to be fairly irregular and an ugly language. And certainly in the academy, if you said you were working on JavaScript, people would ridicule you.

    10. LF

      Yeah.

    11. BK

      It was just not fit for academics to work on. Um, I think a lot of that has evolved. The language itself has evolved, and, uh, certainly the technology of compiling it is fantastically better than it was. Um, and so in that sense, it's a, a- absolutely a viable solution f- on back ends as well as the front ends. Um, used well, I think it's a pretty good language. I've written a modest amount of it, and I've played with JavaScript translators and things like that. I'm not a real expert, and it's hard to keep up even there with the new things that come along with it. Um, so I don't know whether it will ever take over the world. I think not, but, uh, it, it's certainly an important language and-

    12. LF

      So-

    13. BK

      ... worth knowing more about.

    14. LF

      ... there's, uh, there's... Maybe to get a, your comment on something, which JavaScript-

    15. BK

      (laughs)

    16. LF

      ... and actually most languages, uh, sort of Python, such a big part of the experience of programming with those languages includes libraries. Sort of using, building on top of the code that other people have built. I think that's probably different from the experience that we just talked about from Unix and C days when you're building stuff from scratch. What do you think about this world of essentially leveraging, building up libraries on top of each other and leveraging them?

    17. BK

      Yeah. No, that's a very perceptive kind of, uh, question. One of the reasons programming was fun in the old days was that you were really building it all yourself.

    18. LF

      Yeah.

    19. BK

      The, the number of libraries you had to deal with was quite small. Maybe it was printf or the standard library or something like that.Um, and that is not the case today and if you wanna do something in, you mentioned Python and JavaScript, and those are the two fine examples, you have to typically download a boatload of other stuff and you have no idea what you're getting. Absolutely nothing.

    20. LF

      Yeah.

    21. BK

      I've been doing some playing with machine learning over the last couple of days and, geez, something doesn't work. Well, you PIP install this, okay? And down comes another gazillion megabytes of something and you have no idea what it was and if you're lucky, it works. And if it doesn't work? You have no recourse. There's absolutely no way you could figure out which in these thousand different packages. And I think it's worse in the MPN- NPM environment for JavaScript. I think there's less discipline, less control there.

    22. LF

      And there's aspects of, uh, not just not understanding how it works but there's security issues, there's robustness issues, so you don't wanna run a nuclear power plant using JavaScript essentially.

    23. BK

      Uh, probably not. (laughs)

    24. LF

      (laughs)

  12. 1:08:161:10:30

    Variety of programming languages

    1. LF

      So speaking to the variety of languages, do you think that variety is good or do you hope, think that over time we should converge towards one, two, three programming languages? That y- you mentioned to the Bell Lab days when people could sort of, the community of it, and the more languages you have, the more you separate the communities. There's the Ruby community, there's the Python community, there's C++ community. Do you hope that they, they'll unite one day to just one or two languages?

    2. BK

      I certainly don't hope it, I'm not sure that that's right 'cause I honestly don't think there is one language that will suffice for all the programming needs of the world. Are there too many at this point? Well, arguably. Um, but I think if you look at the, the sort of, the distribution of how they are used, there's (clears throat) , something, call it a dozen languages that probably account for 95% of all programming at this point.

    3. LF

      Mm-hmm.

    4. BK

      And that doesn't seem unreasonable. Uh, and then there's another, well, 2,000 languages that are still in use that nobody uses and, or at least don't use in any quantity. But I think new languages are a good idea in many respects 'cause they're often a chance (clears throat) to explore an idea of how a language might help. I think that's one of the, um, positive things about functional languages. For example, they're a particularly good place where people have explored ideas that at the time (clears throat) didn't seem feasible but ultimately have wound up as part of mainstream languages as well. I mean, just go back as early as Recursion and Lisp and then follow forward, functions as first class citizens and pattern-based languages and, gee, I don't know, uh, closures and just on and on and on. Lambdas. Interesting ideas that showed up first in, let's call it broadly the functional programming community, and then find their way into mainstream languages.

    5. LF

      Yeah, it's a, it's a playground for rebels.

    6. BK

      Yeah, exactly.

    7. LF

      (laughs) So...

    8. BK

      And, and, and so I think the languages in the playground themselves are probably not going to be the mainstream-

    9. LF

      Right.

    10. BK

      ... at least for some while, but the ideas that come from there are invaluable.

  13. 1:10:301:18:01

    AMPL

    1. BK

    2. LF

      So let's go to something that, wh- when I found out recently, so I- I've known that you've done a million things but one of the things I wasn't aware of that you had a role in AMPL and I... Before you interrupt me by minimizing your role in it (laughs) , would you-

    3. BK

      AMPL is for Minimizing Functions.

    4. LF

      Yeah, Minimizing Functions, right, exactly (laughs) . Um, I, I, can I just say that the elegance and abstraction power of A- AMPL is incredible when I, when I first came to, to it about 10 years ago or so. Uh, can you describe what is the AMPL language?

    5. BK

      Sure. So AMPL is a language for mathematical programming, uh, technical term, uh, think of it as linear programming, that is setting up systems of linear, um, equations that are, uh, of some sort of system of constraints so that you have a bunch of things that have to be less than this, greater than that, whatever, and you're trying to find a set of values for some decision variables that will maximize or minimize some objective function. So it's, it's a way of solving a particular kind of optimization problem, a very formal sort of optimization problem, but one that's exceptionally useful.

    6. LF

      Yep.

    7. BK

      Yeah.

    8. LF

      And it specifies, so there's objective function constraints and variables that becomes separate from the data it operates on.

    9. BK

      Right.

    10. LF

      So the, that kind of separation allows you to, uh, you know, put on different hats. One, put the hat of an optimization person and then put a, another hat of a data person and dance back and forth and, and also separate the actual, uh, solvers, the optimization systems that do the solving, that you can have other people come to the table and then build their solvers whether it's linear or nonlinear, uh, convex, non-convex, that kind of stuff. So, uh, what is the, do you use... May- maybe you can comment how you got into that world and what is a beautiful or interesting idea to you from the world of optimization?

    11. BK

      Sure. So I preface it by saying I'm absolutely not an expert on this and most of the, uh, important work in AMPL comes from my two partners in crime on that, Bob Fourer who, uh, was a professor of, in, in the Industrial Engineering and Management Science Department at Northwestern and my colleague at, uh, Bell Labs, Dave Gay who was a numerical analyst, uh, and optimization person. So the deal is linear programming (laughs) , preface this by saying... (laughs)

    12. LF

      Let's stay with linear programming.

    13. BK

      Yeah, linear programming is the simplest example of this. So linear programming as it's taught in school is that you have a big matrix which is always called A and you say AX is less than or equal to B, so B is a set of constraints, X is the decision variables and A is the, how the decision vari-... pulls our combined to set up the various constraints. So A is a matrix, and X and B are vectors. Um, and then there's an objective function, which is just the sum of a bunch of Xs and some coefficients on them, and you, that's the thing you want to optimize. Um, the problem is that in the real world, that, that matrix A is a very, very, very intricate, very large, and very sparse matrix, where the various components of the model are distributed among the coefficients in a way that is totally unobvious to anybody. Um, and so what you need is some way to express the original model, which you and I would write. You know, we'd write mathematics on the board. You know, the sum of this is greater than the sum of that, kind of thing. So, um, you need a language to write those kinds of constraints. And Bob Fourer, for a long time, had been interested in modeling languages, languages that made it possible to do this. There was a, a modeling language around called GAMS, the General Algebraic Modeling System, but it looked very much like Fortran. It was kinda clunky. Um, and so Bob spent a sabbatical year at Bell Labs in 1984, and, uh, he ... And he was living in the office across from me, and, uh, it's always geography. And, uh, he and Dave Gay and I started talking about this kind of thing, and, um, he wanted to design a language that would make it so that you could take these algebraic specifications, you know, summation signs over sets, and that you would write on the board and convert them into basically this A matrix, and then pass that off to a solver, which is an entirely separate thing. And so we, uh, talked about the design of the language. I don't remember any of the details of this now, but it's kind of an obvious thing. You're just writing out mathematical expressions in a Fortran-like, or a, a, sorry, an algebraic but textual-like language. Um, and, um, I wrote the first version of this AMPL program, uh, my first C++ program.

    14. LF

      (laughs)

    15. BK

      And, uh-

    16. LF

      It's written in C++?

    17. BK

      Yeah.

    18. LF

      AMPL. Oh, wow.

    19. BK

      And so I did that fairly quickly. We wrote ... It was w- you know, 3,000 lines or something, so it wasn't very big. But it, it sort of showed the feasibility of it, that you could actually do something that was easy for people to specify p- models and convert it into something that a solver could work with. And at the same time, as you say, the model and the data are separate things. So one model would then work with all kinds of different data in the same way that lots of programs do the same thing but with different data.

    20. LF

      So one of the really nice things is the, the specification of the models, human, um, just kind of like as you say, it's human-readable. Like I, I could literally... I remember on stuff I worked, I, I would send it to colleagues that I'm pretty sure never programmed (laughs) in their life, just, just to, uh, understand what the optimization problem is.

    21. BK

      Mm-hmm.

    22. LF

      I think, uh, how hard is it to convert that? You said you, there's a first prototype in C++ to convert that into something that could actually be used by the solver.

    23. BK

      It's not too bad because most of the solvers have some mechanism that lets them import a model in a form. It might be as simple as the matrix itself in just some representation, or if you're doing things that are not linear programming, then there may be some mechanism that lets you provide things like functions to be called, so, or other constraints on the model. So, uh, so all AMPL does is to generate that kind of thing, and then the solver deals with all the hard work, and then when the solver comes back with numbers, AMPL converts those back into your original form so you know how much of each thing you should be buying or making or shipping or whatever. Um, so we did that in '84, and I haven't had a lot to do with it since, except that we wrote a couple of versions of a book on it.

    24. LF

      Which is one of the greatest books ever written. I love that book.

    25. BK

      (laughs)

    26. LF

      Uh, I don't know why.

    27. BK

      It's an excellent book. Bob Fourer wrote most of it, and so it's really, really well done. He must have been a dynamite teacher.

    28. LF

      And typeset in LaTeX.

    29. BK

      No, no, no, are you kidding? (laughs)

    30. LF

      (laughs) I remember liking the typography, so I don't know-

  14. 1:18:011:22:20

    Graph theory

    1. BK

    2. LF

      ... the typography. Outside of Unix, C, Awk, Golang, all the things we talked about, uh, all the amazing work you've done, you've also done work in graph theory. Uh, let, let me ask this, this crazy, out there question. Uh, if you had to make a bet, and I had to force you to make a bet, do you think P equals NP?

    3. BK

      (laughs) Uh, the answer is no, although I, I am told that somebody asked, uh, Jeff Dean if that was the k- under what conditions P would equal NP, and he said, "Either P is zero or N is one." (laughs)

    4. LF

      (laughs)

    5. BK

      Or vice versa, I've forgotten, is what-

    6. LF

      If P is zero, N is one.

    7. BK

      ... Jeff Dean is a lot smarter than I am. (laughs)

    8. LF

      Yeah. (laughs) Uh, so but your intuition is, uh, a little bit on the matter of difference.

    9. BK

      I, I have no i- I have no intuition, but I've got a lot of colleagues who've got intuition, and their betting is no. (laughs)

    10. LF

      That's the popular, that's the popular bet. Okay, so w- what is computational complexity theory, and do you think these kinds of complexity classes, especially as you've taught in this, this modern world, are still useful way to understand the hardness of problems?

    11. BK

      I don't do that stuff. The last time I touched anything to do with that was be-

    12. LF

      Many, many years ago.

    13. BK

      ... was before it was invented.

    14. LF

      (laughs)

    15. BK

      'Cause I ... (laughs) It's literally true. I did my PhD thesis on graph-

    16. LF

      Before big O notation.

    17. BK

      Oh, absolutely. Before ... I, I did this in 1968, um, and I worked on graph partitioning, which is this question ... If you've got a graph, uh, that is a nodes and edges kind of graph-... and the edges have weights. And you just want to divide the nodes into two piles of equal size, so that the number of edges that goes from one side to the other is as small as possible. (inhales deeply) And...

    18. LF

      We, we developed... So that problem is hard?

    19. BK

      Well, as it turns out, I worked with Shan Lin at Bell Labs on this, and we were never able to come up with anything that was guaranteed to give the right answer. We came up with heuristics that worked pretty darn well, and I peeled off some special cases for my thesis, but it was just hard.

    20. LF

      Mm-hmm.

    21. BK

      And that was just about the time that Steve Cook was showing that there were classes of problems that appeared to be really hard, of which graph partitioning was one. (laughs) But this... My expertise, (laughs) such as it was, totally predates that development. Oh, it's-

    22. LF

      Oh, interesting. So the, the heuristic, which now, (laughs) uh, your... Uh, cares the two of yours names for the tr- traveling salesman problem and for the graph partitioning, that was... Like, how did you... You weren't even thinking in terms of classes, you were just trying to find-

    23. BK

      There was no such idea.

    24. LF

      ... a heuristic that kind of does the job pretty well.

    25. BK

      You're trying to find a, something that did the job, and there was no- nothing that you would call, let's say, a closed form or algorithmic thing that would give you a guaranteed right answer. I mean, compare graph partitioning to, uh, max flow min-cut or something like that, bec- that's the same problem, except there's no constraint on the number of nodes on one side or the other of the cut.

    26. LF

      Right.

    27. BK

      And that means it's an easy problem, at least as I understand it. Whereas the constraint that says the two have to be constrained in size makes it a hard problem. (inhales deeply)

    28. LF

      Yeah, so the Robert Frost has that poem where you have to choo- choose two paths. So wha- why did you... (laughs) Uh, is there another alternate universe in which you pursued the Don Knuth path of, you know, algorithm design, sort of-

    29. BK

      Not smart enough. (laughs)

    30. LF

      (laughs) Not smart enough. Wha- uh... (laughs) Uh, you're infinitely, uh, modest. But so you, you pursued your kind of love of programming. I mean, when you look back to those... I mean, just looking into that world, does that just seem like a distant world of, of theoretical computer science? Then is it fundamentally different from the world of programming?

Episode duration: 1:43:09

Install uListen for AI-powered chat & search across the full episode — Get Full Transcript

Transcript of episode O9upVbGSBFo

Get more out of YouTube videos.

High quality summaries for YouTube videos. Accurate transcripts to search & find moments. Powered by ChatGPT & Claude AI.

Add to Chrome