Brian Kernighan: UNIX, C, AWK, AMPL, and Go Programming
技术与编程AI 与机器学习音乐与艺术心理与人性历史与文明
📋 章节目录
暂无章节信息
🔑 关键词
donlanguageprogramminglanguagesunixprogramdatacomputerscomputingstufflabsusedbellprogramsdonemachinegoingbookoperatinginteresting
💬 精彩语录
暂无语录
🎙️ 完整对话(2368 条)
Lex Fridman (00:00.000)
The following is a conversation with Brian Kernighan,
以下是与 Brian Kernighan 的对话,
Lex Fridman (00:03.320)
a professor of computer science at Princeton University.
普林斯顿大学计算机科学教授。
Lex Fridman (00:07.560)
He was a key figure in the computer science community
他是计算机科学界的关键人物
Lex Fridman (00:10.140)
in the early Unix days, alongside Unix creators,
在早期的 Unix 时代,与 Unix 的创造者一起,
Lex Fridman (00:13.760)
Ken Thompson and Dennis Ritchie.
肯·汤普森和丹尼斯·里奇。
Brian Kernighan (00:16.240)
He coauthored the C programming language with Dennis Ritchie,
他与 Dennis Ritchie 共同创作了 C 编程语言,
Lex Fridman (00:20.080)
the creator of C, and has written a lot of books
Brian Kernighan (00:23.520)
on programming, computers, and life,
关于编程、计算机和生活,
Lex Fridman (00:26.280)
including The Practice of Programming,
包括编程实践,
Brian Kernighan (00:28.480)
the Go programming language, and his latest,
Go 编程语言,以及他的最新成果,
Lex Fridman (00:31.200)
Unix, A History and a Memoir.
Unix,一段历史和一本回忆录。
Brian Kernighan (00:34.080)
He cocreated AUK, the text processing language
他共同创建了文本处理语言 AUK
Lex Fridman (00:36.920)
used by Linux folks like myself.
像我这样的 Linux 人都在使用。
Brian Kernighan (00:39.500)
He co designed Ample, an algebraic modeling language
他共同设计了 Ample,一种代数建模语言
Lex Fridman (00:43.800)
that I personally love and have used a lot in my life
我个人很喜欢并且在生活中经常使用它
Brian Kernighan (00:47.560)
for large scale optimization.
用于大规模优化。
Lex Fridman (00:49.580)
I think I can keep going for a long time
我想我可以继续走很长一段时间
Brian Kernighan (00:51.680)
with his creations and accomplishments,
凭借他的创作和成就,
Lex Fridman (00:54.240)
which is funny because given all that,
这很有趣,因为考虑到这一切,
Brian Kernighan (00:56.600)
he's one of the most humble and kind people
他是最谦虚和善良的人之一
Lex Fridman (00:59.160)
I've spoken to on this podcast.
Brian Kernighan (01:01.780)
Quick summary of the ads, two new sponsors,
Lex Fridman (01:04.880)
the amazing self cooling 8sleep mattress
Lex Fridman (01:10.560)
and Raycon earbuds.
Lex Fridman (01:13.260)
Please consider supporting the podcast
Brian Kernighan (01:15.420)
by going to 8sleep.com slash Lex
Lex Fridman (01:19.040)
and going to buyraycon.com slash Lex.
Brian Kernighan (01:23.040)
Click the links, buy the stuff.
Lex Fridman (01:25.200)
It really is the best way to support this podcast
Lex Fridman (01:27.680)
and the journey I'm on.
Lex Fridman (01:29.640)
If you enjoy this thing, subscribe on YouTube,
Brian Kernighan (01:32.000)
review it with 5,000 Apple podcasts,
Lex Fridman (01:34.200)
support it on Patreon,
Brian Kernighan (01:35.560)
or connect with me on Twitter at Lex Friedman.
Lex Fridman (01:39.680)
As usual, I'll do a few minutes of ads now
Lex Fridman (01:41.960)
and never any ads in the middle
Lex Fridman (01:43.300)
that could break the flow of the conversation.
Brian Kernighan (01:45.880)
This show is sponsored by 8sleep
Lex Fridman (01:49.240)
and it's incredible pod pro mattress
Brian Kernighan (01:51.880)
that you can check out at 8sleep.com slash Lex
Lex Fridman (01:54.720)
to get $200 off.
Brian Kernighan (01:57.360)
The mattress controls temperature with an app
Lex Fridman (02:00.720)
and can cool down to as low as 55 degrees.
Brian Kernighan (02:03.840)
Research shows that temperature has a big impact
Lex Fridman (02:07.000)
on the quality of our sleep.
Brian Kernighan (02:09.040)
Anecdotally, it's been a game changer for me.
Lex Fridman (02:11.280)
I love it.
Brian Kernighan (02:12.280)
The pod pro is packed with sensors
Lex Fridman (02:14.320)
that track heart rate, heart rate variability,
Lex Fridman (02:17.140)
and respiratory rate,
Lex Fridman (02:18.640)
showing it all on their app once you wake up.
Brian Kernighan (02:21.440)
Plus, if you have a partner,
Lex Fridman (02:23.540)
you can control the temperature of each side of the bed.
Brian Kernighan (02:26.600)
I don't happen to have one,
Lex Fridman (02:28.260)
but the 8sleep app reminds me
Brian Kernighan (02:30.080)
that I should probably get on that.
Lex Fridman (02:32.040)
So ladies, if a temperature controlled mattress
Brian Kernighan (02:34.860)
isn't a good reason to apply,
Lex Fridman (02:36.760)
I don't know what is.
Brian Kernighan (02:38.920)
The app's health metrics are amazing,
Lex Fridman (02:41.160)
but the cooling alone is honestly worth the money.
Brian Kernighan (02:44.480)
As some of you know, I don't always sleep,
Lex Fridman (02:47.280)
but when I do, I choose the 8sleep pod pro mattress.
Brian Kernighan (02:51.700)
Check it out at 8sleep.com slash Lex
Lex Fridman (02:54.680)
to get $200 off.
Brian Kernighan (02:57.520)
This show is also sponsored by Raycon earbuds.
Lex Fridman (03:01.620)
Get them at buyraycon.com slash lex.
Brian Kernighan (03:06.040)
They've quickly become my main method
Lex Fridman (03:07.760)
of listening to podcasts, audio books,
Lex Fridman (03:09.680)
and music when I run,
Lex Fridman (03:11.600)
do the pushups and pullups
Brian Kernighan (03:13.960)
that I've begun to hate at this point,
Lex Fridman (03:15.940)
or just living life.
Brian Kernighan (03:17.560)
In fact, I often listen to brown noise with these
Lex Fridman (03:20.320)
when I'm thinking deeply about something.
Brian Kernighan (03:22.320)
It helps me focus the mind.
Lex Fridman (03:24.320)
They're super comfortable, pair easily,
Brian Kernighan (03:26.500)
great sound, great bass, six hours of playtime.
Lex Fridman (03:30.200)
In fact, for fun, I have one of the earbuds in now
Lex Fridman (03:33.520)
and I'm listening to Europa by Santana,
Lex Fridman (03:36.360)
probably one of my favorite guitar songs.
Brian Kernighan (03:39.160)
It kind of makes me feel like I'm in a music video.
Lex Fridman (03:41.560)
So they told me to say that a bunch of celebrities
Brian Kernighan (03:44.840)
use these like Snoop Dogg, Melissa Etheridge, and Cardi B.
Lex Fridman (03:50.480)
I don't even know who Cardi B is,
Lex Fridman (03:52.720)
but her earbud game is on point.
Lex Fridman (03:55.600)
To mention celebrities I actually care about,
Brian Kernighan (03:58.320)
I'm sure if Richard Feynman was still with us,
Lex Fridman (04:01.160)
he'd be listening to the Joe Rogan Experience
Brian Kernighan (04:03.840)
with Raycon earbuds.
Lex Fridman (04:06.020)
Get them at buyraycon.com slash lex.
Brian Kernighan (04:09.360)
It's how they know I sent you
Lex Fridman (04:11.040)
and increases the chance that he'll support
Brian Kernighan (04:12.920)
this podcast in the future.
Lex Fridman (04:14.640)
So for all of the sponsors, click all of the links.
Brian Kernighan (04:17.560)
It really helps this podcast.
Lex Fridman (04:19.940)
And now, here's my conversation with Brian Kernighan.
Brian Kernighan (04:25.040)
Unix started being developed 50 years ago.
Lex Fridman (04:28.520)
It'd be more than 50 years ago.
Lex Fridman (04:30.520)
Can you tell the story like you describe in your new book
Lex Fridman (04:33.520)
of how Unix was created?
Brian Kernighan (04:35.700)
Ha, if I can remember that far back,
Lex Fridman (04:38.280)
it was some while ago.
Lex Fridman (04:40.440)
So I think the gist of it is that at Bell Labs,
Lex Fridman (04:44.440)
in 1969, there were a group of people
Brian Kernighan (04:46.760)
who had just finished working on the Multics project,
Lex Fridman (04:49.920)
which was itself a follow on to CTSS.
Lex Fridman (04:54.320)
So we can go back sort of an infinite regress in time,
Lex Fridman (04:57.040)
but the CTSS was a very, very, very nice time sharing system.
Brian Kernighan (05:01.040)
It was very nice to use.
Lex Fridman (05:02.080)
I actually used it that summer I spent in Cambridge in 1966.
Lex Fridman (05:06.920)
What was the hardware there?
Lex Fridman (05:08.520)
So what's the operating system, what's the hardware there?
Lex Fridman (05:10.360)
What's the CTSS look like?
Lex Fridman (05:12.160)
So CTSS looked like kind of like
Brian Kernighan (05:14.840)
a standard time sharing system.
Lex Fridman (05:17.040)
Certainly at the time, it was the only time sharing.
Brian Kernighan (05:19.400)
Let's go back to the basics.
Lex Fridman (05:20.800)
What's a time sharing system?
Brian Kernighan (05:22.360)
Okay, in the beginning was the word
Lex Fridman (05:23.760)
and the word was the system.
Lex Fridman (05:24.600)
And then there was time sharing systems.
Lex Fridman (05:27.040)
Yeah, if we go back into, let's call it the 1950s
Lex Fridman (05:29.960)
and early 1960s, most computing was done on very big
Lex Fridman (05:34.280)
computers, physically big, although not terribly powerful
Brian Kernighan (05:36.960)
by today's standards, that were maintained
Lex Fridman (05:39.840)
in very large rooms and you use things like punch cards
Brian Kernighan (05:45.760)
to write your programs on and talk to them.
Lex Fridman (05:47.440)
So you would take a deck of cards,
Brian Kernighan (05:49.320)
write your program on it, send it over a counter,
Lex Fridman (05:51.920)
hand it to an operator and some while later
Brian Kernighan (05:54.520)
back would come something that said,
Lex Fridman (05:55.680)
oh, you made a mistake and then you'd recycle.
Lex Fridman (05:58.040)
And so it was very, very slow.
Lex Fridman (05:59.480)
So the idea of time sharing was that you take
Brian Kernighan (06:02.320)
basically that same computer, but connect to it
Lex Fridman (06:06.240)
with something that looked like an electric typewriter.
Brian Kernighan (06:09.440)
They could be a long distance away, it could be close,
Lex Fridman (06:11.960)
but fundamentally what the operating system did
Brian Kernighan (06:14.960)
was to give each person who was connected to it
Lex Fridman (06:18.080)
and wanting to do something a small slice of time
Brian Kernighan (06:23.680)
to do a particular job.
Lex Fridman (06:24.880)
So I might be editing a file, so I would be typing
Lex Fridman (06:28.200)
and every time I hit a keystroke,
Lex Fridman (06:29.480)
the operating system would wake up and said,
Brian Kernighan (06:31.000)
oh, he typed character, let me remember that.
Lex Fridman (06:33.440)
Then it'd go back to doing something else.
Lex Fridman (06:35.000)
So it'd be going around and around a group of people
Lex Fridman (06:38.040)
who were trying to get something done, giving each
Brian Kernighan (06:40.200)
a small slice of time and giving them each the illusion
Lex Fridman (06:45.200)
that they pretty much had the whole machine to themselves
Lex Fridman (06:47.600)
and hence time sharing, that is sharing the computing time
Lex Fridman (06:51.360)
resource of the computer among a number of people
Brian Kernighan (06:54.240)
who were doing it.
Lex Fridman (06:55.080)
Without the individual people being aware
Brian Kernighan (06:56.920)
that there's others in a sense, the illusion,
Lex Fridman (06:59.320)
the feelings that the machine is your own.
Brian Kernighan (07:02.560)
Pretty much that was the idea.
Lex Fridman (07:04.040)
Yes, if it were well done and if it were fast enough
Lex Fridman (07:08.080)
and other people weren't doing too much,
Lex Fridman (07:09.840)
you did have the illusion that you had the whole machine
Brian Kernighan (07:12.320)
to yourself and it was very much better
Lex Fridman (07:14.880)
than the punch card model.
Lex Fridman (07:16.480)
And so CTSS, the compatible time sharing system
Lex Fridman (07:19.840)
was I think arguably the first of these.
Brian Kernighan (07:22.480)
It was done I guess technically in 64 or something like that.
Lex Fridman (07:26.440)
It ran on an IBM 7094, slightly modified
Brian Kernighan (07:30.080)
to have twice as much memory as the norm.
Lex Fridman (07:32.840)
It had two banks of 32K words instead of one.
Brian Kernighan (07:37.520)
So.
Lex Fridman (07:38.920)
32K words, yeah.
Brian Kernighan (07:40.800)
Each word was 36 bits, so call it
Lex Fridman (07:42.960)
about 150 kilobytes times two.
Lex Fridman (07:46.440)
So by today's standards, that's down in the noise.
Lex Fridman (07:49.640)
But at the time, that was a lot of memory
Lex Fridman (07:51.520)
and memory was expensive.
Lex Fridman (07:53.280)
So CTSS was just a wonderful environment to work on.
Brian Kernighan (07:56.920)
It was done by the people at MIT,
Lex Fridman (07:58.720)
led by Fernando Corbato, Corby who died just earlier
Brian Kernighan (08:03.600)
this year, and a bunch of other folks.
Lex Fridman (08:06.840)
So I spent the summer of 66 working on that,
Brian Kernighan (08:09.520)
had a great time, met a lot of really nice people
Lex Fridman (08:12.640)
and indirectly knew of people at Bell Labs
Brian Kernighan (08:17.640)
who were also working on a follow on to CTSS
Lex Fridman (08:22.480)
that was called Multics.
Lex Fridman (08:24.080)
So Multics was meant to be the system
Lex Fridman (08:26.000)
that would do everything that CTSS did
Lex Fridman (08:27.720)
but do it better for a larger population.
Lex Fridman (08:30.760)
All the usual stuff.
Brian Kernighan (08:31.720)
Now the actual time sharing, the scheduling,
Lex Fridman (08:36.560)
what's the algorithm that performs the scheduling?
Lex Fridman (08:39.040)
What's that look like?
Lex Fridman (08:39.880)
How much magic is there?
Lex Fridman (08:40.980)
What are the metrics?
Lex Fridman (08:42.720)
How does it all work in the beginning?
Lex Fridman (08:44.920)
So the answer is I don't have a clue.
Lex Fridman (08:46.200)
I think the basic idea was nothing more
Brian Kernighan (08:48.280)
than who all wants to get something done.
Lex Fridman (08:50.600)
Suppose that things are very quiet
Brian Kernighan (08:52.040)
in the middle of the night,
Lex Fridman (08:53.660)
then I get all the time that I want.
Brian Kernighan (08:55.760)
Suppose that you and I are contending at high noon
Lex Fridman (08:58.080)
for something like that,
Brian Kernighan (08:59.880)
then probably the simplest algorithm is a round robin one
Lex Fridman (09:02.600)
that gives you a bit of time, gives me a bit of time.
Lex Fridman (09:05.080)
And then we could adapt to that.
Lex Fridman (09:07.080)
Like what are you trying to do?
Lex Fridman (09:08.680)
Are you text editing or are you compiling or something?
Lex Fridman (09:12.000)
And then we might adjust the scheduler
Brian Kernighan (09:13.600)
according to things like that.
Lex Fridman (09:15.040)
So okay, so Multics was trying to just do some of the,
Brian Kernighan (09:19.000)
clean it up a little bit.
Lex Fridman (09:20.280)
Well, it was meant to be much more than that.
Lex Fridman (09:22.280)
So Multics was the multiplexed information
Lex Fridman (09:24.320)
and computing service and it was meant to be
Brian Kernighan (09:27.000)
a very large thing that would provide computing utility.
Lex Fridman (09:29.980)
Something that where you could actually think of it
Brian Kernighan (09:32.940)
as just a plug in the wall service.
Lex Fridman (09:35.080)
Sort of like cloud computing today.
Brian Kernighan (09:37.140)
Same idea, but 50 odd years earlier.
Lex Fridman (09:40.680)
And so what Multics offered
Brian Kernighan (09:43.800)
was a richer operating system environment,
Lex Fridman (09:46.520)
a piece of hardware that was better designed
Brian Kernighan (09:48.880)
for doing the kind of sharing of resources.
Lex Fridman (09:53.160)
And presumably lots of other things.
Lex Fridman (09:55.920)
Do you think people at that time had the dream
Lex Fridman (09:58.520)
of what cloud computing is starting to become now,
Brian Kernighan (10:01.080)
which is computing is everywhere.
Lex Fridman (10:03.120)
That you can just plug in almost,
Lex Fridman (10:06.440)
and you never know how the magic works.
Lex Fridman (10:09.000)
You just kind of plug in, add your little computation
Brian Kernighan (10:11.720)
that you need to perform and it does it.
Lex Fridman (10:13.640)
Was that the dream?
Brian Kernighan (10:14.880)
I don't know where that was the dream.
Lex Fridman (10:16.000)
I wasn't part of it at that point.
Brian Kernighan (10:17.360)
I remember I was an intern for summer.
Lex Fridman (10:19.360)
But my sense is given that it was over 50 years ago,
Brian Kernighan (10:23.240)
yeah, they had that idea that it was an information utility.
Lex Fridman (10:26.240)
That it was something where if you had a computing task to do,
Brian Kernighan (10:29.800)
you could just go and do it.
Lex Fridman (10:31.660)
Now I'm betting that they didn't have the same view
Brian Kernighan (10:35.880)
of computing for the masses, let's call it.
Lex Fridman (10:38.840)
The idea that your grandmother would be shopping on Amazon.
Brian Kernighan (10:43.200)
I don't think that was part of it.
Lex Fridman (10:45.000)
But if your grandmother were a programmer,
Brian Kernighan (10:47.160)
it might be very easy for her to go and use
Lex Fridman (10:49.920)
this kind of utility.
Lex Fridman (10:51.520)
What was your dream of computers at that time?
Lex Fridman (10:53.680)
What did you see as the future of computers?
Brian Kernighan (10:55.680)
Because you have predicted what computers are today.
Lex Fridman (10:59.600)
Oh, short answer, absolutely not.
Brian Kernighan (11:01.740)
I have no clue.
Lex Fridman (11:02.580)
I'm not sure I had a dream.
Brian Kernighan (11:03.840)
It was a dream job in the sense that I really enjoyed
Lex Fridman (11:06.640)
what I was doing.
Brian Kernighan (11:07.480)
I was surrounded by really, really nice people.
Lex Fridman (11:10.020)
Cambridge is a very fine city to live in in the summer,
Brian Kernighan (11:12.880)
less so in the winter when it snows.
Lex Fridman (11:14.300)
But in the summer, it was a delightful time.
Lex Fridman (11:16.880)
And so I really enjoyed all of that stuff.
Lex Fridman (11:19.240)
And I learned things.
Lex Fridman (11:20.400)
And I think the good fortune of being there for summer
Lex Fridman (11:25.000)
led me then to get a summer job at Bell Labs
Brian Kernighan (11:27.220)
the following summer.
Lex Fridman (11:28.520)
And that was quite useful for the future.
Lex Fridman (11:31.760)
So Bell Labs is this magical, legendary place.
Lex Fridman (11:35.960)
So first of all, where is Bell Labs?
Lex Fridman (11:39.060)
And can you start talking about that journey
Lex Fridman (11:44.200)
towards Unix at Bell Labs?
Brian Kernighan (11:46.600)
Yeah, so Bell Labs is physically scattered around,
Lex Fridman (11:50.160)
at the time, scattered around New Jersey.
Brian Kernighan (11:52.320)
The primary location is in a town called Murray Hill,
Lex Fridman (11:54.960)
or a location called Murray Hill is actually
Brian Kernighan (11:57.880)
across the boundary between two small towns in New Jersey
Lex Fridman (12:00.840)
called New Providence and Berkeley Heights.
Brian Kernighan (12:03.440)
Think of it as about 15, 20 miles straight west
Lex Fridman (12:05.440)
of New York City, and therefore about an hour north
Brian Kernighan (12:08.920)
of here in Princeton.
Lex Fridman (12:11.520)
And at that time, it had, make up a number,
Brian Kernighan (12:15.080)
three or 4,000 people there, many of whom had PhDs
Lex Fridman (12:18.000)
and mostly doing physical sciences,
Brian Kernighan (12:20.840)
chemistry, physics, materials kinds of things,
Lex Fridman (12:24.480)
but very strong math and rapidly growing interest
Brian Kernighan (12:29.120)
in computing as people realized you could do things
Lex Fridman (12:31.240)
with computers that you might not have been able
Brian Kernighan (12:34.000)
to do before.
Lex Fridman (12:35.040)
You could replace labs with computers
Brian Kernighan (12:37.520)
that had worked on models of what was going on.
Lex Fridman (12:41.360)
So that was the essence of Bell Labs.
Lex Fridman (12:44.160)
And again, I wasn't a permanent employee there.
Lex Fridman (12:46.600)
That was another internship.
Brian Kernighan (12:47.960)
I got lucky in internships.
Lex Fridman (12:50.480)
I mean, if you could just linger on it a little bit,
Lex Fridman (12:52.560)
what was the, what was in the air there?
Lex Fridman (12:55.520)
Because some of the, the number of Nobel Prizes,
Brian Kernighan (12:57.800)
the number of Turing Awards and just legendary
Lex Fridman (13:00.020)
computer scientists that come from their inventions,
Brian Kernighan (13:03.000)
including developments, including Unix,
Lex Fridman (13:05.920)
it's just, it's unbelievable.
Lex Fridman (13:07.900)
So was there something special about that place?
Lex Fridman (13:11.600)
Oh, I think there was very definitely something special.
Brian Kernighan (13:14.640)
I mentioned the number of people,
Lex Fridman (13:15.800)
it's a very large number of people, very highly skilled
Lex Fridman (13:19.120)
and working in an environment
Lex Fridman (13:20.680)
where there was always something interesting to work on
Brian Kernighan (13:23.120)
because the goal of Bell Labs,
Lex Fridman (13:25.120)
which was a small part of AT&T,
Brian Kernighan (13:27.280)
which provided basically the country's phone service.
Lex Fridman (13:30.160)
The goal of AT&T was to provide service for everybody.
Lex Fridman (13:33.440)
And the goal of Bell Labs was to try and make that service
Lex Fridman (13:36.940)
keep getting better, so improving service.
Lex Fridman (13:39.520)
And that meant doing research on a lot of different things,
Lex Fridman (13:43.920)
physical devices, like the transistor
Brian Kernighan (13:46.400)
or fiber optical cables or microwave systems,
Lex Fridman (13:50.860)
all of these things the labs worked on.
Lex Fridman (13:53.240)
And it was kind of just the beginning of real boom times
Lex Fridman (13:56.580)
in computing as well.
Brian Kernighan (13:58.040)
Because when I was there, I went there first in 66.
Lex Fridman (14:01.160)
So computing was at that point fairly young.
Lex Fridman (14:04.560)
And so people were discovering
Lex Fridman (14:06.000)
that you could do lots of things with computers.
Lex Fridman (14:08.720)
So how was Unix born?
Lex Fridman (14:10.840)
So Multics, in spite of having an enormous number
Brian Kernighan (14:14.600)
of really good ideas and lots of good people working on it,
Lex Fridman (14:16.840)
fundamentally didn't live up, at least in the short run,
Lex Fridman (14:20.040)
and I think ultimately really ever,
Lex Fridman (14:22.160)
to its goal of being this information utility.
Brian Kernighan (14:25.560)
It was too expensive and certainly what was promised
Lex Fridman (14:29.200)
was delivered much too late.
Lex Fridman (14:31.280)
And so in roughly the beginning of 1969,
Lex Fridman (14:34.600)
Bell Labs pulled out of the project.
Brian Kernighan (14:37.200)
The project at that point had included MIT, Bell Labs,
Lex Fridman (14:42.520)
and General Electric, General Electric made computers.
Lex Fridman (14:45.480)
So General Electric was the hardware operation.
Lex Fridman (14:48.320)
So Bell Labs, realizing this wasn't going anywhere
Brian Kernighan (14:50.880)
on a timescale they cared about, pulled out of the project.
Lex Fridman (14:54.160)
And this left several people with an acquired taste
Brian Kernighan (14:59.160)
for really, really nice computing environments,
Lex Fridman (15:01.660)
but no computing environment.
Lex Fridman (15:03.520)
And so they started thinking about what could you do
Lex Fridman (15:06.820)
if you were going to design a new operating system
Brian Kernighan (15:09.480)
that would provide the same kind of comfortable computing
Lex Fridman (15:12.920)
as CTSS had, but also the facilities of something
Brian Kernighan (15:16.040)
like Multics sort of brought forward.
Lex Fridman (15:19.440)
And so they did a lot of paper design stuff.
Lex Fridman (15:21.720)
And at the same time, Ken Thompson found
Lex Fridman (15:23.920)
what is characterized as a little used PDP 7,
Brian Kernighan (15:27.300)
where he started to do experiments with file systems,
Lex Fridman (15:31.080)
just how do you store information on a computer
Brian Kernighan (15:33.620)
in a efficient way, and then this famous story
Lex Fridman (15:36.380)
that his wife went away to California for three weeks,
Brian Kernighan (15:39.160)
taking their one year old son, and three weeks,
Lex Fridman (15:43.280)
and he sat down and wrote an operating system,
Brian Kernighan (15:45.640)
which ultimately became Unix.
Lex Fridman (15:47.500)
So software productivity was good in those days.
Lex Fridman (15:50.360)
So PDP, what's a PDP 7?
Lex Fridman (15:52.060)
So it's a piece of hardware.
Brian Kernighan (15:53.400)
Yeah, it's a piece of hardware.
Lex Fridman (15:54.560)
It was one of early machines made
Brian Kernighan (15:56.760)
by Digital Equipment Corporation, DEC,
Lex Fridman (15:59.880)
and it was a mini computer, so called.
Brian Kernighan (16:03.460)
It had, I would have to look up the numbers exactly,
Lex Fridman (16:07.480)
but it had a very small amount of memory,
Brian Kernighan (16:09.360)
maybe 16K, 16 bit words, or something like that,
Lex Fridman (16:13.320)
relatively slow, probably not super expensive.
Brian Kernighan (16:17.120)
Maybe, again, making this up, I'd have to look it up,
Lex Fridman (16:19.720)
$100,000 or something like that.
Lex Fridman (16:21.840)
Which is not super expensive in those days, right?
Lex Fridman (16:24.360)
It was expensive.
Brian Kernighan (16:25.400)
It was enough that you and I probably
Lex Fridman (16:26.840)
wouldn't be able to buy one,
Lex Fridman (16:27.680)
but a modest group of people could get together.
Lex Fridman (16:30.880)
But in any case, it came out, if I recall, in 1964.
Lex Fridman (16:34.880)
So by 1969, it was getting a little obsolete,
Lex Fridman (16:38.640)
and that's why it was little used.
Brian Kernighan (16:41.500)
If you can sort of comment,
Lex Fridman (16:42.800)
what do you think it's like
Lex Fridman (16:43.800)
to write an operating system like that?
Lex Fridman (16:45.680)
So that process that Ken went through in three weeks,
Brian Kernighan (16:49.600)
because you were, I mean, you're a part of that process.
Lex Fridman (16:52.800)
You contributed a lot to Unix's early development.
Lex Fridman (16:57.600)
So what do you think it takes to do that first step,
Lex Fridman (17:01.360)
that first kind of, from design to reality on the PDP?
Brian Kernighan (17:05.460)
Well, let me correct one thing.
Lex Fridman (17:07.160)
I had nothing to do with it.
Lex Fridman (17:08.860)
So I did not write it.
Lex Fridman (17:10.440)
I have never written operating system code.
Lex Fridman (17:13.440)
And so I don't know.
Lex Fridman (17:16.400)
Now an operating system is simply code.
Lex Fridman (17:18.980)
And this first one wasn't very big,
Lex Fridman (17:21.400)
but it's something that lets you run processes,
Brian Kernighan (17:24.600)
lets you execute some kind of code that has been written.
Lex Fridman (17:27.320)
It lets you store information for periods of time
Lex Fridman (17:30.800)
so that it doesn't go away when you turn the power off
Lex Fridman (17:33.160)
or reboot or something like that.
Lex Fridman (17:36.180)
And there's kind of a core set of tools
Lex Fridman (17:38.560)
that are technically not part of an operating system,
Lex Fridman (17:40.920)
but you probably need them.
Lex Fridman (17:42.380)
In this case, Ken wrote an assembler
Brian Kernighan (17:44.980)
for the PDP 7 that worked.
Lex Fridman (17:46.680)
He needed a text editor
Lex Fridman (17:47.820)
so that he could actually create text.
Lex Fridman (17:49.840)
He had the file system stuff that he had been working on,
Lex Fridman (17:52.120)
and then the rest of it was just a way
Lex Fridman (17:53.640)
to load things, executable code from the file system
Brian Kernighan (17:57.840)
into the memory, give it control,
Lex Fridman (18:00.040)
and then recover control when it was finished
Brian Kernighan (18:02.800)
or in some other way quit.
Lex Fridman (18:04.840)
What was the code written in,
Lex Fridman (18:06.600)
primarily the programming language?
Lex Fridman (18:08.160)
Was it in assembly?
Brian Kernighan (18:09.200)
Yeah, PDP 7 assembler that Ken created.
Lex Fridman (18:13.680)
These things were assembly language
Brian Kernighan (18:15.200)
until probably the, call it 1973 or 74, something like that.
Lex Fridman (18:21.440)
Forgive me if it's a dumb question,
Lex Fridman (18:23.000)
but it feels like a daunting task
Lex Fridman (18:25.200)
to write any kind of complex system in assembly.
Brian Kernighan (18:28.780)
Absolutely.
Lex Fridman (18:31.280)
It feels like impossible to do any kind
Brian Kernighan (18:32.860)
of what we think of as software engineering with assembly,
Lex Fridman (18:36.160)
because to work on a big picture sort of.
Brian Kernighan (18:40.080)
I think it's hard.
Lex Fridman (18:41.480)
It's been a long time since I wrote assembly language.
Brian Kernighan (18:43.760)
It is absolutely true that in assembly language,
Lex Fridman (18:45.600)
if you make a mistake, nobody tells you.
Brian Kernighan (18:47.160)
There are no training wheels whatsoever.
Lex Fridman (18:49.640)
And so stuff doesn't work.
Lex Fridman (18:51.120)
Now what?
Lex Fridman (18:51.960)
There's no debuggers.
Brian Kernighan (18:53.400)
Well, there could be debuggers,
Lex Fridman (18:54.460)
but that's the same problem, right?
Lex Fridman (18:56.800)
How do you actually get something
Lex Fridman (18:58.920)
that will help you debug it?
Lex Fridman (19:00.400)
So part of it is an ability to see the big picture.
Lex Fridman (19:05.640)
Now these systems were not big in the sense
Brian Kernighan (19:07.760)
that today's pictures are.
Lex Fridman (19:08.680)
So the big picture was in some sense more manageable.
Brian Kernighan (19:11.840)
I mean, then realistically,
Lex Fridman (19:13.560)
there's an enormous variation
Brian Kernighan (19:15.240)
in the capabilities of programmers.
Lex Fridman (19:17.520)
And Ken Thompson, who did that first one,
Brian Kernighan (19:20.200)
is kind of the singularity, in my experience, of programmers.
Lex Fridman (19:25.480)
With no disrespect to you or even to me,
Brian Kernighan (19:27.760)
he's in several leagues removed.
Lex Fridman (19:31.000)
I know there's levels.
Brian Kernighan (19:33.080)
It's a fascinating thing that there are unique stars
Lex Fridman (19:37.200)
in particular in the programming space
Lex Fridman (19:39.800)
and at a particular time.
Lex Fridman (19:40.880)
You know, the time matters too,
Brian Kernighan (19:42.160)
the timing of when that person comes along.
Lex Fridman (19:44.440)
And a wife does have to leave.
Brian Kernighan (19:47.800)
There's this weird timing that happens
Lex Fridman (19:49.760)
and then all of a sudden something beautiful is created.
Brian Kernighan (19:52.240)
I mean, how does it make you feel
Lex Fridman (19:53.400)
that there's a system that was created in three weeks
Brian Kernighan (19:58.280)
or maybe you can even say on a whim,
Lex Fridman (1:00:01.200)
And so that's an interesting combination of things.
Lex Fridman (1:00:03.240)
And so some ways, Go captures the good parts of C,
Lex Fridman (1:00:08.560)
it looks sort of like C, it's sometimes characterized as C
Brian Kernighan (1:00:11.400)
for the 21st century.
Lex Fridman (1:00:14.280)
On the surface, it looks very, very much like C.
Lex Fridman (1:00:17.580)
But at the same time, it has some interesting
Lex Fridman (1:00:20.040)
data structuring capabilities.
Lex Fridman (1:00:21.880)
And then I think the part that I would say
Lex Fridman (1:00:25.240)
is particularly useful, and again, I'm not a Go expert.
Brian Kernighan (1:00:29.680)
In spite of coauthoring the book,
Lex Fridman (1:00:31.840)
about 90% of the work was done by Alan Donovan,
Brian Kernighan (1:00:34.840)
my coauthor, who is a Go expert.
Lex Fridman (1:00:36.920)
But Go provides a very nice model of concurrency.
Brian Kernighan (1:00:40.420)
It's basically the cooperating,
Lex Fridman (1:00:42.740)
communicating sequential processes that Tony Hoare
Brian Kernighan (1:00:46.460)
set forth, jeez, I don't know, 40 plus years ago.
Lex Fridman (1:00:50.380)
And Go routines are, to my mind, a very natural way
Brian Kernighan (1:00:53.980)
to talk about parallel computation.
Lex Fridman (1:00:57.260)
And in the few experiments I've done with them,
Brian Kernighan (1:00:59.740)
they're easy to write, and typically it's gonna work,
Lex Fridman (1:01:02.780)
and very efficient as well.
Lex Fridman (1:01:05.180)
So I think that's one place where Go stands out,
Lex Fridman (1:01:07.860)
that that model of parallel computation
Brian Kernighan (1:01:10.860)
is very, very easy and nice to work with.
Lex Fridman (1:01:14.100)
Just to comment on that, do you think C foresaw,
Brian Kernighan (1:01:17.500)
or the early Unix days foresaw threads
Lex Fridman (1:01:20.740)
and massively parallel computation?
Brian Kernighan (1:01:23.940)
I would guess not really.
Lex Fridman (1:01:25.620)
I mean, maybe it was seen, but not at the level
Brian Kernighan (1:01:28.300)
where it was something you had to do anything about.
Lex Fridman (1:01:31.340)
For a long time, processors got faster,
Lex Fridman (1:01:35.020)
and then processors stopped getting faster
Lex Fridman (1:01:38.300)
because of things like power consumption
Lex Fridman (1:01:40.820)
and heat generation.
Lex Fridman (1:01:43.100)
And so what happened instead was that instead
Brian Kernighan (1:01:46.100)
of processors getting faster,
Lex Fridman (1:01:47.460)
there started to be more of them.
Lex Fridman (1:01:49.500)
And that's where that parallel thread stuff comes in.
Lex Fridman (1:01:53.740)
So if you can comment on all the other languages,
Lex Fridman (1:01:58.020)
is it break your heart that you'll never get to explore them?
Lex Fridman (1:02:01.500)
How do you feel about the full variety?
Brian Kernighan (1:02:04.420)
It's not break my heart,
Lex Fridman (1:02:05.700)
but I would love to be able to try more of these languages.
Brian Kernighan (1:02:10.020)
The closest I've come is in a class
Lex Fridman (1:02:11.940)
that I often teach in the spring here.
Brian Kernighan (1:02:14.060)
It's a programming class, and I often give,
Lex Fridman (1:02:18.580)
I have one sort of small example that I will write
Brian Kernighan (1:02:21.980)
in as many languages as I possibly can.
Lex Fridman (1:02:24.380)
I've got it in 20 languages.
Brian Kernighan (1:02:26.060)
At this point, and that's so I do a minimal experiment
Lex Fridman (1:02:31.260)
with a language just to say, okay,
Brian Kernighan (1:02:33.060)
I have this trivial task, which I understand the task,
Lex Fridman (1:02:35.580)
and it takes 15 lines in awk,
Lex Fridman (1:02:38.500)
and not much more in a variety of other languages.
Lex Fridman (1:02:41.420)
So how big is it?
Lex Fridman (1:02:42.260)
How fast does it run?
Lex Fridman (1:02:43.380)
And what pain did I go through to learn how to do it?
Lex Fridman (1:02:47.980)
And that's like anecdotal, right?
Lex Fridman (1:02:52.420)
It's very, very, very, very, very, very, very,
Brian Kernighan (1:02:55.980)
very, very narrowly focused.
Lex Fridman (1:02:57.900)
I think data, I like that term.
Lex Fridman (1:02:59.460)
So yeah, but still, it's a little sample,
Lex Fridman (1:03:01.940)
because you get to, I think the hardest step
Brian Kernighan (1:03:04.040)
of the programming language is probably the first step,
Lex Fridman (1:03:06.380)
right, so there you're taking the first step.
Brian Kernighan (1:03:08.800)
Yeah, and so my experience with some languages
Lex Fridman (1:03:13.460)
is very positive, like Lua,
Brian Kernighan (1:03:14.900)
a scripting language I had never used,
Lex Fridman (1:03:17.580)
and I took my little program.
Brian Kernighan (1:03:19.780)
The program is a trivial formatter.
Lex Fridman (1:03:21.700)
It just takes in lines of text of varying lengths,
Lex Fridman (1:03:24.660)
and it puts them out in lines
Lex Fridman (1:03:26.500)
that have no more than 60 characters on each line.
Lex Fridman (1:03:28.940)
So think of it as just kind of the flow of process
Lex Fridman (1:03:31.940)
in a browser or something.
Lex Fridman (1:03:34.500)
So it's a very short program.
Lex Fridman (1:03:36.300)
And in Lua, I downloaded Lua,
Lex Fridman (1:03:39.340)
and in an hour, I had it working,
Lex Fridman (1:03:41.040)
never having written Lua in my life,
Brian Kernighan (1:03:43.180)
just going with online documentation.
Lex Fridman (1:03:44.940)
I did the same thing in Scala,
Brian Kernighan (1:03:46.180)
which you can think of as a flavor of Java, equally trivial.
Lex Fridman (1:03:51.020)
I did it in Haskell.
Brian Kernighan (1:03:52.140)
It took me several weeks.
Lex Fridman (1:03:53.620)
But it did run like a turtle.
Lex Fridman (1:03:57.780)
And I did it in Fortran 90, and it was painful,
Lex Fridman (1:04:05.220)
but it worked, and I tried it in Rust,
Lex Fridman (1:04:07.980)
and it took me several days to get it working
Lex Fridman (1:04:10.200)
because the model of memory management
Brian Kernighan (1:04:12.140)
was just a little unfamiliar to me.
Lex Fridman (1:04:13.820)
And the problem I had with Rust,
Lex Fridman (1:04:15.900)
and it's back to what we were just talking about,
Lex Fridman (1:04:18.300)
I couldn't find good, consistent documentation on Rust.
Brian Kernighan (1:04:21.500)
Now, this was several years ago,
Lex Fridman (1:04:22.720)
and I'm sure things have stabilized,
Lex Fridman (1:04:24.180)
but at the time, everything in the Rust world
Lex Fridman (1:04:26.500)
seemed to be changing rapidly,
Lex Fridman (1:04:27.900)
and so you would find what looked like a working example,
Lex Fridman (1:04:30.500)
and it wouldn't work with the version
Brian Kernighan (1:04:32.220)
of the language that I had.
Lex Fridman (1:04:34.820)
So it took longer than it should have.
Brian Kernighan (1:04:37.540)
Rust is a language I would like to get back to,
Lex Fridman (1:04:39.620)
but probably won't.
Brian Kernighan (1:04:41.200)
I think one of the issues,
Lex Fridman (1:04:42.060)
you have to have something you want to do.
Brian Kernighan (1:04:44.060)
If you don't have something that is the right combination,
Lex Fridman (1:04:47.540)
if I want to do it, and yet I have enough disposable time,
Brian Kernighan (1:04:51.980)
whatever, to make it worth learning a new language
Lex Fridman (1:04:55.220)
at the same time, it's never gonna happen.
Lex Fridman (1:04:58.120)
So what do you think about another language of JavaScript?
Lex Fridman (1:05:02.100)
That's this...
Brian Kernighan (1:05:04.940)
Well, let me just sort of comment on what I said.
Lex Fridman (1:05:06.860)
When I was brought up, sort of JavaScript was seen as
Brian Kernighan (1:05:12.240)
probably like the ugliest language possible,
Lex Fridman (1:05:15.580)
and yet it's quite arguably, quite possibly taking over,
Brian Kernighan (1:05:18.980)
not just the front end and the back end of the internet,
Lex Fridman (1:05:21.640)
but possibly in the future taking over everything,
Brian Kernighan (1:05:24.020)
because they've now learned to make it very efficient.
Lex Fridman (1:05:27.900)
And so what do you think about this?
Brian Kernighan (1:05:29.700)
Yeah, well, I think you've captured it in a lot of ways.
Lex Fridman (1:05:32.140)
When it first came out,
Brian Kernighan (1:05:32.980)
JavaScript was deemed to be fairly irregular
Lex Fridman (1:05:35.460)
and an ugly language, and certainly in the academy,
Brian Kernighan (1:05:37.780)
if you said you were working on JavaScript,
Lex Fridman (1:05:39.260)
people would ridicule you.
Brian Kernighan (1:05:40.460)
It was just not fit for academics to work on.
Lex Fridman (1:05:43.780)
I think a lot of that has evolved.
Brian Kernighan (1:05:45.460)
The language itself has evolved,
Lex Fridman (1:05:47.540)
and certainly the technology of compiling it
Brian Kernighan (1:05:50.660)
is fantastically better than it was.
Lex Fridman (1:05:53.660)
And so in that sense,
Brian Kernighan (1:05:54.780)
it's absolutely a viable solution on back ends,
Lex Fridman (1:05:58.820)
as well as the front ends.
Brian Kernighan (1:06:01.140)
Used well, I think it's a pretty good language.
Lex Fridman (1:06:03.480)
I've written a modest amount of it,
Lex Fridman (1:06:06.340)
and I've played with JavaScript translators
Lex Fridman (1:06:09.140)
and things like that.
Brian Kernighan (1:06:10.300)
I'm not a real expert,
Lex Fridman (1:06:12.020)
and it's hard to keep up even there
Brian Kernighan (1:06:13.660)
with the new things that come along with it.
Lex Fridman (1:06:15.860)
So I don't know whether it will ever take over the world.
Brian Kernighan (1:06:19.220)
I think not, but it's certainly an important language,
Lex Fridman (1:06:24.540)
and worth knowing more about.
Brian Kernighan (1:06:27.100)
There's, maybe to get your comment on something,
Lex Fridman (1:06:30.260)
which JavaScript, and actually most languages,
Brian Kernighan (1:06:33.220)
sort of Python, such a big part of the experience
Lex Fridman (1:06:37.420)
of programming with those languages includes libraries,
Brian Kernighan (1:06:40.660)
sort of using, building on top of the code
Lex Fridman (1:06:42.500)
that other people have built.
Brian Kernighan (1:06:43.780)
I think that's probably different from the experience
Lex Fridman (1:06:45.980)
that we just talked about from Unix and C days,
Brian Kernighan (1:06:49.700)
when you're building stuff from scratch.
Lex Fridman (1:06:51.020)
What do you think about this world
Brian Kernighan (1:06:53.020)
of essentially leveraging, building up libraries
Lex Fridman (1:06:55.460)
on top of each other and leveraging them?
Brian Kernighan (1:06:57.180)
Yeah, no, that's a very perceptive kind of question.
Lex Fridman (1:07:01.780)
One of the reasons programming was fun in the old days
Brian Kernighan (1:07:04.060)
was that you were really building it all yourself.
Lex Fridman (1:07:06.860)
The number of libraries you had to deal with
Brian Kernighan (1:07:08.780)
was quite small.
Lex Fridman (1:07:09.620)
Maybe it was printf, or the standard library,
Brian Kernighan (1:07:11.980)
or something like that, and that is not the case today.
Lex Fridman (1:07:15.780)
And if you want to do something in,
Brian Kernighan (1:07:18.060)
you mentioned Python and JavaScript,
Lex Fridman (1:07:20.460)
and those are the two fine examples,
Brian Kernighan (1:07:22.220)
you have to typically download a boatload of other stuff,
Lex Fridman (1:07:25.740)
and you have no idea what you're getting,
Brian Kernighan (1:07:27.660)
absolutely nothing.
Lex Fridman (1:07:29.220)
I've been doing some playing with machine learning
Brian Kernighan (1:07:31.540)
over the last couple of days,
Lex Fridman (1:07:33.540)
and geez, something doesn't work.
Brian Kernighan (1:07:36.420)
Well, you pip install this, okay,
Lex Fridman (1:07:38.900)
and down comes another one,
Brian Kernighan (1:07:40.460)
okay, and down comes another gazillion megabytes of something
Lex Fridman (1:07:44.340)
and you have no idea what it was.
Lex Fridman (1:07:46.300)
And if you're lucky, it works.
Lex Fridman (1:07:47.940)
And if it doesn't work, you have no recourse.
Brian Kernighan (1:07:51.180)
There's absolutely no way you could figure out
Lex Fridman (1:07:52.740)
which of these thousand different packages.
Lex Fridman (1:07:55.180)
And I think it's worse in the NPM environment
Lex Fridman (1:07:59.540)
for JavaScript.
Brian Kernighan (1:08:00.380)
I think there's less discipline, less control there.
Lex Fridman (1:08:02.980)
And there's aspects of not just not understanding
Lex Fridman (1:08:06.100)
how it works, but there's security issues,
Lex Fridman (1:08:07.900)
there's robustness issues,
Lex Fridman (1:08:09.020)
so you don't wanna run a nuclear power plant
Lex Fridman (1:08:11.740)
using JavaScript, essentially.
Brian Kernighan (1:08:14.060)
Probably not.
Lex Fridman (1:08:16.100)
So speaking to the variety of languages,
Lex Fridman (1:08:18.820)
do you think that variety is good,
Lex Fridman (1:08:20.420)
or do you hope, think that over time,
Brian Kernighan (1:08:23.540)
we should converge towards one, two, three
Lex Fridman (1:08:25.740)
programming languages?
Brian Kernighan (1:08:28.140)
You mentioned to the Bell Lab days
Lex Fridman (1:08:29.700)
when people could sort of, the community of it,
Lex Fridman (1:08:32.860)
and the more languages you have,
Lex Fridman (1:08:34.500)
the more you separate the communities.
Brian Kernighan (1:08:36.780)
There's the Ruby community,
Lex Fridman (1:08:38.140)
there's the Python community,
Brian Kernighan (1:08:40.260)
there's C++ community.
Lex Fridman (1:08:42.660)
Do you hope that they'll unite one day
Lex Fridman (1:08:45.420)
to just one or two languages?
Lex Fridman (1:08:47.700)
I certainly don't hope it.
Brian Kernighan (1:08:48.820)
I'm not sure that that's right,
Lex Fridman (1:08:49.940)
because I honestly don't think there is one language
Brian Kernighan (1:08:51.940)
that will suffice for all the programming needs of the world.
Lex Fridman (1:08:55.340)
Are there too many at this point?
Brian Kernighan (1:08:56.860)
Well, arguably.
Lex Fridman (1:08:58.540)
But I think if you look at the sort of the distribution
Brian Kernighan (1:09:01.860)
of how they are used,
Lex Fridman (1:09:03.140)
there's something called a dozen languages
Brian Kernighan (1:09:06.740)
that probably account for 95% of all programming
Lex Fridman (1:09:10.500)
at this point, and that doesn't seem unreasonable.
Lex Fridman (1:09:13.580)
And then there's another, well, 2,000 languages
Lex Fridman (1:09:17.220)
that are still in use that nobody uses,
Brian Kernighan (1:09:19.940)
and, or at least don't use in any quantity.
Lex Fridman (1:09:23.300)
But I think new languages are a good idea in many respects,
Brian Kernighan (1:09:25.940)
because they're often a chance to explore an idea
Lex Fridman (1:09:30.260)
of how language might help.
Brian Kernighan (1:09:32.940)
I think that's one of the positive things
Lex Fridman (1:09:35.220)
about functional languages, for example.
Brian Kernighan (1:09:36.940)
They're a particularly good place
Lex Fridman (1:09:38.660)
where people have explored ideas
Brian Kernighan (1:09:42.500)
that at the time didn't seem feasible,
Lex Fridman (1:09:45.700)
but ultimately have wound up
Brian Kernighan (1:09:47.500)
as part of mainstream languages as well.
Lex Fridman (1:09:50.140)
I mean, just go back as early as Recursion Lisp
Lex Fridman (1:09:52.700)
and then follow forward functions as first class citizens
Lex Fridman (1:09:57.100)
and pattern based languages,
Lex Fridman (1:09:59.300)
and gee, I don't know, closures,
Lex Fridman (1:10:02.260)
and just on and on and on.
Brian Kernighan (1:10:04.220)
Lambda's interesting ideas that showed up first
Lex Fridman (1:10:07.020)
in, let's call it broadly,
Brian Kernighan (1:10:08.860)
the functional programming community,
Lex Fridman (1:10:10.700)
and then find their way into mainstream languages.
Brian Kernighan (1:10:13.340)
Yeah, it's a playground for rebels.
Lex Fridman (1:10:15.620)
Yeah, exactly, and so I think the languages
Brian Kernighan (1:10:19.620)
in the playground themselves are probably not going
Lex Fridman (1:10:22.680)
to be the mainstream, at least for some while,
Lex Fridman (1:10:25.900)
but the ideas that come from there are invaluable.
Lex Fridman (1:10:29.940)
So let's go to something that, when I found out recently,
Lex Fridman (1:10:33.860)
so I've known that you've done a million things,
Lex Fridman (1:10:36.220)
but one of the things I wasn't aware of,
Brian Kernighan (1:10:37.740)
that you had a role in Ample,
Lex Fridman (1:10:39.700)
and before you interrupt me by minimizing your role in it.
Brian Kernighan (1:10:44.940)
Ample is for minimizing functions.
Lex Fridman (1:10:46.500)
Yeah, minimizing functions, right, exactly.
Brian Kernighan (1:10:51.020)
Can I just say that the elegance and abstraction power
Lex Fridman (1:10:53.580)
of Ample is incredible,
Brian Kernighan (1:10:57.380)
when I first came to it about 10 years ago or so.
Lex Fridman (1:11:01.360)
Can you describe what is the Ample language?
Brian Kernighan (1:11:04.260)
Sure, so Ample is a language for mathematical programming,
Lex Fridman (1:11:08.180)
technical term, think of it as linear programming,
Brian Kernighan (1:11:10.760)
that is setting up systems of linear equations
Lex Fridman (1:11:14.740)
that are of some sort of system of constraints,
Lex Fridman (1:11:18.820)
so that you have a bunch of things
Lex Fridman (1:11:20.580)
that have to be less than this, greater than that,
Brian Kernighan (1:11:22.580)
whatever, and you're trying to find a set of values
Lex Fridman (1:11:25.640)
for some decision variables that will maximize
Brian Kernighan (1:11:29.580)
or minimize some objective function,
Lex Fridman (1:11:32.220)
so it's a way of solving a particular kind
Brian Kernighan (1:11:35.900)
of optimization problem,
Lex Fridman (1:11:38.000)
a very formal sort of optimization problem,
Lex Fridman (1:11:40.020)
but one that's exceptionally useful.
Lex Fridman (1:11:42.540)
And it specifies, so there's objective function constraints
Lex Fridman (1:11:45.820)
and variables that become separate
Lex Fridman (1:11:48.180)
from the data it operates on.
Brian Kernighan (1:11:50.060)
Right.
Lex Fridman (1:11:50.900)
So that kind of separation allows you to,
Brian Kernighan (1:11:56.860)
put on different hats,
Lex Fridman (1:11:58.020)
one put the hat of an optimization person
Lex Fridman (1:12:00.380)
and then put another hat of a data person
Lex Fridman (1:12:03.260)
and dance back and forth,
Lex Fridman (1:12:04.940)
and also separate the actual solvers,
Lex Fridman (1:12:08.820)
the optimization systems that do the solving.
Brian Kernighan (1:12:11.980)
Then you can have other people come to the table
Lex Fridman (1:12:14.220)
and then build their solvers,
Brian Kernighan (1:12:15.500)
whether it's linear or nonlinear,
Lex Fridman (1:12:19.480)
convex, nonconvex, that kind of stuff.
Lex Fridman (1:12:21.800)
So what is the,
Lex Fridman (1:12:25.740)
to you as, maybe you can comment
Lex Fridman (1:12:28.780)
how you got into that world
Lex Fridman (1:12:30.180)
and what is the beautiful or interesting idea to you
Lex Fridman (1:12:33.800)
from the world of optimization?
Lex Fridman (1:12:35.420)
Sure.
Lex Fridman (1:12:36.260)
So I preface it by saying I'm absolutely not an expert
Lex Fridman (1:12:39.820)
on this and most of the important work in AMPL
Brian Kernighan (1:12:42.980)
comes from my two partners in crime on that,
Lex Fridman (1:12:45.360)
Bob Forer, who was a professor
Brian Kernighan (1:12:48.740)
in the Industrial Engineering
Lex Fridman (1:12:50.020)
and Management Science Department at Northwestern,
Lex Fridman (1:12:52.500)
and my colleague at Bell Labs, Dave Gay,
Lex Fridman (1:12:54.820)
who was a numerical analyst and optimization person.
Lex Fridman (1:12:59.020)
So the deal is linear programming.
Lex Fridman (1:13:02.420)
Preface this by saying I don't.
Brian Kernighan (1:13:03.860)
Let's stay with linear programming.
Lex Fridman (1:13:05.180)
Yeah, linear programming is the simplest example of this.
Lex Fridman (1:13:07.620)
So linear programming, as it's taught in school,
Lex Fridman (1:13:09.740)
is that you have a big matrix,
Brian Kernighan (1:13:11.220)
which is always called A,
Lex Fridman (1:13:12.260)
and you say AX is less than or equal to B.
Lex Fridman (1:13:14.940)
So B is a set of constraints,
Lex Fridman (1:13:16.380)
X is the decision variables,
Lex Fridman (1:13:18.580)
and A is how the decision variables are combined
Lex Fridman (1:13:22.980)
to set up the various constraints.
Lex Fridman (1:13:24.500)
So A is a matrix and X and B are vectors.
Lex Fridman (1:13:28.180)
And then there's an objective function,
Brian Kernighan (1:13:30.020)
which is just a sum of a bunch of Xs
Lex Fridman (1:13:32.000)
and some coefficients on them,
Lex Fridman (1:13:33.620)
and that's the thing you want to optimize.
Lex Fridman (1:13:37.160)
The problem is that in the real world,
Brian Kernighan (1:13:40.020)
that matrix A is a very, very, very intricate,
Lex Fridman (1:13:43.460)
very large and very sparse matrix
Brian Kernighan (1:13:45.560)
where the various components of the model
Lex Fridman (1:13:47.860)
are distributed among the coefficients
Brian Kernighan (1:13:50.600)
in a way that is totally unobvious to anybody.
Lex Fridman (1:13:54.880)
And so what you need is some way
Brian Kernighan (1:13:57.580)
to express the original model,
Lex Fridman (1:13:59.860)
which you and I would write,
Brian Kernighan (1:14:01.100)
you know, we'd write mathematics on the board,
Lex Fridman (1:14:03.300)
and the sum of this is greater
Brian Kernighan (1:14:04.580)
than the sum of that kind of thing.
Lex Fridman (1:14:06.460)
So you need a language to write those kinds of constraints.
Lex Fridman (1:14:10.300)
And Bob Forer, for a long time,
Lex Fridman (1:14:12.340)
had been interested in modeling languages,
Brian Kernighan (1:14:14.420)
languages that made it possible to do this.
Lex Fridman (1:14:16.540)
There was a modeling language around called GAMS,
Brian Kernighan (1:14:19.060)
the General Algebraic Modeling System,
Lex Fridman (1:14:21.300)
but it looked very much like Fortran.
Brian Kernighan (1:14:22.940)
It was kind of clunky.
Lex Fridman (1:14:24.700)
And so Bob spent a sabbatical year at Bell Labs in 1984,
Lex Fridman (1:14:29.220)
and he and, there's only the office across from me,
Lex Fridman (1:14:32.820)
and it's always geography,
Lex Fridman (1:14:35.420)
and he and Dave Gay and I started talking
Lex Fridman (1:14:38.080)
about this kind of thing,
Lex Fridman (1:14:39.700)
and he wanted to design a language that would make it
Lex Fridman (1:14:43.780)
so that you could take these algebraic specifications,
Brian Kernighan (1:14:46.520)
you know, summation signs over sets,
Lex Fridman (1:14:48.820)
and that you would write on the board
Lex Fridman (1:14:51.100)
and convert them into basically this A matrix,
Lex Fridman (1:14:55.820)
and then pass that off to a solver,
Brian Kernighan (1:14:58.900)
which is an entirely separate thing.
Lex Fridman (1:15:01.620)
And so we talked about the design of the language.
Brian Kernighan (1:15:05.140)
I don't remember any of the details of this now,
Lex Fridman (1:15:07.200)
but it's kind of an obvious thing.
Brian Kernighan (1:15:08.940)
You're just writing out mathematical expressions
Lex Fridman (1:15:11.220)
in a Fortran like, sorry,
Brian Kernighan (1:15:13.140)
an algebraic but textual like language.
Lex Fridman (1:15:15.820)
And I wrote the first version of this Ample program,
Brian Kernighan (1:15:22.580)
my first C++ program, and.
Lex Fridman (1:15:26.180)
It's written in C++?
Brian Kernighan (1:15:27.420)
Yeah.
Lex Fridman (1:15:28.620)
And so I did that fairly quickly.
Brian Kernighan (1:15:30.980)
We wrote, it was, you know, 3,000 lines or something,
Lex Fridman (1:15:33.500)
so it wasn't very big,
Lex Fridman (1:15:34.340)
but it sort of showed the feasibility of it
Lex Fridman (1:15:36.520)
that you could actually do something that was easy
Brian Kernighan (1:15:38.380)
for people to specify models
Lex Fridman (1:15:41.740)
and convert it into something that a solver could work with.
Brian Kernighan (1:15:44.700)
At the same time, as you say,
Lex Fridman (1:15:45.860)
the model and the data are separate things.
Lex Fridman (1:15:47.900)
So one model would then work with all kinds
Lex Fridman (1:15:50.580)
of different data in the same way
Brian Kernighan (1:15:51.780)
that lots of programs do the same thing,
Lex Fridman (1:15:53.500)
but with different data.
Lex Fridman (1:15:54.420)
So one of the really nice things
Lex Fridman (1:15:55.660)
is the specification of the models,
Brian Kernighan (1:15:58.460)
human, just kind of like, as you say, is human readable.
Lex Fridman (1:16:01.980)
Like I literally, I remember on stuff I worked,
Brian Kernighan (1:16:04.900)
I would send it to colleagues
Lex Fridman (1:16:07.620)
that I'm pretty sure never programmed in their life,
Brian Kernighan (1:16:10.780)
just to understand what the optimization problem is.
Lex Fridman (1:16:15.780)
I think, how hard is it to convert that?
Brian Kernighan (1:16:18.060)
You said there's a first prototype in C++
Lex Fridman (1:16:20.300)
to convert that into something
Brian Kernighan (1:16:22.060)
that could actually be used by the solver.
Lex Fridman (1:16:24.300)
It's not too bad,
Brian Kernighan (1:16:25.140)
because most of the solvers have some mechanism
Lex Fridman (1:16:27.460)
that lets them import a model in a form.
Brian Kernighan (1:16:30.460)
It might be as simple as the matrix itself
Lex Fridman (1:16:32.980)
in just some representation,
Brian Kernighan (1:16:35.040)
or if you're doing things that are not linear programming,
Lex Fridman (1:16:38.420)
then there may be some mechanism
Brian Kernighan (1:16:39.820)
that lets you provide things like functions to be called,
Lex Fridman (1:16:43.420)
or other constraints on the model.
Lex Fridman (1:16:47.140)
So all AMPL does is to generate that kind of thing,
Lex Fridman (1:16:51.500)
and then solver deals with all the hard work,
Lex Fridman (1:16:54.220)
and then when the solver comes back with numbers,
Lex Fridman (1:16:57.380)
AMPL converts those back into your original form,
Lex Fridman (1:17:00.220)
so you know how much of each thing you should be buying,
Lex Fridman (1:17:03.140)
or making, or shipping, or whatever.
Lex Fridman (1:17:05.120)
So we did that in 84, and I haven't had a lot to do
Lex Fridman (1:17:11.160)
with it since, except that we wrote a couple of versions
Brian Kernighan (1:17:13.560)
of a book on it.
Lex Fridman (1:17:14.400)
Which is one of the greatest books ever written.
Brian Kernighan (1:17:16.520)
I love that book.
Lex Fridman (1:17:18.600)
I don't know why.
Brian Kernighan (1:17:19.960)
It's an excellent book.
Lex Fridman (1:17:20.980)
Bob Farrer wrote most of it,
Lex Fridman (1:17:22.520)
and so it's really, really well done.
Lex Fridman (1:17:23.980)
He must have been a dynamite teacher.
Lex Fridman (1:17:25.640)
And typeset in LaTeX.
Lex Fridman (1:17:27.520)
No, no, no, are you kidding?
Brian Kernighan (1:17:29.040)
I remember liking the typography, so I don't know.
Lex Fridman (1:17:32.920)
We did it with DROF.
Brian Kernighan (1:17:34.480)
I don't even know what that is.
Lex Fridman (1:17:35.440)
Yeah, exactly.
Brian Kernighan (1:17:36.280)
You're too young.
Lex Fridman (1:17:37.120)
Uh oh, oh boy.
Brian Kernighan (1:17:38.360)
I think of DROF as a predecessor
Lex Fridman (1:17:42.160)
to the tech family of things.
Brian Kernighan (1:17:44.240)
It's a formatter that was done at Bell Labs
Lex Fridman (1:17:46.160)
in this same period of the very early 70s
Brian Kernighan (1:17:49.720)
that predates tech and things like that
Lex Fridman (1:17:52.440)
by five to 10 years.
Lex Fridman (1:17:54.920)
But it was nevertheless, I'm going by memories.
Lex Fridman (1:17:58.200)
I remember it being beautiful.
Brian Kernighan (1:18:00.080)
Yeah, it was nicely done.
Lex Fridman (1:18:01.800)
Outside of Unix, C, A, Golang,
Brian Kernighan (1:18:03.840)
all the things we talked about.
Lex Fridman (1:18:05.760)
All the amazing work you've done.
Brian Kernighan (1:18:07.920)
You've also done work in graph theory.
Lex Fridman (1:18:12.500)
Let me ask this crazy out there question.
Brian Kernighan (1:18:16.480)
If you had to make a bet,
Lex Fridman (1:18:17.640)
and I had to force you to make a bet,
Lex Fridman (1:18:19.200)
do you think P equals NP?
Lex Fridman (1:18:23.520)
The answer is no,
Brian Kernighan (1:18:24.360)
although I'm told that somebody asked Jeff Dean
Lex Fridman (1:18:27.160)
if that was, under what conditions P would equal NP,
Lex Fridman (1:18:30.080)
and he said either P is zero or N is one.
Lex Fridman (1:18:33.840)
Or vice versa, I've forgotten.
Brian Kernighan (1:18:35.640)
This is why Jeff Dean is a lot smarter than I am.
Lex Fridman (1:18:38.040)
Yeah.
Brian Kernighan (1:18:40.040)
So, but your intuition is, uh.
Lex Fridman (1:18:42.440)
I have no, I have no intuition,
Lex Fridman (1:18:44.880)
but I've got a lot of colleagues who've got intuition
Lex Fridman (1:18:46.840)
and their betting is no.
Brian Kernighan (1:18:48.160)
That's the popular, that's the popular bet.
Lex Fridman (1:18:51.200)
Okay, so what is computational complexity theory?
Lex Fridman (1:18:55.640)
And do you think these kinds of complexity classes,
Lex Fridman (1:18:58.280)
especially as you've taught in this modern world,
Brian Kernighan (1:19:01.560)
are still a useful way to understand
Lex Fridman (1:19:04.240)
the hardness of problems?
Brian Kernighan (1:19:06.080)
I don't do that stuff.
Lex Fridman (1:19:07.400)
The last time I touched anything to do with that
Brian Kernighan (1:19:09.360)
was before. Many, many years ago.
Lex Fridman (1:19:10.320)
Was before it was invented.
Brian Kernighan (1:19:12.400)
Because I, it's literally true.
Lex Fridman (1:19:14.680)
I did my PhD thesis on graph.
Brian Kernighan (1:19:17.720)
Before Big O notation.
Lex Fridman (1:19:18.920)
Oh, absolutely.
Brian Kernighan (1:19:19.760)
Before, I did this in 1968,
Lex Fridman (1:19:24.060)
and I worked on graph partitioning,
Brian Kernighan (1:19:25.940)
which is this question.
Lex Fridman (1:19:26.780)
You've got a graph that is a nodes and edges kind of graph,
Lex Fridman (1:19:30.280)
and the edges have weights,
Lex Fridman (1:19:31.640)
and you just want to divide the nodes into two piles
Brian Kernighan (1:19:34.400)
of equal size so that the number of edges
Lex Fridman (1:19:36.780)
that goes from one side to the other
Brian Kernighan (1:19:38.040)
is as small as possible.
Lex Fridman (1:19:40.320)
And we.
Brian Kernighan (1:19:41.560)
You developed, so that problem is hard.
Lex Fridman (1:19:45.880)
Well, as it turns out,
Brian Kernighan (1:19:47.240)
I worked with Shen Lin at Bell Labs on this,
Lex Fridman (1:19:49.880)
and we were never able to come up with anything
Brian Kernighan (1:19:52.640)
that was guaranteed to give the right answer.
Lex Fridman (1:19:54.200)
We came up with heuristics that worked pretty darn well,
Lex Fridman (1:19:57.920)
and I peeled off some special cases for my thesis,
Lex Fridman (1:20:01.060)
but it was just hard.
Lex Fridman (1:20:02.240)
And that was just about the time that Steve Cook
Lex Fridman (1:20:04.680)
was showing that there were classes of problems
Brian Kernighan (1:20:06.500)
that appeared to be really hard,
Lex Fridman (1:20:08.120)
of which graph partitioning was one.
Lex Fridman (1:20:10.720)
But this, my expertise, such as it was,
Lex Fridman (1:20:13.760)
totally predates that development.
Brian Kernighan (1:20:16.500)
Oh, interesting.
Lex Fridman (1:20:17.340)
So the heuristic, which now,
Brian Kernighan (1:20:20.060)
carries the two of yours names
Lex Fridman (1:20:21.960)
for the traveling salesman problem,
Lex Fridman (1:20:23.720)
and then for the graph partitioning.
Lex Fridman (1:20:25.280)
That was, like, how did you,
Brian Kernighan (1:20:27.460)
you weren't even thinking in terms of classes.
Lex Fridman (1:20:29.320)
You were just trying to find.
Brian Kernighan (1:20:30.160)
There was no such idea.
Lex Fridman (1:20:31.120)
A heuristic that kinda does the job pretty well.
Brian Kernighan (1:20:34.440)
You were trying to find something that did the job,
Lex Fridman (1:20:36.820)
and there was nothing that you would call,
Brian Kernighan (1:20:38.680)
let's say, a closed form or algorithmic thing
Lex Fridman (1:20:41.760)
that would give you a guaranteed right answer.
Brian Kernighan (1:20:44.320)
I mean, compare graph partitioning to max flow min cut,
Lex Fridman (1:20:48.320)
or something like that.
Brian Kernighan (1:20:50.180)
That's the same problem,
Lex Fridman (1:20:51.400)
except there's no constraint on the number of nodes
Brian Kernighan (1:20:53.920)
on one side or the other of the cut.
Lex Fridman (1:20:56.280)
And that means it's an easy problem,
Brian Kernighan (1:20:58.720)
at least as I understand it.
Lex Fridman (1:21:00.000)
Whereas the constraint that says
Brian Kernighan (1:21:01.480)
the two have to be constrained in size
Lex Fridman (1:21:03.480)
makes it a hard problem.
Brian Kernighan (1:21:05.520)
Yeah, so Robert Frost says that poem
Lex Fridman (1:21:07.600)
where you had to choose two paths.
Lex Fridman (1:21:09.280)
So why did you,
Lex Fridman (1:21:12.200)
is there another alternate universe
Brian Kernighan (1:21:13.600)
in which you pursued the Don Knuth path
Lex Fridman (1:21:16.600)
of algorithm design, sort of?
Brian Kernighan (1:21:19.860)
Not smart enough.
Lex Fridman (1:21:21.480)
Not smart enough.
Brian Kernighan (1:21:25.480)
You're infinitely modest,
Lex Fridman (1:21:27.320)
but so you pursued your kind of love of programming.
Brian Kernighan (1:21:31.480)
I mean, when you look back to those,
Lex Fridman (1:21:33.640)
I mean, just looking into that world,
Brian Kernighan (1:21:35.320)
does that just seem like a distant world
Lex Fridman (1:21:37.840)
of theoretical computer science?
Brian Kernighan (1:21:40.360)
Then is it fundamentally different
Lex Fridman (1:21:42.080)
from the world of programming?
Brian Kernighan (1:21:44.680)
I don't know.
Lex Fridman (1:21:45.520)
I mean, certainly, in all seriousness,
Brian Kernighan (1:21:47.680)
I just didn't have the talent for it.
Lex Fridman (1:21:49.480)
When I got here as a grad student to Princeton
Lex Fridman (1:21:51.840)
and I started to think about research
Lex Fridman (1:21:53.520)
at the end of my, I don't know,
Brian Kernighan (1:21:55.040)
first year or something like that,
Lex Fridman (1:21:56.480)
I worked briefly with John Hopcroft,
Brian Kernighan (1:21:59.040)
who is absolutely, you know,
Lex Fridman (1:22:00.920)
you mentioned during award winner, et cetera,
Brian Kernighan (1:22:02.640)
a great guy, and it became crystal clear
Lex Fridman (1:22:05.440)
I was not cut out for this stuff, period, okay.
Lex Fridman (1:22:09.280)
And so I moved into things
Lex Fridman (1:22:11.520)
where I was more cut out for it,
Lex Fridman (1:22:13.600)
and that tended to be things like writing programs
Lex Fridman (1:22:16.840)
and then ultimately writing books.
Brian Kernighan (1:22:20.600)
You said that in Toronto as an undergrad,
Lex Fridman (1:22:22.920)
you did a senior thesis or a literature survey
Brian Kernighan (1:22:26.360)
on artificial intelligence.
Lex Fridman (1:22:28.720)
This was 1964.
Brian Kernighan (1:22:30.480)
Correct.
Lex Fridman (1:22:32.160)
What was the AI landscape, ideas, dreams at that time?
Brian Kernighan (1:22:37.080)
I think that was one of the,
Lex Fridman (1:22:39.080)
well, you've heard of AI winners.
Brian Kernighan (1:22:40.400)
This is whatever the opposite was,
Lex Fridman (1:22:41.800)
AI summer or something.
Brian Kernighan (1:22:43.640)
It was one of these things where people thought
Lex Fridman (1:22:46.000)
that, boy, we could do anything with computers,
Brian Kernighan (1:22:49.280)
that all these hard problems, we could,
Lex Fridman (1:22:51.520)
computers will solve them.
Brian Kernighan (1:22:52.720)
They will do machine translation.
Lex Fridman (1:22:54.400)
They will play games like chess.
Brian Kernighan (1:22:57.880)
They will do, you know, prove theorems in geometry.
Lex Fridman (1:23:02.160)
There are all kinds of examples like that
Brian Kernighan (1:23:04.160)
where people thought, boy,
Lex Fridman (1:23:06.560)
we could really do those sorts of things.
Brian Kernighan (1:23:09.880)
And, you know, I read The Kool Aid in some sense.
Lex Fridman (1:23:14.880)
There's a wonderful collection of papers
Brian Kernighan (1:23:16.920)
called Computers and Thought that was published
Lex Fridman (1:23:18.760)
in about that era and people were very optimistic.
Lex Fridman (1:23:22.520)
And then of course it turned out that
Lex Fridman (1:23:24.240)
what people thought was just a few years down the pike
Brian Kernighan (1:23:28.920)
was more than a few years down the pike.
Lex Fridman (1:23:31.320)
And some parts of that are more or less now
Brian Kernighan (1:23:34.600)
sort of under control.
Lex Fridman (1:23:36.400)
We finally do play games like Go and chess
Lex Fridman (1:23:38.960)
and so on better than people do,
Lex Fridman (1:23:41.160)
but there are others and machine translation
Brian Kernighan (1:23:43.600)
is a lot better than it used to be,
Lex Fridman (1:23:45.120)
but that's, you know, 50, close to 60 years of progress
Lex Fridman (1:23:49.720)
and a lot of evolution in hardware
Lex Fridman (1:23:51.360)
and a tremendous amount more data up on which
Brian Kernighan (1:23:53.360)
you can build systems that actually can learn
Lex Fridman (1:23:57.480)
from some of that data.
Lex Fridman (1:23:58.960)
And the infrastructure to support developers
Lex Fridman (1:24:02.600)
working together, like an open source movement,
Brian Kernighan (1:24:05.640)
the internet, period, is also empowering.
Lex Fridman (1:24:08.760)
But what lessons do you draw from that,
Lex Fridman (1:24:11.720)
the opposite of winter, that optimism?
Lex Fridman (1:24:14.760)
Well, I guess the lesson is that in the short run
Brian Kernighan (1:24:19.680)
it's pretty easy to be too pessimistic
Lex Fridman (1:24:23.520)
or maybe too optimistic and in the long run
Brian Kernighan (1:24:25.520)
you probably shouldn't be too pessimistic.
Lex Fridman (1:24:27.200)
I'm not saying that very well.
Brian Kernighan (1:24:28.600)
It reminds me of this remark from Arthur Clarke,
Lex Fridman (1:24:32.600)
a science fiction author, who says, you know,
Brian Kernighan (1:24:34.680)
when some distinguished but elderly person
Lex Fridman (1:24:36.560)
says that something is possible, he's probably right.
Lex Fridman (1:24:41.200)
And if he says it's impossible, he's almost surely wrong.
Lex Fridman (1:24:44.320)
But you don't know what the time scale is.
Brian Kernighan (1:24:45.760)
The time scale is critical, right.
Lex Fridman (1:24:48.320)
So what are your thoughts on this new summer of AI
Lex Fridman (1:24:52.520)
now in the work with machine learning and neural networks?
Lex Fridman (1:24:55.360)
You've kind of mentioned that you started to try to explore
Lex Fridman (1:24:57.880)
and look into this world that seems fundamentally different
Lex Fridman (1:25:01.400)
from the world of heuristics and algorithms like search,
Brian Kernighan (1:25:06.200)
that it's now purely sort of trying to take
Lex Fridman (1:25:08.960)
huge amounts of data and learn from that data, right,
Brian Kernighan (1:25:12.480)
programs from the data.
Lex Fridman (1:25:14.040)
Yeah, look, I think it's very interesting.
Brian Kernighan (1:25:17.000)
I am incredibly far from an expert.
Lex Fridman (1:25:19.800)
Most of what I know I've learned from my students
Lex Fridman (1:25:21.520)
and they're probably disappointed
Lex Fridman (1:25:24.520)
in how little I've learned from them.
Lex Fridman (1:25:26.360)
But I think it has tremendous potential
Lex Fridman (1:25:29.200)
for certain kinds of things.
Brian Kernighan (1:25:30.560)
I mean, games is one where it obviously has had an effect
Lex Fridman (1:25:34.640)
on some of the others as well.
Brian Kernighan (1:25:36.000)
I think there's, and this is speaking from
Lex Fridman (1:25:39.520)
definitely not expertise,
Brian Kernighan (1:25:40.680)
I think there are serious problems
Lex Fridman (1:25:42.360)
in certain kinds of machine learning at least
Brian Kernighan (1:25:45.480)
because what they're learning from
Lex Fridman (1:25:47.520)
is the data that we give them.
Lex Fridman (1:25:49.200)
And if the data we give them has something wrong with it,
Lex Fridman (1:25:52.080)
then what they learn from it is probably wrong too.
Lex Fridman (1:25:54.920)
And the obvious thing is some kind of bias in the data.
Lex Fridman (1:25:59.120)
That the data has stuff in it like, I don't know,
Brian Kernighan (1:26:02.360)
women aren't as good as men at something, okay.
Lex Fridman (1:26:05.440)
That's just flat wrong.
Lex Fridman (1:26:07.360)
But if it's in the data because of historical treatment,
Lex Fridman (1:26:11.480)
then that machine learning stuff will propagate that.
Lex Fridman (1:26:15.000)
And that is a serious worry.
Lex Fridman (1:26:18.120)
The positive part of that is what machine learning does
Brian Kernighan (1:26:22.680)
is reveal the bias in the data
Lex Fridman (1:26:24.680)
and puts a mirror to our own society.
Lex Fridman (1:26:27.040)
And in so doing helps us remove the bias,
Lex Fridman (1:26:30.920)
you know, helps us work on ourselves.
Brian Kernighan (1:26:33.880)
Puts a mirror to ourselves.
Lex Fridman (1:26:35.720)
Yeah, that's an optimistic point of view.
Lex Fridman (1:26:37.440)
And if it works that way, that would be absolutely great.
Lex Fridman (1:26:40.000)
And what I don't know is whether it does work that way
Brian Kernighan (1:26:42.560)
or whether the AI mechanisms
Lex Fridman (1:26:46.440)
or machine learning mechanisms reinforce
Lex Fridman (1:26:49.400)
and amplify things that have been wrong in the past.
Lex Fridman (1:26:52.640)
And I don't know, but I think that's a serious thing
Brian Kernighan (1:26:56.000)
that we have to be concerned about.
Lex Fridman (1:26:58.760)
Let me ask you an out there question, okay.
Brian Kernighan (1:27:01.200)
I know nobody knows, but what do you think it takes
Lex Fridman (1:27:03.920)
to build a system of human level intelligence?
Brian Kernighan (1:27:07.400)
That's been the dream from the 60s.
Lex Fridman (1:27:09.880)
We talk about games, about language,
Brian Kernighan (1:27:12.000)
about image recognition, but really the dream
Lex Fridman (1:27:16.360)
is to create human level or superhuman level intelligence.
Lex Fridman (1:27:19.600)
What do you think it takes to do that?
Lex Fridman (1:27:21.240)
And are we close?
Brian Kernighan (1:27:23.080)
I haven't a clue and I don't know, roughly speaking.
Lex Fridman (1:27:26.200)
I mean, this was Turing.
Brian Kernighan (1:27:27.040)
I was trying to trick you into a hypothesis.
Lex Fridman (1:27:30.040)
Yeah, I mean, Turing talked about this
Brian Kernighan (1:27:31.520)
in his paper on machine intelligence back in, geez,
Lex Fridman (1:27:34.960)
I don't know, early 50s or something like that.
Lex Fridman (1:27:36.840)
And he had the idea of the Turing test.
Lex Fridman (1:27:38.320)
And I don't know what the Turing test is.
Brian Kernighan (1:27:41.000)
It's a good test of intelligence.
Lex Fridman (1:27:41.960)
I don't know.
Brian Kernighan (1:27:42.800)
It's an interesting test.
Lex Fridman (1:27:43.640)
At least it's in some vague sense objective,
Brian Kernighan (1:27:45.800)
whether you can read anything into the conclusions
Lex Fridman (1:27:48.480)
is a different story.
Lex Fridman (1:27:50.440)
Do you have worries, concerns, excitement
Lex Fridman (1:27:55.160)
about the future of artificial intelligence?
Lex Fridman (1:27:57.000)
So there's a lot of people who are worried
Lex Fridman (1:27:58.920)
and you can speak broadly
Brian Kernighan (1:28:00.320)
than just artificial intelligence.
Lex Fridman (1:28:01.720)
It's basically computing taking over the world
Brian Kernighan (1:28:05.320)
in various forms.
Lex Fridman (1:28:06.760)
Are you excited by this future,
Brian Kernighan (1:28:09.240)
this possibility of computing being everywhere
Lex Fridman (1:28:12.320)
or are you worried?
Brian Kernighan (1:28:14.640)
It's some combination of those.
Lex Fridman (1:28:16.440)
I think almost all technologies over the long run
Brian Kernighan (1:28:21.200)
are for good, but there's plenty of examples
Lex Fridman (1:28:24.600)
where they haven't been good either over a long run
Brian Kernighan (1:28:27.840)
for some people or over a short run.
Lex Fridman (1:28:30.520)
And computing is one of those.
Lex Fridman (1:28:33.220)
And AI within it is gonna be one of those as well,
Lex Fridman (1:28:36.800)
but computing broadly.
Brian Kernighan (1:28:37.880)
I mean, for just a today example is privacy,
Lex Fridman (1:28:41.600)
that the use of things like social media and so on
Brian Kernighan (1:28:46.440)
means that, and the commercial surveillance
Lex Fridman (1:28:49.140)
means that there's an enormous amount more known about us
Brian Kernighan (1:28:52.480)
by people, other businesses, government, whatever,
Lex Fridman (1:28:56.920)
than perhaps one ought to feel comfortable with.
Lex Fridman (1:28:59.560)
So that's an example.
Lex Fridman (1:29:04.280)
So that's an example of a possible negative effect
Brian Kernighan (1:29:07.600)
of computing being everywhere.
Lex Fridman (1:29:09.700)
It's an interesting one
Brian Kernighan (1:29:11.160)
because it could also be a positive, if leveraged correctly.
Lex Fridman (1:29:16.160)
There's a big if there.
Lex Fridman (1:29:18.160)
So I have a deep interest in human psychology
Lex Fridman (1:29:22.980)
and humans seem to be very paranoid about this data thing
Brian Kernighan (1:29:27.360)
that varies depending on age group.
Lex Fridman (1:29:31.360)
It seems like the younger folks.
Lex Fridman (1:29:32.920)
So it's exciting to me to see what society looks like
Lex Fridman (1:29:35.940)
50 years from now, that the concerns about privacy
Brian Kernighan (1:29:39.280)
might be flipped on their head
Lex Fridman (1:29:40.640)
based purely on human psychology
Brian Kernighan (1:29:42.680)
versus actual concerns or not.
Lex Fridman (1:29:47.400)
What do you think about Moore's Law?
Brian Kernighan (1:29:49.560)
Well, you said a lot of stuff we've talked,
Lex Fridman (1:29:52.040)
you talked about programming languages in their design,
Brian Kernighan (1:29:55.760)
in their ideas that come from the constraints
Lex Fridman (1:29:58.760)
in the systems they operate in.
Lex Fridman (1:30:00.480)
Do you think Moore's Law,
Lex Fridman (1:30:04.360)
the exponential improvement of systems
Lex Fridman (1:30:07.160)
will continue indefinitely?
Lex Fridman (1:30:08.840)
There's a mix of opinions on that currently,
Lex Fridman (1:30:12.400)
or do you think there'll be a plateau?
Lex Fridman (1:30:19.260)
Well, the frivolous answer is no exponential
Brian Kernighan (1:30:21.600)
it can go on forever.
Lex Fridman (1:30:24.080)
You run out of something.
Brian Kernighan (1:30:26.120)
Just as we said, timescale matters.
Lex Fridman (1:30:27.760)
So if it goes on long enough, that might be all we need.
Brian Kernighan (1:30:30.880)
Yeah, right, won't matter to us.
Lex Fridman (1:30:33.320)
So I don't know, we've seen places
Brian Kernighan (1:30:34.680)
where Moore's Law has changed.
Lex Fridman (1:30:35.960)
For example, mentioned earlier,
Brian Kernighan (1:30:37.480)
processors don't get faster anymore,
Lex Fridman (1:30:41.320)
but you use that same growth of the ability
Brian Kernighan (1:30:46.120)
to put more things in a given area
Lex Fridman (1:30:48.080)
to grow them horizontally instead of vertically as it were
Lex Fridman (1:30:51.120)
so you can get more and more processors
Lex Fridman (1:30:52.960)
or memory or whatever on the same chip.
Lex Fridman (1:30:55.640)
Is that gonna run into a limitation?
Lex Fridman (1:30:57.440)
Presumably, because at some point
Brian Kernighan (1:31:00.680)
you get down to the individual atoms.
Lex Fridman (1:31:03.160)
And so you gotta find some way around that.
Lex Fridman (1:31:05.600)
Will we find some way around that?
Lex Fridman (1:31:07.840)
I don't know, I just said that if I say it won't,
Brian Kernighan (1:31:10.040)
I'll be wrong, so perhaps we will.
Lex Fridman (1:31:12.600)
So I just talked to Jim Keller and he says,
Lex Fridman (1:31:15.080)
so he actually describes, he argues
Lex Fridman (1:31:16.920)
that the Moore's Law will continue for a long, long time
Brian Kernighan (1:31:19.580)
because you mentioned the atom.
Lex Fridman (1:31:21.840)
We actually have, I think, a thousand fold increase,
Brian Kernighan (1:31:25.200)
still decreased in size, still possible
Lex Fridman (1:31:30.000)
before we get to the quantum level.
Lex Fridman (1:31:32.120)
So there's still a lot of possibilities.
Lex Fridman (1:31:34.760)
He thinks he'll continue indefinitely,
Brian Kernighan (1:31:36.460)
which is an interesting optimistic viewpoint.
Lex Fridman (1:31:40.720)
But how do you think the programming languages
Lex Fridman (1:31:43.480)
will change with this increase?
Lex Fridman (1:31:45.440)
Whether we hit a wall or not,
Lex Fridman (1:31:47.680)
what do you think, do you think there'll be
Lex Fridman (1:31:50.400)
a fundamental change in the way
Lex Fridman (1:31:51.840)
programming languages are designed?
Lex Fridman (1:31:54.500)
I don't know about that.
Brian Kernighan (1:31:55.400)
I think what will happen is continuation
Lex Fridman (1:31:58.600)
of what we see in some areas, at least,
Brian Kernighan (1:32:02.040)
which is that more programming will be done
Lex Fridman (1:32:05.500)
by programs than by people, and that more will be done
Brian Kernighan (1:32:11.000)
by sort of declarative rather than procedural mechanisms
Lex Fridman (1:32:14.960)
where I'll say, I want this to happen.
Brian Kernighan (1:32:17.360)
You figure out how.
Lex Fridman (1:32:19.820)
And that is, in many cases, at this point,
Brian Kernighan (1:32:24.240)
domain of specialized languages for narrow domains,
Lex Fridman (1:32:28.680)
but you can imagine that broadening out.
Lex Fridman (1:32:31.840)
And so I don't have to say so much, in so much detail,
Lex Fridman (1:32:35.660)
some collection of software, let's call it languages
Brian Kernighan (1:32:39.360)
or programs or something, will figure out
Lex Fridman (1:32:42.400)
how to do what I want to do.
Brian Kernighan (1:32:44.840)
Interesting, so increased levels of abstraction.
Lex Fridman (1:32:47.200)
Yeah.
Lex Fridman (1:32:48.920)
And one day getting to the human level,
Lex Fridman (1:32:51.040)
where we can just use natural language.
Brian Kernighan (1:32:52.680)
Could be possible.
Lex Fridman (1:32:54.600)
So you taught, so teach a course,
Brian Kernighan (1:32:56.800)
Computers in Our World, here at Princeton,
Lex Fridman (1:32:59.760)
that introduces computing and programming to nonmajors.
Brian Kernighan (1:33:03.880)
What, just from that experience,
Lex Fridman (1:33:06.800)
what advice do you have for people
Brian Kernighan (1:33:08.560)
who don't know anything about programming
Lex Fridman (1:33:10.600)
but are kind of curious about this world,
Brian Kernighan (1:33:12.960)
or programming seems to become more and more
Lex Fridman (1:33:14.800)
of a fundamental skill that people need to be
Lex Fridman (1:33:17.360)
at least aware of?
Lex Fridman (1:33:18.440)
Yeah, well, I couldn't recommend a good book.
Lex Fridman (1:33:20.400)
What's that?
Lex Fridman (1:33:22.040)
The book I wrote for the course.
Brian Kernighan (1:33:24.400)
I think this is one of these questions of,
Lex Fridman (1:33:26.840)
should everybody know how to program?
Lex Fridman (1:33:28.520)
And I think the answer is probably not,
Lex Fridman (1:33:31.300)
but I think everybody should at least understand
Brian Kernighan (1:33:33.000)
sort of what it is, so that if you say to somebody,
Lex Fridman (1:33:35.700)
I'm a programmer, they have a notion of what that might be,
Brian Kernighan (1:33:38.140)
or if you say this is a program,
Lex Fridman (1:33:40.160)
or this was decided by a computer running a program,
Brian Kernighan (1:33:43.600)
that they have some vague intuitive understanding
Lex Fridman (1:33:47.600)
and accurate understanding of what that might imply.
Lex Fridman (1:33:52.600)
So part of what I'm doing in this course,
Lex Fridman (1:33:55.180)
which is very definitely for nontechnical people,
Lex Fridman (1:33:57.480)
and a typical person in it is a history or English major,
Lex Fridman (1:34:01.200)
try and explain how computers work,
Lex Fridman (1:34:03.680)
how they do their thing, what programming is,
Lex Fridman (1:34:06.320)
how you write a program,
Lex Fridman (1:34:08.880)
and how computers talk to each other,
Lex Fridman (1:34:11.400)
and what do they do when they're talking to each other.
Lex Fridman (1:34:14.320)
And then I would say nobody, very rarely,
Lex Fridman (1:34:19.400)
and does anybody in that course go on
Brian Kernighan (1:34:21.920)
to become a real serious programmer,
Lex Fridman (1:34:24.200)
but at least they've got a somewhat better idea
Brian Kernighan (1:34:27.160)
of what all this stuff is about, not just the programming,
Lex Fridman (1:34:29.600)
but the technology behind computers and communications.
Lex Fridman (1:34:32.640)
Do they try and write a program themselves?
Lex Fridman (1:34:35.720)
Oh yeah, yeah, a very small amount.
Brian Kernighan (1:34:38.360)
I introduced them to how machines work at a level below,
Lex Fridman (1:34:42.200)
high level languages, so we have kind of a toy machine
Brian Kernighan (1:34:45.240)
that has a very small repertoire, a dozen instructions,
Lex Fridman (1:34:47.800)
and they write trivial assembly language programs for that.
Brian Kernighan (1:34:51.240)
Wow, that's interesting.
Lex Fridman (1:34:52.440)
So can you just, if you were to give a flavor
Brian Kernighan (1:34:55.080)
to people of the programming world,
Lex Fridman (1:34:57.680)
of the competing world,
Lex Fridman (1:34:59.480)
what are the examples they should go with?
Lex Fridman (1:35:01.920)
So a little bit of assembly to get a sense
Brian Kernighan (1:35:04.320)
at the lowest level of what the program is really doing.
Lex Fridman (1:35:08.800)
Yeah, I mean, in some sense,
Brian Kernighan (1:35:10.720)
there's no such thing as the lowest level
Lex Fridman (1:35:12.480)
because you can keep going down,
Lex Fridman (1:35:13.600)
but that's the place where I drew the line.
Lex Fridman (1:35:15.560)
So the idea that computers have a fairly small repertoire
Brian Kernighan (1:35:19.360)
of very simple instructions that they can do,
Lex Fridman (1:35:21.760)
like add and subtract and branch and so on,
Brian Kernighan (1:35:25.000)
as you mentioned earlier,
Lex Fridman (1:35:27.560)
and that you can write code at that level
Lex Fridman (1:35:31.520)
and it will get things done,
Lex Fridman (1:35:33.240)
and then you have the levels of abstraction
Brian Kernighan (1:35:35.520)
that we get with higher level languages,
Lex Fridman (1:35:37.800)
like Fortran or C or whatever,
Lex Fridman (1:35:39.880)
and that makes it easier to write the code
Lex Fridman (1:35:42.320)
and less dependent on particular architectures.
Lex Fridman (1:35:45.960)
And then we talk about a lot of the different kinds
Lex Fridman (1:35:48.040)
of programs that they use all the time
Brian Kernighan (1:35:50.640)
that they don't probably realize are programs,
Lex Fridman (1:35:52.760)
like they're running Mac OS on their computers
Brian Kernighan (1:35:57.640)
or maybe Windows, and they're downloading apps
Lex Fridman (1:36:00.240)
on their phones, and all of those things are programs
Brian Kernighan (1:36:03.000)
that are just what we just talked about,
Lex Fridman (1:36:05.960)
except at a grand scale.
Lex Fridman (1:36:08.160)
And it's easy to forget that they're actual programs
Lex Fridman (1:36:10.520)
that people program.
Brian Kernighan (1:36:11.840)
There's engineers that wrote those things.
Lex Fridman (1:36:14.080)
Yeah, right.
Lex Fridman (1:36:14.920)
And so in a way, I'm expecting them
Lex Fridman (1:36:18.920)
to make an enormous conceptual leap
Brian Kernighan (1:36:20.600)
from their five or 10 line toy assembly language thing
Lex Fridman (1:36:24.560)
that adds two or three numbers to something
Brian Kernighan (1:36:28.280)
that is a browser on their phone or whatever,
Lex Fridman (1:36:31.040)
but it's really the same thing.
Lex Fridman (1:36:34.520)
So if you look in broad strokes at history,
Lex Fridman (1:36:38.320)
what do you think the world,
Lex Fridman (1:36:39.720)
how do you think the world changed because of computers?
Lex Fridman (1:36:42.840)
It's hard to sometimes see the big picture
Brian Kernighan (1:36:45.200)
when you're in it, but I guess I'm asking
Lex Fridman (1:36:48.040)
if there's something you've noticed over the years
Brian Kernighan (1:36:51.520)
that, like you were mentioning,
Lex Fridman (1:36:54.560)
the students are more distracted looking at their,
Brian Kernighan (1:36:56.820)
now there's a device to look at.
Lex Fridman (1:36:58.520)
Right.
Brian Kernighan (1:36:59.360)
I think computing has changed a tremendous amount,
Lex Fridman (1:37:01.600)
obviously, but I think one aspect of that
Brian Kernighan (1:37:03.800)
is the way that people interact with each other,
Lex Fridman (1:37:06.480)
both locally and far away.
Lex Fridman (1:37:08.880)
And when I was the age of those kids,
Lex Fridman (1:37:12.240)
making a phone call to somewhere was a big deal
Brian Kernighan (1:37:15.120)
because it costs serious money.
Lex Fridman (1:37:17.280)
And this was in the 60s, right?
Lex Fridman (1:37:20.520)
And today people don't make phone calls,
Lex Fridman (1:37:22.920)
they send texts or something like that.
Lex Fridman (1:37:25.720)
So there's an up and down in what people do.
Lex Fridman (1:37:29.520)
People think nothing of having correspondence,
Brian Kernighan (1:37:34.120)
regular meetings, video, whatever,
Lex Fridman (1:37:36.560)
with friends or family or whatever
Brian Kernighan (1:37:38.680)
in any other part of the world,
Lex Fridman (1:37:40.400)
and they don't think about that at all.
Lex Fridman (1:37:43.100)
And so that's just the communication aspect of it.
Lex Fridman (1:37:49.120)
Do you think that brings us closer together
Brian Kernighan (1:37:51.000)
or does it make us,
Lex Fridman (1:37:53.760)
does it take us away from the closeness
Lex Fridman (1:37:57.900)
of human to human contact?
Lex Fridman (1:37:59.140)
I think it depends a lot on all kinds of things.
Lex Fridman (1:38:02.820)
So I trade mail with my brother and sister in Canada
Lex Fridman (1:38:05.820)
much more often than I used to talk to them on the phone.
Lex Fridman (1:38:08.820)
So probably every two or three days,
Lex Fridman (1:38:10.700)
I get something or send something to them.
Brian Kernighan (1:38:14.380)
Whereas 20 years ago,
Lex Fridman (1:38:16.940)
I probably wouldn't have talked to them
Brian Kernighan (1:38:19.260)
on the phone nearly as much.
Lex Fridman (1:38:20.600)
So in that sense, that's brought my brother and sister
Lex Fridman (1:38:23.060)
and I closer together.
Lex Fridman (1:38:24.020)
That's a good thing.
Brian Kernighan (1:38:25.860)
I watch the kids on campus
Lex Fridman (1:38:28.660)
and they're mostly walking around with their heads down,
Brian Kernighan (1:38:30.980)
fooling with their phones
Lex Fridman (1:38:32.260)
to the point where I have to duck them.
Brian Kernighan (1:38:34.900)
I don't know that that has brought them closer together
Lex Fridman (1:38:39.460)
in some ways.
Brian Kernighan (1:38:40.500)
There's sociological research that says people are,
Lex Fridman (1:38:43.740)
in fact, not as close together as they used to be.
Brian Kernighan (1:38:46.220)
I don't know where that's really true,
Lex Fridman (1:38:47.620)
but I can see potential downsides
Lex Fridman (1:38:50.780)
and kids where you think,
Lex Fridman (1:38:53.220)
come on, wake up and smell the coffee or whatever.
Brian Kernighan (1:38:56.780)
That's right.
Lex Fridman (1:38:57.620)
But if you look at, again, nobody can predict the future,
Lex Fridman (1:39:00.380)
but are you excited?
Lex Fridman (1:39:02.620)
Kind of touched this a little bit with AI,
Lex Fridman (1:39:04.780)
but are you excited by the future in the next 10, 20 years
Lex Fridman (1:39:08.740)
that computing will bring?
Brian Kernighan (1:39:11.540)
You were there when there was no computers really.
Lex Fridman (1:39:15.700)
And now computers are everywhere all over the world
Lex Fridman (1:39:19.420)
and Africa and Asia and just every person,
Lex Fridman (1:39:23.060)
almost every person in the world has a device.
Lex Fridman (1:39:25.580)
So are you hopeful, optimistic about that future?
Lex Fridman (1:39:30.740)
It's mixed, if the truth be told.
Brian Kernighan (1:39:32.420)
I mean, I think there are some things about that
Lex Fridman (1:39:34.140)
that are good.
Brian Kernighan (1:39:34.980)
I think there's the potential for people
Lex Fridman (1:39:36.740)
to improve their lives all over the place
Lex Fridman (1:39:39.140)
and that's obviously good.
Lex Fridman (1:39:40.940)
And at the same time, at least in the short run,
Brian Kernighan (1:39:44.260)
you can see lots and lots of bad
Lex Fridman (1:39:45.900)
as people become more tribalistic or parochial
Brian Kernighan (1:39:49.420)
in their interests and it's an enormous amount
Lex Fridman (1:39:51.780)
more us than them and people are using computers
Brian Kernighan (1:39:54.820)
in all kinds of ways to mislead or misrepresent
Lex Fridman (1:39:58.060)
or flat out lie about what's going on
Lex Fridman (1:39:59.900)
and that is affecting politics locally
Lex Fridman (1:40:02.300)
and I think everywhere in the world.
Brian Kernighan (1:40:05.580)
Yeah, the long term effect on political systems
Lex Fridman (1:40:08.900)
and so on is who knows.
Brian Kernighan (1:40:10.860)
Who knows indeed.
Lex Fridman (1:40:11.860)
The people now have a voice which is a powerful thing.
Brian Kernighan (1:40:18.620)
People who are oppressed have a voice
Lex Fridman (1:40:21.020)
but also everybody has a voice
Lex Fridman (1:40:24.060)
and the chaos that emerges from that
Lex Fridman (1:40:25.580)
is fascinating to watch.
Brian Kernighan (1:40:26.820)
Yeah, yeah, it's kind of scary.
Lex Fridman (1:40:30.260)
If you can go back and relive a moment in your life,
Brian Kernighan (1:40:33.700)
one that made you truly happy outside of family
Lex Fridman (1:40:37.520)
or was profoundly transformative,
Brian Kernighan (1:40:40.060)
is there a moment or moments that jump out at you
Lex Fridman (1:40:44.340)
from memory?
Brian Kernighan (1:40:46.140)
I don't think specific moments.
Lex Fridman (1:40:48.040)
I think there were lots and lots and lots of good times
Brian Kernighan (1:40:50.340)
at Bell Labs where you would build something
Lex Fridman (1:40:52.500)
and it worked.
Lex Fridman (1:40:55.820)
Did you say it worked?
Lex Fridman (1:40:56.740)
So the moment it worked.
Brian Kernighan (1:40:57.940)
Yeah, and somebody used it and they said,
Lex Fridman (1:41:00.300)
gee, that's neat.
Brian Kernighan (1:41:01.260)
Those kinds of things happened quite often
Lex Fridman (1:41:04.640)
in that sort of golden era in the 70s when Unix was young
Lex Fridman (1:41:09.260)
and there was all this low hanging fruit
Lex Fridman (1:41:11.420)
and interesting things to work on
Lex Fridman (1:41:13.420)
and a group of people who kind of,
Lex Fridman (1:41:16.140)
we were all together in this and if you did something,
Brian Kernighan (1:41:18.900)
they would try it out for you.
Lex Fridman (1:41:20.580)
And I think that was in some sense,
Brian Kernighan (1:41:22.820)
a really, really good time.
Lex Fridman (1:41:24.500)
And AUK was, was AUK an example of that?
Lex Fridman (1:41:27.460)
That when you built it and people used it?
Lex Fridman (1:41:29.400)
Yeah, absolutely.
Lex Fridman (1:41:30.420)
And now millions of people use it.
Lex Fridman (1:41:32.700)
And all your stupid mistakes are right there
Lex Fridman (1:41:34.540)
for them to look at, right?
Lex Fridman (1:41:36.500)
So it's mixed.
Brian Kernighan (1:41:37.460)
Yeah, it's terrifying, vulnerable
Lex Fridman (1:41:39.140)
but it's beautiful because it does have a positive impact
Brian Kernighan (1:41:42.020)
on so, so many people.
Lex Fridman (1:41:43.840)
So I think there's no better way to end it.
Brian Kernighan (1:41:47.220)
Brian, thank you so much for talking to us, it was an honor.
Lex Fridman (1:41:49.420)
Okay, my pleasure.
Brian Kernighan (1:41:51.260)
Good fun.
Lex Fridman (1:41:52.080)
Thank you for listening to this conversation
Brian Kernighan (1:41:55.340)
with Brian Kernighan and thank you to our sponsors,
Lex Fridman (1:41:58.500)
8 Sleep Mattress and Raycon Earbuds.
Brian Kernighan (1:42:02.380)
Please consider supporting this podcast
Lex Fridman (1:42:05.100)
by going to 8sleep.com slash Lex and to buyraycon.com
Brian Kernighan (1:42:10.820)
slash Lex, click the links, buy the stuff.
Lex Fridman (1:42:14.520)
These both are amazing products.
Brian Kernighan (1:42:16.760)
It really is the best way to support this podcast
Lex Fridman (1:42:19.300)
and the journey I'm on.
Brian Kernighan (1:42:21.140)
It's how they know I sent you and increases the chance
Lex Fridman (1:42:24.700)
that they'll actually support this podcast in the future.
Brian Kernighan (1:42:27.660)
If you enjoy this thing, subscribe on YouTube,
Lex Fridman (1:42:30.260)
review it with 5 Stars and Apple Podcast,
Brian Kernighan (1:42:32.620)
support it on Patreon or connect with me on Twitter
Lex Fridman (1:42:35.940)
at Lex Friedman, spelled somehow miraculously
Brian Kernighan (1:42:40.060)
without the letter E, just F R I D M A N
Lex Fridman (1:42:44.100)
because when we immigrated to this country,
Brian Kernighan (1:42:46.600)
we were not so good at spelling.
Lex Fridman (1:42:49.020)
And now let me leave you with some words
Brian Kernighan (1:42:51.340)
from Brian Kernighan, don't comment bad code, rewrite it.
Lex Fridman (1:42:56.200)
Thank you for listening and hope to see you next time.
Lex Fridman (20:01.160)
but not really, but of course, quickly,
Lex Fridman (20:03.600)
that is now, you could think of most of the computers
Lex Fridman (20:07.080)
in the world run on a Unix like system?
Lex Fridman (20:10.560)
Right.
Lex Fridman (20:12.800)
How do you interpret, like,
Lex Fridman (20:14.240)
if you kind of zoom from the alien perspective,
Brian Kernighan (20:16.480)
if you were just observing Earth,
Lex Fridman (20:18.360)
and all of a sudden these computers took over the world
Lex Fridman (20:20.960)
and they started from this little initial seed of Unix,
Lex Fridman (20:24.800)
how does that make you feel?
Brian Kernighan (20:26.600)
It's quite surprising.
Lex Fridman (20:27.640)
And you asked earlier about prediction.
Brian Kernighan (20:30.280)
The answer is no.
Lex Fridman (20:31.120)
There's no way you could predict that kind of evolution.
Lex Fridman (20:33.960)
And I don't know whether it was inevitable
Lex Fridman (20:37.120)
or just a whole sequence of blind luck.
Brian Kernighan (20:39.080)
I suspect more of the latter.
Lex Fridman (20:40.920)
And so I look at it and think, gee, that's kind of neat.
Lex Fridman (20:45.320)
I think the real question is what does Ken think about that?
Lex Fridman (20:49.000)
Because he's the guy arguably from whom it really came.
Brian Kernighan (20:53.000)
You know, tremendous contributions from Dennis Ritchie
Lex Fridman (20:55.240)
and then others around in that Bell Labs environment.
Brian Kernighan (20:58.200)
But, you know, if you had to pick a single person,
Lex Fridman (21:01.160)
that would be Ken.
Lex Fridman (21:02.560)
So you've written a new book,
Lex Fridman (21:04.320)
Unix, a history and a memoir.
Brian Kernighan (21:06.320)
Are there some memorable human stories,
Lex Fridman (21:08.960)
funny or profound from that time
Lex Fridman (21:10.680)
that just kind of stand out?
Lex Fridman (21:12.160)
Oh, there's a lot of them in his book.
Brian Kernighan (21:14.000)
Oh, there's a lot of them in a sense.
Lex Fridman (21:15.680)
And again, it's a question of can you resurrect them
Lex Fridman (21:18.160)
in real time?
Lex Fridman (21:19.000)
Never.
Brian Kernighan (21:19.840)
His memory fails.
Lex Fridman (21:21.720)
But I think part of it was that Bell Labs at the time
Brian Kernighan (21:25.040)
was a very special kind of place to work
Lex Fridman (21:27.040)
because there were a lot of interesting people
Lex Fridman (21:28.960)
and the environment was very, very open and free.
Lex Fridman (21:31.720)
It was a very cooperative environment,
Brian Kernighan (21:33.280)
very friendly environment.
Lex Fridman (21:34.360)
And so if you had an interesting problem,
Brian Kernighan (21:35.960)
you go and talk to somebody
Lex Fridman (21:37.160)
and they might help you with the solution.
Lex Fridman (21:40.600)
And it was a kind of a fun environment too,
Lex Fridman (21:43.800)
in which people did strange things
Lex Fridman (21:46.680)
and often tweaking the bureaucracy in one way or another.
Lex Fridman (21:52.440)
So rebellious in certain kinds of ways.
Brian Kernighan (21:54.960)
In some ways, yeah, absolutely.
Lex Fridman (21:56.720)
I think most people didn't take too kindly
Brian Kernighan (21:58.880)
to the bureaucracy and I'm sure the bureaucracy
Lex Fridman (22:01.560)
put up with an enormous amount
Brian Kernighan (22:03.840)
that they didn't really want to.
Lex Fridman (22:06.000)
So maybe to linger on it a little bit,
Lex Fridman (22:09.520)
do you have a sense of what the philosophy
Lex Fridman (22:11.840)
that characterizes Unix is, the design?
Brian Kernighan (22:15.320)
Not just the initial, but just carry through the years,
Lex Fridman (22:18.880)
just being there, being around it.
Lex Fridman (22:20.640)
What's the fundamental philosophy behind the system?
Lex Fridman (22:23.320)
I think one aspect of fundamental philosophy
Brian Kernighan (22:25.600)
was to provide an environment that made it easy to write
Lex Fridman (22:29.120)
or easier, productive to write programs.
Lex Fridman (22:31.960)
So it was meant as a programmer environment.
Lex Fridman (22:33.720)
It wasn't meant specifically as something
Brian Kernighan (22:36.080)
to do some other kind of job.
Lex Fridman (22:38.400)
For example, it was used extensively for word processing,
Lex Fridman (22:41.400)
but it wasn't designed as a word processing system.
Lex Fridman (22:43.720)
It was used extensively for lab control,
Lex Fridman (22:45.800)
but it wasn't designed for that.
Lex Fridman (22:47.320)
It was used extensively as a front end
Brian Kernighan (22:49.480)
for big other systems, big dumb systems,
Lex Fridman (22:52.440)
but it wasn't designed for that.
Brian Kernighan (22:53.800)
It was meant to be an environment
Lex Fridman (22:55.640)
where it was really easy to write programs.
Lex Fridman (22:57.960)
So the programmers could be highly productive.
Lex Fridman (23:00.680)
And part of that was to be a community.
Lex Fridman (23:03.120)
And there's some observation from Dennis Ritchie,
Lex Fridman (23:05.760)
I think at the end of the book,
Brian Kernighan (23:06.840)
that says that from his standpoint,
Lex Fridman (23:09.720)
the real goal was to create a community
Brian Kernighan (23:11.920)
where people could work as programmers on a system.
Lex Fridman (23:17.160)
And I think in that sense, certainly for many, many years,
Brian Kernighan (23:19.600)
it succeeded quite well at that.
Lex Fridman (23:22.520)
And part of that is the technical aspects
Brian Kernighan (23:25.040)
of because it made it really easy to write programs,
Lex Fridman (23:27.600)
people did write interesting programs.
Brian Kernighan (23:29.520)
Those programs tended to be used by other programmers.
Lex Fridman (23:32.000)
And so it was kind of a virtuous circle
Brian Kernighan (23:34.600)
of more and more stuff coming up
Lex Fridman (23:36.560)
that was really good for programmers.
Lex Fridman (23:39.360)
And you were part of that community of programmers.
Lex Fridman (23:41.800)
So what was it like writing programs in that early Unix?
Brian Kernighan (23:45.760)
It was a blast.
Lex Fridman (23:46.600)
It really was.
Brian Kernighan (23:50.000)
You know, I like to program.
Lex Fridman (23:51.120)
I'm not a terribly good programmer,
Lex Fridman (23:52.800)
but it was a lot of fun to write code.
Lex Fridman (23:55.260)
And in the early days, there was an enormous amount
Brian Kernighan (23:57.520)
of what you would today, I suppose,
Lex Fridman (23:59.000)
called low hanging fruit.
Brian Kernighan (24:00.100)
People hadn't done things before.
Lex Fridman (24:02.520)
And this was this new environment
Lex Fridman (24:04.320)
and the whole combination of nice tools
Lex Fridman (24:07.640)
and very responsive system and tremendous colleagues
Brian Kernighan (24:11.560)
made it possible to write code.
Lex Fridman (24:13.640)
You could have an idea in the morning.
Brian Kernighan (24:16.440)
You could do an experiment with it.
Lex Fridman (24:19.080)
You could have something limping along that night
Brian Kernighan (24:21.320)
or the next day and people would react to it.
Lex Fridman (24:23.600)
And they would say, oh, that's wonderful,
Lex Fridman (24:25.920)
but you're really screwed up here.
Lex Fridman (24:27.800)
And the feedback loop was then very, very short and tight.
Lex Fridman (24:31.680)
And so a lot of things got developed fairly quickly
Lex Fridman (24:34.960)
that in many cases still exist today.
Lex Fridman (24:39.920)
And I think that was part of what made it fun
Lex Fridman (24:43.240)
because programming itself is fun.
Brian Kernighan (24:44.680)
It's puzzle solving in a variety of ways,
Lex Fridman (24:46.900)
but I think it's even more fun when you do something
Brian Kernighan (24:50.000)
that somebody else then uses.
Lex Fridman (24:52.320)
Even if they whine about it not working,
Brian Kernighan (24:54.600)
the fact that they used it is part of the reward mechanism.
Lex Fridman (24:58.560)
And what was the method of interaction,
Lex Fridman (25:00.480)
the communication, that feedback loop?
Lex Fridman (25:03.640)
I mean, this is before the internet.
Brian Kernighan (25:05.440)
Certainly before the internet.
Lex Fridman (25:07.520)
It was mostly physical right there.
Brian Kernighan (25:11.640)
Somebody would come into your office and say something.
Lex Fridman (25:13.680)
So these places are all close by,
Brian Kernighan (25:15.280)
like offices are nearby, so really lively interaction.
Lex Fridman (25:18.960)
Yeah, yeah.
Brian Kernighan (25:19.800)
Bell Labs was fundamentally one giant building
Lex Fridman (25:22.040)
and most of the people were involved in this unique stuff.
Brian Kernighan (25:24.400)
We're in two or three quarters and there was a room.
Lex Fridman (25:27.640)
Oh, how big was it?
Brian Kernighan (25:29.400)
Probably call it 50 feet by 50 feet.
Lex Fridman (25:33.480)
Make up a number of that which had some access
Brian Kernighan (25:37.320)
to computers there as well as in offices
Lex Fridman (25:39.980)
and people hung out there and it had a coffee machine.
Lex Fridman (25:42.920)
And so it was mostly very physical.
Lex Fridman (25:46.340)
We did use email, of course.
Lex Fridman (25:49.440)
But it was fundamentally, for a long time,
Lex Fridman (25:52.720)
all on one machine.
Lex Fridman (25:54.120)
So there was no need for internet.
Lex Fridman (25:56.520)
It's fascinating to think about what computing
Brian Kernighan (25:58.660)
would be today without Bell Labs.
Lex Fridman (26:00.920)
It seems so many, the people being in the vicinity
Brian Kernighan (26:05.000)
of each other, sort of getting that quick feedback,
Lex Fridman (26:08.480)
working together, so many brilliant people.
Brian Kernighan (26:11.440)
I don't know where else that could have existed
Lex Fridman (26:13.200)
in the world given how that came together.
Brian Kernighan (26:18.000)
Yeah, how does that make you feel
Lex Fridman (26:19.720)
that little element of history?
Brian Kernighan (26:23.200)
Well, I think that's very nice,
Lex Fridman (26:24.600)
but in a sense it's survivor bias
Lex Fridman (26:26.760)
and if it hadn't happened at Bell Labs,
Lex Fridman (26:29.240)
there were other places that were doing
Brian Kernighan (26:31.000)
really interesting work as well.
Lex Fridman (26:32.880)
Xerox PARC is perhaps the most obvious one.
Brian Kernighan (26:35.040)
Xerox PARC contributed an enormous amount
Lex Fridman (26:36.760)
of good material and many of the things
Brian Kernighan (26:39.120)
we take for granted today in the same way
Lex Fridman (26:41.520)
came from Xerox PARC experience.
Brian Kernighan (26:43.360)
I don't think they capitalized in the long run as much.
Lex Fridman (26:46.440)
Their parent company was perhaps not as lucky
Lex Fridman (26:49.800)
in capitalizing on this, who knows?
Lex Fridman (26:52.800)
But that's certainly another place
Brian Kernighan (26:55.000)
where there was a tremendous amount of influence.
Lex Fridman (26:58.060)
There were a lot of good university activities.
Brian Kernighan (27:00.240)
MIT was obviously no slouch in this kind of thing
Lex Fridman (27:03.720)
and others as well.
Lex Fridman (27:07.120)
So Unix turned out to be open source
Lex Fridman (27:10.660)
because of the various ways that AT&T operated
Lex Fridman (27:13.560)
and sort of it had to, the focus was on telephones.
Lex Fridman (27:19.000)
I think that's a mischaracterization in a sense.
Brian Kernighan (27:21.580)
It absolutely was not open source.
Lex Fridman (27:23.840)
It was very definitely proprietary, licensed,
Lex Fridman (27:27.840)
but it was licensed freely to universities
Lex Fridman (27:30.840)
in source code form for many years.
Lex Fridman (27:33.520)
And because of that, generations of university students
Lex Fridman (27:37.680)
and their faculty people grew up knowing about Unix
Lex Fridman (27:41.760)
and there was enough expertise in the community
Lex Fridman (27:44.720)
that it then became possible for people
Brian Kernighan (27:46.640)
to kind of go off in their own direction
Lex Fridman (27:48.120)
and build something that looked Unix like.
Brian Kernighan (27:51.520)
The Berkeley version of Unix started with that licensed code
Lex Fridman (27:56.520)
and gradually picked up enough of its own code contributions,
Brian Kernighan (28:01.680)
notably from people like Bill Joy,
Lex Fridman (28:04.000)
that eventually it was able to become completely free
Brian Kernighan (28:08.600)
of any AT&T code.
Lex Fridman (28:10.480)
Now, there was an enormous amount of legal jockeying
Brian Kernighan (28:13.120)
around this in the late, early to late 80s, early 90s,
Lex Fridman (28:17.400)
something like that.
Lex Fridman (28:19.480)
And then, I guess the open source movement
Lex Fridman (28:24.480)
might've started when Richard Stallman started
Brian Kernighan (28:27.600)
to think about this in the late 80s.
Lex Fridman (28:29.240)
And by 1991, when Torvalds decided he was going
Brian Kernighan (28:33.200)
to do a Unix like operating system,
Lex Fridman (28:37.040)
there was enough expertise in the community
Brian Kernighan (28:40.440)
that first he had a target, he could see what to do
Lex Fridman (28:44.280)
because the kind of the Unix system call interface
Lex Fridman (28:47.480)
and the tools and so on were there.
Lex Fridman (28:50.720)
And so he was able to build an operating system
Brian Kernighan (28:53.440)
that at this point, when you say Unix,
Lex Fridman (28:56.160)
in many cases, what you're really thinking is Linux.
Brian Kernighan (28:58.400)
Linux, yeah.
Lex Fridman (28:59.280)
But it's funny that from my distant perception,
Brian Kernighan (29:02.880)
I felt that Unix was open source
Lex Fridman (29:05.720)
without actually knowing it.
Lex Fridman (29:07.440)
But what you're really saying, it was just freely licensed.
Lex Fridman (29:11.560)
It was freely licensed.
Lex Fridman (29:12.960)
So it felt open source in a sense
Lex Fridman (29:14.880)
because universities are not trying to make money,
Lex Fridman (29:16.960)
so it felt open source in a sense
Lex Fridman (29:19.000)
that you can get access if you wanted.
Brian Kernighan (29:20.520)
Right, and a very, very, very large number of universities
Lex Fridman (29:23.640)
had the license and they were able to talk
Brian Kernighan (29:25.240)
to all the other universities who had the license.
Lex Fridman (29:27.360)
And so technically not open,
Brian Kernighan (29:30.200)
technically belonging to AT&T, pragmatically pretty open.
Lex Fridman (29:34.880)
And so there's a ripple effect
Brian Kernighan (29:36.080)
that all the faculty and the students then all grew up
Lex Fridman (29:39.000)
and then they went throughout the world
Lex Fridman (29:41.840)
and permeated in that kind of way.
Lex Fridman (29:45.420)
So what kind of features do you think make
Lex Fridman (29:49.820)
for a good operating system?
Lex Fridman (29:52.560)
If you take the lessons of Unix,
Brian Kernighan (29:54.920)
you said make it easy for programmers.
Lex Fridman (29:59.440)
That seems to be an important one.
Lex Fridman (30:03.840)
But also Unix turned out to be exceptionally robust
Lex Fridman (30:07.000)
and efficient.
Brian Kernighan (30:08.180)
Right.
Lex Fridman (30:09.020)
So is that an accident when you focus on the programmer
Lex Fridman (30:12.120)
or is that a natural outcome?
Lex Fridman (30:14.760)
I think part of the reason for efficiency
Brian Kernighan (30:17.560)
was that it began on extremely modest hardware,
Lex Fridman (30:21.160)
very, very, very tiny.
Lex Fridman (30:22.600)
And so you couldn't get carried away.
Lex Fridman (30:24.000)
You couldn't do a lot of complicated things
Brian Kernighan (30:27.740)
because you just didn't have the resources,
Lex Fridman (30:30.000)
either processor speed or memory.
Lex Fridman (30:32.400)
And so that enforced a certain minimality of mechanisms
Lex Fridman (30:37.800)
and maybe a search for generalizations
Lex Fridman (30:40.080)
so that you would find one mechanism
Lex Fridman (30:41.840)
that served for a lot of different things
Brian Kernighan (30:43.520)
rather than having lots of different special cases.
Lex Fridman (30:45.900)
I think the file system in Unix is a good example
Brian Kernighan (30:48.800)
of that file system interface in its fundamental form
Lex Fridman (30:51.460)
is extremely straightforward.
Lex Fridman (30:53.600)
And that means that you can write code
Lex Fridman (30:56.560)
very, very effectively for the file system.
Lex Fridman (30:58.920)
And then one of those ideas, one of those generalizations
Lex Fridman (31:02.720)
is that gee, that file system interface works
Brian Kernighan (31:04.840)
for all kinds of other things as well.
Lex Fridman (31:06.780)
And so in particular, the idea of reading
Lex Fridman (31:09.240)
and writing to devices is the same as reading
Lex Fridman (31:11.600)
and writing to a disc that has a file system.
Lex Fridman (31:14.480)
And then that gets carried further in other parts
Lex Fridman (31:17.880)
of the world.
Brian Kernighan (31:18.700)
Processes become, in effect, files in a file system.
Lex Fridman (31:24.240)
And the Plan 9 operating system, which came along,
Brian Kernighan (31:26.440)
I guess, in the late 80s or something like that,
Lex Fridman (31:29.320)
took a lot of those ideas from the original Unix
Lex Fridman (31:31.520)
and tried to push the generalization even further
Lex Fridman (31:34.720)
so that in Plan 9, a lot of different resources
Brian Kernighan (31:37.180)
are file systems.
Lex Fridman (31:38.180)
They all share that interface.
Lex Fridman (31:40.040)
So that would be one example where finding the right model
Lex Fridman (31:44.360)
of how to do something means that an awful lot of things
Brian Kernighan (31:46.800)
become simpler, and it means, therefore,
Lex Fridman (31:48.840)
that more people can do useful, interesting things
Brian Kernighan (31:51.200)
with them without having to think as hard about it.
Lex Fridman (31:54.440)
So you said you're not a very good programmer.
Brian Kernighan (31:56.960)
That's true.
Lex Fridman (31:58.480)
You're the most modest human being, okay,
Lex Fridman (32:01.400)
but you'll continue saying that.
Lex Fridman (32:03.280)
I understand how this works.
Lex Fridman (32:04.420)
But you do radiate a sort of love for programming.
Lex Fridman (32:07.760)
So let me ask, do you think programming
Lex Fridman (32:10.840)
is more an art or a science?
Lex Fridman (32:13.240)
Is it creativity or kind of rigor?
Brian Kernighan (32:16.640)
I think it's some of each.
Lex Fridman (32:18.080)
It's some combination.
Brian Kernighan (32:20.800)
Some of the art is figuring out what it is
Lex Fridman (32:22.680)
that you really want to do.
Lex Fridman (32:23.720)
What should that program be?
Lex Fridman (32:25.520)
What would make a good program?
Lex Fridman (32:27.560)
And that's some understanding of what the task is,
Lex Fridman (32:30.640)
what the people who might use this program want.
Lex Fridman (32:33.600)
And I think that's art in many respects.
Lex Fridman (32:37.760)
The science part is trying to figure out how to do it well.
Lex Fridman (32:40.480)
And some of that is real computer sciencey stuff,
Lex Fridman (32:45.240)
like what algorithm should we use at some point?
Brian Kernighan (32:48.080)
Mostly in the sense of being careful to use algorithms
Lex Fridman (32:52.320)
that will actually work properly, scale properly,
Brian Kernighan (32:56.240)
avoiding quadratic algorithms
Lex Fridman (32:58.000)
when a linear algorithm should be the right thing,
Brian Kernighan (33:01.280)
that kind of more formal view of it.
Lex Fridman (33:04.080)
Same thing for data structures.
Lex Fridman (33:06.380)
But also it's, I think, an engineering field as well.
Lex Fridman (33:10.360)
And engineering is not quite the same as science
Brian Kernighan (33:12.480)
because engineering, you're working with constraints.
Lex Fridman (33:15.320)
You have to figure out not only what
Brian Kernighan (33:19.200)
is a good algorithm for this kind of thing,
Lex Fridman (33:21.080)
but what's the most appropriate algorithm given
Brian Kernighan (33:23.240)
the amount of time we have to compute,
Lex Fridman (33:26.200)
the amount of time we have to program,
Brian Kernighan (33:28.000)
what's likely to happen in the future with maintenance,
Lex Fridman (33:30.880)
who's going to pick this up in the future, all
Brian Kernighan (33:33.280)
of those kind of things that if you're an engineer,
Lex Fridman (33:35.840)
you get to worry about.
Brian Kernighan (33:37.240)
Whereas if you think of yourself as a scientist,
Lex Fridman (33:39.160)
well, you can maybe push them over the horizon in a way.
Lex Fridman (33:42.080)
And if you're an artist, what's that?
Lex Fridman (33:45.360)
So just on your own personal level,
Lex Fridman (33:48.600)
what's your process like of writing a program?
Lex Fridman (33:50.640)
Say, a small and large sort of tinkering with stuff.
Lex Fridman (33:55.840)
Do you just start coding right away
Lex Fridman (33:58.000)
and just kind of evolve iteratively with a loose notion?
Brian Kernighan (34:03.040)
Or do you plan on a sheet of paper first
Lex Fridman (34:05.760)
and then kind of design in what they teach you
Brian Kernighan (34:09.320)
in the kind of software engineering courses
Lex Fridman (34:12.040)
in undergrad or something like that?
Lex Fridman (34:13.600)
What's your process like?
Lex Fridman (34:14.880)
It's certainly much more the informal incremental.
Brian Kernighan (34:17.480)
First, I don't write big programs at this point.
Lex Fridman (34:19.880)
It's been a long time since I wrote a program that
Brian Kernighan (34:21.880)
was more than I call it a few hundred or more lines,
Lex Fridman (34:25.560)
something like that.
Brian Kernighan (34:26.960)
Many of the programs I write are experiments
Lex Fridman (34:29.080)
for either something I'm curious about
Brian Kernighan (34:31.680)
or often for something that I want to talk about in a class.
Lex Fridman (34:34.680)
So those necessarily tend to be relatively small.
Brian Kernighan (34:38.920)
A lot of the kind of code I write these days
Lex Fridman (34:41.400)
tends to be for sort of exploratory data analysis
Brian Kernighan (34:44.280)
where I've got some collection of data
Lex Fridman (34:46.200)
and I want to try and figure out what on earth is going on in it.
Lex Fridman (34:49.160)
And for that, those programs tend to be very small.
Lex Fridman (34:52.280)
Sometimes you're not even programming.
Brian Kernighan (34:53.920)
You're just using existing tools like counting things.
Lex Fridman (34:57.720)
Or sometimes you're writing OX scripts
Brian Kernighan (35:00.200)
because two or three lines will tell you
Lex Fridman (35:02.360)
something about a piece of data.
Lex Fridman (35:03.960)
And then when it gets bigger, well, then I
Lex Fridman (35:05.640)
will probably write something in Python
Brian Kernighan (35:08.800)
because that scales better up to call it a few hundred lines
Lex Fridman (35:13.200)
or something like that.
Lex Fridman (35:14.240)
And it's been a long time since I wrote programs
Lex Fridman (35:16.320)
that were much more than that.
Lex Fridman (35:18.600)
Speaking of data exploration and OX, first, what is OX?
Lex Fridman (35:23.680)
So OX is a scripting language that
Brian Kernighan (35:25.680)
was done by myself, Al Aho, and Peter Weinberger.
Lex Fridman (35:30.280)
We did that originally in the late 70s.
Brian Kernighan (35:32.240)
It was a language that was meant to make it really easy
Lex Fridman (35:34.800)
to do quick and dirty tasks like counting things
Brian Kernighan (35:39.360)
or selecting interesting information from basically
Lex Fridman (35:43.680)
all text files, rearranging it in some way or summarizing it.
Brian Kernighan (35:47.640)
It runs a command on each line of a file.
Lex Fridman (35:51.480)
I mean, it's still exceptionally widely used today.
Brian Kernighan (35:55.480)
Oh, absolutely.
Lex Fridman (35:56.280)
Yeah.
Brian Kernighan (35:56.800)
It's so simple and elegant, sort of the way to explore data.
Lex Fridman (36:01.480)
Turns out you can just write a script that
Brian Kernighan (36:03.320)
does something seemingly trivial in a single line,
Lex Fridman (36:07.120)
and giving you that slice of the data
Brian Kernighan (36:09.880)
somehow reveals something fundamental about the data.
Lex Fridman (36:13.200)
And that seems to work still.
Brian Kernighan (36:17.040)
Yeah, it's very good for that kind of thing.
Lex Fridman (36:19.640)
That's sort of what it was meant for.
Brian Kernighan (36:21.200)
I think what we didn't appreciate
Lex Fridman (36:22.600)
was that the model was actually quite good for a lot of data
Brian Kernighan (36:26.240)
processing kinds of tasks and that it's
Lex Fridman (36:29.040)
kept going as long as it has because at this point,
Brian Kernighan (36:31.440)
it's over 40 years old, and it's still, I think, a useful tool.
Lex Fridman (36:35.920)
And well, this is paternal interest, I guess.
Lex Fridman (36:38.400)
But I think in terms of programming languages,
Lex Fridman (36:40.960)
you get the most bang for the buck by learning AUC.
Lex Fridman (36:44.240)
And it doesn't scale the big programs,
Lex Fridman (36:46.560)
but it does pretty darn well on these little things
Brian Kernighan (36:49.920)
where you just want to see all the somethings in something.
Lex Fridman (36:53.760)
So yeah, I probably write more AUC than anything else
Brian Kernighan (36:56.960)
at this point.
Lex Fridman (36:58.640)
So what kind of stuff do you love about AUC?
Brian Kernighan (37:01.160)
Is there, if you can comment on sort of things
Lex Fridman (37:06.240)
that give you joy when you can, in a simple program,
Brian Kernighan (37:10.200)
reveal something about the data.
Lex Fridman (37:11.560)
Is there something that stands out from particular features?
Brian Kernighan (37:14.520)
I think it's mostly the selection of default behaviors.
Lex Fridman (37:19.440)
You sort of hinted at it a moment ago.
Lex Fridman (37:21.080)
What AUC does is to read through a set of files,
Lex Fridman (37:24.760)
and then within each file, it writes
Brian Kernighan (37:26.640)
through each of the lines.
Lex Fridman (37:28.400)
And then on each of the lines, it has a set of patterns
Brian Kernighan (37:31.760)
that it looks for.
Lex Fridman (37:33.120)
That's your AUC program.
Lex Fridman (37:34.720)
And if one of the patterns matches,
Lex Fridman (37:36.920)
there is a corresponding action that you might perform.
Lex Fridman (37:40.000)
And so it's kind of a quadruply nested loop or something
Lex Fridman (37:43.960)
like that.
Lex Fridman (37:45.160)
And that's all completely automatic.
Lex Fridman (37:46.620)
You don't have to say anything about it.
Brian Kernighan (37:48.280)
You just write the pattern and the action,
Lex Fridman (37:49.960)
and then run the data by it.
Lex Fridman (37:52.120)
And so that paradigm for programming
Lex Fridman (37:54.240)
is a very natural and effective one.
Lex Fridman (37:56.880)
And I think we captured that reasonably well in AUC.
Lex Fridman (38:00.160)
And it does other things for free as well.
Brian Kernighan (38:01.960)
It splits the data into fields so that on each line,
Lex Fridman (38:05.320)
there is fields separated by white space or something.
Lex Fridman (38:07.640)
And so it does that for free.
Lex Fridman (38:08.840)
You don't have to say anything about it.
Lex Fridman (38:11.200)
And it collects information as it goes along,
Lex Fridman (38:13.840)
like what line are we on?
Lex Fridman (38:15.360)
How many fields are there on this line?
Lex Fridman (38:18.040)
So lots of things that just make it so that a program which
Brian Kernighan (38:21.160)
in another language, let's say Python,
Lex Fridman (38:24.080)
would be five, 10, 20 lines in AUC is one or two lines.
Lex Fridman (38:28.040)
And so because it's one or two lines,
Lex Fridman (38:29.600)
you can do it on the shell.
Brian Kernighan (38:31.840)
You don't have to open up another whole thing.
Lex Fridman (38:33.720)
You can just do it right there in the interaction
Brian Kernighan (38:35.920)
with the operatives directly.
Lex Fridman (38:38.920)
Is there other shell commands that you love over the years
Lex Fridman (38:44.880)
like you really enjoy using?
Lex Fridman (38:46.320)
Oh, grep.
Lex Fridman (38:47.360)
Grep?
Lex Fridman (38:47.920)
Grep's the only one.
Brian Kernighan (38:49.720)
Yeah, grep does everything.
Lex Fridman (38:51.440)
So grep is a simpler version of AUC, I would say?
Brian Kernighan (38:55.360)
In some sense, yeah, right.
Lex Fridman (38:58.000)
What is grep?
Lex Fridman (38:58.880)
So grep basically searches the input
Lex Fridman (39:01.840)
for particular patterns, regular expressions,
Brian Kernighan (39:04.000)
technically, of a certain class.
Lex Fridman (39:06.160)
And it has that same paradigm that AUC does.
Brian Kernighan (39:08.640)
It's a pattern action thing.
Lex Fridman (39:10.080)
It reads through all the files and then
Brian Kernighan (39:12.080)
all the lines in each file.
Lex Fridman (39:13.480)
But it has a single pattern, which
Brian Kernighan (39:15.200)
is the regular expression you're looking for,
Lex Fridman (39:17.040)
and a single action printed if it matches.
Lex Fridman (39:20.240)
So in that sense, it's a much simpler version.
Lex Fridman (39:22.600)
And you could write grep in AUC as a one liner.
Lex Fridman (39:26.800)
And I use grep probably more than anything else
Lex Fridman (39:30.440)
at this point just because it's so convenient and natural.
Lex Fridman (39:35.000)
Why do you think it's such a powerful tool, grep and AUC?
Lex Fridman (39:38.640)
Why do you think operating systems like Windows,
Lex Fridman (39:41.280)
for example, don't have it?
Lex Fridman (39:45.240)
You can, of course, I use, which is amazing now,
Brian Kernighan (39:48.240)
there's Windows for Linux.
Lex Fridman (39:50.120)
So which you could basically use all the fun stuff
Brian Kernighan (39:54.880)
like AUC and grep inside of Windows.
Lex Fridman (39:57.320)
But Windows naturally, as part of the graphical interface,
Brian Kernighan (40:00.800)
the simplicity of grep, searching
Lex Fridman (40:03.200)
through a bunch of files and just popping up naturally.
Lex Fridman (40:06.560)
Why do you think that's unique to the Linux environment?
Lex Fridman (40:11.560)
I don't know.
Brian Kernighan (40:12.400)
It's not strictly unique, but it's certainly focused there.
Lex Fridman (40:16.400)
And I think some of it's the weight of history
Brian Kernighan (40:19.080)
that Windows came from MS DOS.
Lex Fridman (40:22.040)
MS DOS was a pretty pathetic operating system,
Brian Kernighan (40:24.520)
although common on an unboundedly large number
Lex Fridman (40:27.760)
of machines.
Lex Fridman (40:28.960)
But somewhere in roughly the 90s,
Lex Fridman (40:32.840)
Windows became a graphical system.
Lex Fridman (40:34.680)
And I think Microsoft spent a lot of their energy
Lex Fridman (40:37.960)
on making that graphical interface what it is.
Lex Fridman (40:41.600)
And that's a different model of computing.
Lex Fridman (40:44.160)
It's a model of computing where you point and click
Lex Fridman (40:47.120)
and sort of experiment with menus.
Lex Fridman (40:49.480)
It's a model of computing works rather well for people
Brian Kernighan (40:53.160)
who are not programmers and just want to get something done,
Lex Fridman (40:56.080)
whereas teaching something like the command line
Brian Kernighan (40:59.080)
to nonprogrammers turns out to sometimes be
Lex Fridman (41:01.760)
an uphill struggle.
Lex Fridman (41:02.720)
And so I think Microsoft probably
Lex Fridman (41:04.400)
was right in what they did.
Brian Kernighan (41:06.240)
Now you mentioned Whistle or whatever
Lex Fridman (41:07.920)
it's called, the Winix, Linux.
Brian Kernighan (41:09.520)
Whistle.
Lex Fridman (41:10.040)
I wonder what it's pronounced.
Brian Kernighan (41:11.480)
WSL is what I've never actually pronounced.
Lex Fridman (41:13.120)
Whistle, I like it.
Brian Kernighan (41:13.920)
I have no idea.
Lex Fridman (41:15.880)
But there have been things like that for longest.
Brian Kernighan (41:17.880)
Cygwin, for example, which is a wonderful collection of take
Lex Fridman (41:21.320)
all your favorite tools from Unix and Linux
Lex Fridman (41:23.320)
and just make them work perfectly on Windows.
Lex Fridman (41:25.440)
And so that's something that's been going on
Brian Kernighan (41:27.320)
for at least 20 years, if not longer.
Lex Fridman (41:29.920)
And I use that on my one remaining Windows machine
Brian Kernighan (41:34.600)
routinely because if you're doing something that
Lex Fridman (41:37.960)
is batch computing, suitable for command line,
Brian Kernighan (41:41.360)
that's the right way to do it.
Lex Fridman (41:42.700)
Because the Windows equivalents are, if nothing else,
Brian Kernighan (41:45.160)
not familiar to me.
Lex Fridman (41:47.760)
But I would definitely recommend to people
Brian Kernighan (41:50.200)
if they don't use Cygwin to try Whistle.
Lex Fridman (41:52.440)
Yes.
Brian Kernighan (41:54.240)
I've been so excited that I could write scripts quickly
Lex Fridman (41:59.600)
in Windows.
Brian Kernighan (42:00.560)
It's changed my life.
Lex Fridman (42:03.160)
OK, what's your perfect programming setup?
Lex Fridman (42:06.400)
What computer, what operating system, what keyboard,
Lex Fridman (42:09.080)
what editor?
Brian Kernighan (42:10.440)
Yeah, perfect is too strong a word.
Lex Fridman (42:13.320)
It's way too strong a word.
Lex Fridman (42:15.280)
What I use by default, I have, at this point,
Lex Fridman (42:18.880)
a 13 inch MacBook Air, which I use
Brian Kernighan (42:22.000)
because it's kind of a reasonable balance
Lex Fridman (42:24.240)
of the various things I need.
Brian Kernighan (42:25.400)
I can carry it around.
Lex Fridman (42:26.600)
It's got enough computing, horsepower, screen's
Brian Kernighan (42:28.400)
big enough, keyboard's OK.
Lex Fridman (42:31.080)
And so I basically do most of my computing on that.
Brian Kernighan (42:34.640)
I have a big iMac in my office that I use from time to time
Lex Fridman (42:38.840)
as well, especially when I need a big screen,
Lex Fridman (42:41.020)
but otherwise, it tends not to be used that much.
Lex Fridman (42:47.080)
Editor.
Brian Kernighan (42:48.320)
I use mostly SAM, which is an editor that Rob Pike wrote
Lex Fridman (42:52.600)
long ago at Bell Labs.
Brian Kernighan (42:56.080)
Sorry to interrupt.
Lex Fridman (42:56.960)
Does that precede VI?
Lex Fridman (42:58.680)
Does that precede iMac?
Lex Fridman (43:00.040)
It post dates both VI and iMacs.
Brian Kernighan (43:04.000)
It is derived from Rob's experience with ED and VI.
Lex Fridman (43:11.120)
What's ED?
Brian Kernighan (43:12.760)
That's the original Unix editor.
Lex Fridman (43:14.600)
Oh, wow.
Brian Kernighan (43:16.520)
Dated probably before you were born.
Lex Fridman (43:19.600)
So actually, what's the history of editors?
Lex Fridman (43:23.480)
Can you briefly, because it's such a fact.
Lex Fridman (43:26.680)
I use Emacs, I'm sorry to say.
Brian Kernighan (43:28.840)
Sorry to come out with that.
Lex Fridman (43:30.280)
But what's the kind of interplay there?
Lex Fridman (43:33.640)
So in ancient times, call it the first time sharing systems,
Lex Fridman (43:39.280)
going back to what we were talking about.
Brian Kernighan (43:41.800)
There was an editor on CTSS that I don't even
Lex Fridman (43:44.560)
remember what it was called.
Brian Kernighan (43:45.760)
It might have been edit, where you could type text, program
Lex Fridman (43:50.280)
text, and it would do something, or document text.
Brian Kernighan (43:53.760)
You could save the text.
Lex Fridman (43:54.960)
And save it.
Brian Kernighan (43:55.560)
You could edit it.
Lex Fridman (43:57.240)
The usual thing that you would get in an editor.
Lex Fridman (44:00.200)
And Ken Thompson wrote an editor called QED, which
Lex Fridman (44:04.080)
was very, very powerful.
Lex Fridman (44:05.960)
But these were all totally A, command based.
Lex Fridman (44:08.680)
They were not mouse or cursor based,
Brian Kernighan (44:10.760)
because it was before mice and even before cursors,
Lex Fridman (44:13.720)
because they were running on terminals that printed on paper.
Brian Kernighan (44:17.000)
No CRT type displays, let alone LEDs.
Lex Fridman (44:21.280)
And so then when Unix came along, Ken took QED
Lex Fridman (44:26.080)
and stripped it way, way, way, way down.
Lex Fridman (44:28.680)
And that became an editor that he called ED.
Lex Fridman (44:30.960)
And it was very simple.
Lex Fridman (44:31.960)
But it was a line oriented editor.
Lex Fridman (44:33.800)
And so you could load a file.
Lex Fridman (44:36.080)
And then you could talk about the lines one
Brian Kernighan (44:38.120)
through the last line.
Lex Fridman (44:39.240)
And you could print ranges of lines.
Brian Kernighan (44:41.600)
You could add text.
Lex Fridman (44:43.080)
You could delete text.
Brian Kernighan (44:44.000)
You could change text.
Lex Fridman (44:44.880)
Or you could do a substitute command
Brian Kernighan (44:46.440)
that would change things within a line or within groups
Lex Fridman (44:48.800)
of lines.
Lex Fridman (44:49.280)
So you can work on parts of a file, essentially.
Lex Fridman (44:51.320)
Yeah.
Brian Kernighan (44:51.480)
You can work on any part of it, the whole thing or whatever.
Lex Fridman (44:54.000)
But it was entirely command line based.
Lex Fridman (44:57.320)
And it was entirely on paper.
Lex Fridman (45:00.800)
Paper.
Lex Fridman (45:01.560)
And that meant that you changed it.
Lex Fridman (45:02.960)
Yeah, right.
Brian Kernighan (45:03.480)
Real paper.
Lex Fridman (45:04.080)
And so if you changed a line, you
Brian Kernighan (45:06.240)
had to print that line using up another line of paper
Lex Fridman (45:09.120)
to see what the change caused.
Lex Fridman (45:12.920)
So when CRT displays came along, then you
Lex Fridman (45:18.320)
could start to use cursor control.
Lex Fridman (45:19.760)
And you could sort of move where you were on the screen.
Lex Fridman (45:24.200)
Without reprinting every time.
Brian Kernighan (45:26.080)
Without reprinting.
Lex Fridman (45:27.000)
And there were a number of editors there.
Brian Kernighan (45:29.880)
The one that I was most familiar with and still use
Lex Fridman (45:32.720)
is VI, which was done by Bill Choi.
Lex Fridman (45:35.160)
And so that dates from probably the late 70s, as I guess.
Lex Fridman (45:40.760)
And it took full advantage of the cursor controls.
Brian Kernighan (45:45.200)
I suspect that Emacs was roughly at the same time.
Lex Fridman (45:48.360)
But I don't know.
Brian Kernighan (45:49.040)
I've never internalized Emacs.
Lex Fridman (45:51.760)
So at this point, I stopped using ED, although I still can.
Brian Kernighan (45:56.320)
I use VI sometimes, and I use SAM when I can.
Lex Fridman (46:00.120)
And SAM is available on most systems?
Brian Kernighan (46:02.480)
It is available.
Lex Fridman (46:04.320)
You have to download it yourself from, typically,
Brian Kernighan (46:06.360)
the Plan 9 operating system distribution.
Lex Fridman (46:08.520)
It's been maintained by people there.
Lex Fridman (46:11.800)
And so I'll get home tonight.
Lex Fridman (46:13.600)
I'll try it.
Brian Kernighan (46:14.280)
It's cool.
Lex Fridman (46:14.800)
It sounds fascinating.
Brian Kernighan (46:17.800)
Although my love is with Lisp and Emacs,
Lex Fridman (46:20.600)
I've went into that hippie world of.
Brian Kernighan (46:25.120)
I think it's a lot of things.
Lex Fridman (46:26.280)
Religion, where you're brought up with.
Brian Kernighan (46:27.760)
Yeah, that's true.
Lex Fridman (46:28.760)
That's true.
Brian Kernighan (46:29.280)
Most of the actual programming I do is C, C++, and Python.
Lex Fridman (46:34.080)
But my weird sort of, yeah, my religious upbringing is in Lisp.
Lex Fridman (46:38.160)
So can you take on the impossible task
Lex Fridman (46:41.840)
and give a brief history of programming languages
Lex Fridman (46:44.760)
from your perspective?
Lex Fridman (46:46.440)
So I guess you could say programming languages started
Brian Kernighan (46:48.800)
probably in, what, the late 40s or something like that.
Lex Fridman (46:52.000)
People used to program computers by basically putting
Brian Kernighan (46:55.200)
in zeros and ones.
Lex Fridman (46:56.240)
Using something like switches on a console.
Lex Fridman (46:59.760)
And then, or maybe holes in paper tapes.
Lex Fridman (47:03.560)
Something like that.
Lex Fridman (47:04.920)
So extremely tedious, awful, whatever.
Lex Fridman (47:08.040)
And so I think the first programming languages
Brian Kernighan (47:10.280)
were relatively crude assembly languages,
Lex Fridman (47:14.560)
where people would basically write
Brian Kernighan (47:17.840)
a program that would convert mnemonics like add ADD
Lex Fridman (47:22.360)
into whatever the bit pattern was
Brian Kernighan (47:24.920)
that corresponded to an ADD instruction.
Lex Fridman (47:26.800)
And they would do the clerical work of figuring out
Brian Kernighan (47:28.960)
where things were.
Lex Fridman (47:30.080)
So you could put a name on a location in a program,
Lex Fridman (47:32.840)
and the assembler would figure out
Lex Fridman (47:34.920)
where that corresponded to when the thing was all put together
Lex Fridman (47:37.920)
and dropped into memory.
Lex Fridman (47:40.760)
And early on, and this would be the late 40s and very early
Brian Kernighan (47:46.280)
50s, there were assemblers written for the various machines
Lex Fridman (47:50.040)
that people used.
Brian Kernighan (47:51.040)
You may have seen in the paper just a couple of days ago,
Lex Fridman (47:53.460)
Tony Berker died.
Brian Kernighan (47:54.240)
He did this thing in Manchester called AutoCode, a language
Lex Fridman (47:58.720)
which I knew only by name.
Lex Fridman (48:01.000)
But it sounds like it was a flavor of assembly language,
Lex Fridman (48:04.400)
sort of a little higher in some ways.
Lex Fridman (48:06.680)
And it replaced a language that Alan Turing wrote,
Lex Fridman (48:09.040)
which you put in zeros and ones.
Lex Fridman (48:10.840)
But you put it in backwards order,
Lex Fridman (48:12.480)
because that was a hardware word.
Brian Kernighan (48:14.400)
Very strange.
Lex Fridman (48:14.920)
That's right.
Brian Kernighan (48:15.480)
Yeah, yeah, that's right.
Lex Fridman (48:16.520)
Backwards.
Lex Fridman (48:17.880)
So assembly languages, let's call that the early 1950s.
Lex Fridman (48:22.320)
And so every different flavor of computer
Brian Kernighan (48:24.280)
has its own assembly language.
Lex Fridman (48:25.800)
So the EDSAC had its, and the Manchester had its,
Lex Fridman (48:28.920)
and the IBM whatever, 790 or 704, or whatever had its,
Lex Fridman (48:33.640)
and so on.
Lex Fridman (48:34.240)
So everybody had their own assembly language.
Lex Fridman (48:36.080)
And assembly languages have a few commands, additions,
Brian Kernighan (48:38.760)
subtraction, then branching of some kind,
Lex Fridman (48:41.160)
if then type of situation.
Brian Kernighan (48:42.920)
Right, they have exactly, in their simplest form at least,
Lex Fridman (48:46.720)
one instruction per, or one assembly language instruction
Brian Kernighan (48:50.000)
per instruction in the machine's repertoire.
Lex Fridman (48:52.880)
And so you have to know the machine intimately
Brian Kernighan (48:54.920)
to be able to write programs in it.
Lex Fridman (48:56.760)
And if you write an assembly language program
Brian Kernighan (48:58.640)
for one kind of machine, and then you say,
Lex Fridman (49:00.440)
gee, it's nice, I'd like a different machine, start over.
Brian Kernighan (49:03.920)
OK, so very bad.
Lex Fridman (49:06.160)
And so what happened in the late 50s
Brian Kernighan (49:08.680)
was people realized you could play this game again,
Lex Fridman (49:10.960)
and you could move up a level in writing or creating languages
Brian Kernighan (49:15.480)
that were closer to the way that real people might think
Lex Fridman (49:18.000)
about how to write code.
Lex Fridman (49:20.680)
And there were, I guess, arguably three or four
Lex Fridman (49:24.080)
at that time period.
Brian Kernighan (49:25.600)
There was FORTRAN, which came from IBM,
Lex Fridman (49:28.080)
which was formula translation, meant
Brian Kernighan (49:29.960)
to make it easy to do scientific and engineering
Lex Fridman (49:32.240)
computations.
Brian Kernighan (49:32.840)
I didn't know that, formula translation, that's wow.
Lex Fridman (49:34.920)
That's what I stood for.
Brian Kernighan (49:35.680)
There was COBOL, which is the Common Business Oriented
Lex Fridman (49:37.880)
Language that Grace Hopper and others worked on,
Brian Kernighan (49:40.920)
which was aimed at business kinds of tasks.
Lex Fridman (49:44.200)
There was ALGOL, which was mostly
Brian Kernighan (49:45.680)
meant to describe algorithmic computations.
Lex Fridman (49:49.280)
I guess you could argue BASIC was in there somewhere.
Brian Kernighan (49:51.440)
I think it's just a little later.
Lex Fridman (49:54.400)
And so all of those moved the level up,
Lex Fridman (49:56.360)
and so they were closer to what you and I might think of
Lex Fridman (49:59.920)
as we were trying to write a program.
Lex Fridman (50:02.520)
And they were focused on different domains, FORTRAN
Lex Fridman (50:06.400)
for formula translation, engineering computations,
Brian Kernighan (50:09.160)
let's say COBOL for business, that kind of thing.
Lex Fridman (50:11.640)
And still used today, at least FORTRAN probably.
Brian Kernighan (50:14.520)
Oh, yeah, COBOL, too.
Lex Fridman (50:16.760)
But the deal was that once you moved up that level,
Brian Kernighan (50:19.440)
then you, let's call it FORTRAN, you
Lex Fridman (50:21.120)
had a language that was not tied to a particular kind
Brian Kernighan (50:24.640)
of hardware, because a different compiler would compile
Lex Fridman (50:26.840)
for a different kind of hardware.
Lex Fridman (50:28.180)
And that meant two things.
Lex Fridman (50:30.080)
It meant you only had to write the program once, which
Brian Kernighan (50:32.360)
is very important.
Lex Fridman (50:33.920)
And it meant that you could, in fact,
Brian Kernighan (50:35.960)
if you were a random engineer, physicist, whatever,
Lex Fridman (50:38.240)
you could write that program yourself.
Brian Kernighan (50:39.800)
You didn't have to hire a programmer to do it for you.
Lex Fridman (50:42.240)
It might not be as good as you'd get with a real programmer,
Lex Fridman (50:44.500)
but it was pretty good.
Lex Fridman (50:45.840)
And so it democratized and made much more broadly available
Brian Kernighan (50:49.640)
the ability to write code.
Lex Fridman (50:51.440)
So it puts the power of programming
Brian Kernighan (50:53.080)
into the hands of people like you.
Lex Fridman (50:54.600)
Yeah, anybody who is willing to invest some time in learning
Brian Kernighan (50:58.480)
a programming language and is not then tied
Lex Fridman (51:00.720)
to a particular kind of computer.
Lex Fridman (51:03.520)
And then in the 70s, you get system programming languages,
Lex Fridman (51:06.280)
of which C is the survivor.
Lex Fridman (51:08.480)
And what does system programming language mean?
Lex Fridman (51:11.840)
Programs that, programming languages
Brian Kernighan (51:14.920)
that would take on the kinds of things
Lex Fridman (51:16.560)
that were necessary to write so called system programs.
Brian Kernighan (51:19.360)
Things like text editors, or assemblers, or compilers,
Lex Fridman (51:22.720)
or operating systems themselves.
Brian Kernighan (51:24.920)
Those kinds of things.
Lex Fridman (51:26.600)
And Fortran.
Brian Kernighan (51:28.000)
They have to be feature rich.
Lex Fridman (51:29.160)
They have to be able to do a lot of stuff.
Brian Kernighan (51:30.960)
A lot of memory management, access processes,
Lex Fridman (51:33.640)
and all that kind of stuff.
Brian Kernighan (51:35.600)
It's a different flavor of what they're doing.
Lex Fridman (51:37.560)
They're much more in touch with the actual machine,
Lex Fridman (51:41.200)
but in a positive way.
Lex Fridman (51:42.360)
That is, you can talk about memory in a more controlled
Brian Kernighan (51:44.760)
way.
Lex Fridman (51:45.880)
You can talk about the different data types
Brian Kernighan (51:48.000)
that the machine supports, and more ways
Lex Fridman (51:52.760)
to structure and organize data.
Lex Fridman (51:54.840)
And so the system programming languages,
Lex Fridman (51:57.360)
there was a lot of effort in that in the,
Brian Kernighan (51:59.720)
call it the late 60s, early 70s.
Lex Fridman (52:02.120)
C is, I think, the only real survivor of that.
Lex Fridman (52:06.240)
And then what happens after that?
Lex Fridman (52:09.000)
You get things like object oriented programming languages.
Brian Kernighan (52:12.080)
Because as you write programs in a language like C,
Lex Fridman (52:14.880)
at some point scale gets to you.
Lex Fridman (52:16.520)
And it's too hard to keep track of the pieces.
Lex Fridman (52:18.440)
And there's no guardrails, or training wheels,
Brian Kernighan (52:21.040)
or something like that to prevent you
Lex Fridman (52:22.480)
from doing bad things.
Lex Fridman (52:24.320)
So C++ comes out of that tradition.
Lex Fridman (52:28.200)
And then it took off from there.
Brian Kernighan (52:29.560)
I mean, there's also a parallel, slightly parallel track
Lex Fridman (52:32.160)
with a little bit of functional stuff with Lisp and so on.
Lex Fridman (52:35.080)
But I guess from that point, it's
Lex Fridman (52:37.080)
just an explosion of languages.
Brian Kernighan (52:38.920)
There's the Java story.
Lex Fridman (52:40.040)
There's the JavaScript.
Brian Kernighan (52:41.880)
There's all the stuff that the cool kids these days
Lex Fridman (52:44.960)
are doing with Rust and all that.
Lex Fridman (52:48.320)
So what's to you?
Lex Fridman (52:50.120)
You wrote a book, C Programming Language.
Lex Fridman (52:53.080)
And C is probably one of the most important languages
Lex Fridman (52:56.920)
in the history of programming languages,
Brian Kernighan (52:58.840)
if you kind of look at impact.
Lex Fridman (53:01.080)
What do you think is the most elegant or powerful part of C?
Lex Fridman (53:06.240)
Why did it survive?
Lex Fridman (53:07.560)
Why did it have such a long lasting impact?
Brian Kernighan (53:11.280)
I think it found a sweet spot of expressiveness,
Lex Fridman (53:16.280)
so that you could rewrite things in a pretty natural way,
Lex Fridman (53:19.080)
and efficiency, which was particularly important when
Lex Fridman (53:22.400)
computers were not nearly as powerful as they are today.
Brian Kernighan (53:25.160)
You've got to put yourself back 50 years,
Lex Fridman (53:28.880)
almost, in terms of what computers could do.
Lex Fridman (53:31.240)
And that's roughly four or five generations,
Lex Fridman (53:35.000)
decades of Moore's law, right?
Lex Fridman (53:37.520)
So expressiveness and efficiency and, I don't know,
Lex Fridman (53:42.960)
perhaps the environment that it came with as well,
Brian Kernighan (53:45.040)
which was Unix.
Lex Fridman (53:46.360)
So it meant if you wrote a program,
Brian Kernighan (53:47.920)
it could be used on all those computers that ran Unix.
Lex Fridman (53:50.520)
And that was all of those computers,
Brian Kernighan (53:51.960)
because they were all written in C.
Lex Fridman (53:53.440)
And that was Unix, the operating system itself,
Brian Kernighan (53:56.560)
was portable, as were all the tools.
Lex Fridman (53:58.640)
So it all worked together, again,
Brian Kernighan (54:00.720)
in one of these things where things
Lex Fridman (54:02.720)
fit on each other in a positive cycle.
Lex Fridman (54:05.920)
What did it take to write sort of a definitive book,
Lex Fridman (54:10.000)
probably definitive book on all of program,
Brian Kernighan (54:11.960)
like it's more definitive to a particular language
Lex Fridman (54:14.480)
than any other book on any other language,
Lex Fridman (54:16.640)
and did two really powerful things,
Lex Fridman (54:19.000)
which is popularized the language,
Brian Kernighan (54:22.720)
at least from my perspective, maybe you can correct me.
Lex Fridman (54:24.880)
And second is created a standard of how, you know,
Lex Fridman (54:29.880)
how this language is supposed to be used and applied.
Lex Fridman (54:33.640)
So what did it take?
Brian Kernighan (54:34.960)
Did you have those kinds of ambitions in mind
Lex Fridman (54:37.400)
when working on that?
Lex Fridman (54:38.240)
Is this some kind of joke?
Lex Fridman (54:39.640)
No, of course not.
Lex Fridman (54:42.840)
So it's an accident of timing, skill, and just luck?
Lex Fridman (54:48.440)
A lot of it is, clearly.
Brian Kernighan (54:50.360)
Timing was good.
Lex Fridman (54:51.520)
Now, Dennis and I wrote the book in 1977.
Brian Kernighan (54:54.040)
Dennis Ritchie.
Lex Fridman (54:54.880)
Yeah, right.
Lex Fridman (54:56.440)
And at that point, Unix was starting to spread.
Lex Fridman (54:58.920)
I don't know how many there were,
Lex Fridman (55:00.040)
but it would be dozens to hundreds of Unix systems.
Lex Fridman (55:03.320)
And C was also available on other kinds of computers
Brian Kernighan (55:06.680)
that had nothing to do with Unix.
Lex Fridman (55:08.320)
And so the language had some potential.
Lex Fridman (55:13.520)
And there were no other books on C,
Lex Fridman (55:17.720)
and Bell Labs was really the only source for it.
Lex Fridman (55:20.360)
And Dennis, of course, was authoritative
Lex Fridman (55:22.560)
because it was his language.
Lex Fridman (55:23.920)
And he had written the reference manual,
Lex Fridman (55:26.800)
which is a marvelous example
Brian Kernighan (55:28.040)
of how to write a reference manual.
Lex Fridman (55:29.480)
Really, really very, very well done.
Lex Fridman (55:31.480)
So I twisted his arm until he agreed to write a book,
Lex Fridman (55:34.240)
and then we wrote a book.
Lex Fridman (55:35.440)
And the virtue or advantage, at least,
Lex Fridman (55:38.560)
I guess, of going first is that then other people
Brian Kernighan (55:40.840)
have to follow you if they're gonna do anything.
Lex Fridman (55:44.880)
And I think it worked well because Dennis
Brian Kernighan (55:49.240)
was a superb writer.
Lex Fridman (55:50.400)
I mean, he really, really did.
Lex Fridman (55:51.600)
And the reference manual in that book is his, period.
Lex Fridman (55:55.080)
I had nothing to do with that at all.
Lex Fridman (55:58.760)
So just crystal clear prose and very, very well expressed.
Lex Fridman (56:02.720)
And then he and I, I wrote most of the expository material.
Lex Fridman (56:07.720)
And then he and I sort of did the usual ping ponging
Lex Fridman (56:10.320)
back and forth, refining it.
Lex Fridman (56:13.400)
But I spent a lot of time trying to find examples
Lex Fridman (56:15.600)
that would sort of hang together
Lex Fridman (56:16.840)
and that would tell people what they might need
Lex Fridman (56:18.680)
to know at about the right time
Brian Kernighan (56:20.200)
that they should be thinking about needing it.
Lex Fridman (56:22.440)
And I'm not sure it completely succeeded,
Lex Fridman (56:25.520)
but it mostly worked out fairly well.
Lex Fridman (56:28.480)
What do you think is the power of example?
Brian Kernighan (56:30.120)
I mean, you're the creator, at least one of the first people
Lex Fridman (56:35.960)
to do the Hello World program, which is like the example.
Brian Kernighan (56:40.400)
If aliens discover our civilization hundreds of years
Lex Fridman (56:43.760)
from now, it'll probably be Hello World programs,
Brian Kernighan (56:46.800)
just like a half broken robot communicating with them
Lex Fridman (56:49.560)
with the Hello World.
Lex Fridman (56:50.760)
So what, and that's a representative example.
Lex Fridman (56:53.400)
So what do you find powerful about examples?
Brian Kernighan (56:57.040)
I think a good example will tell you how to do something
Lex Fridman (57:01.520)
and it will be representative of,
Brian Kernighan (57:03.840)
you might not want to do exactly that,
Lex Fridman (57:05.680)
but you will want to do something that's at least
Brian Kernighan (57:07.560)
in that same general vein.
Lex Fridman (57:10.720)
And so a lot of the examples in the C book were picked
Brian Kernighan (57:14.000)
for these very, very simple, straightforward
Lex Fridman (57:16.200)
text processing problems that were typical of Unix.
Brian Kernighan (57:19.720)
I want to read input and write it out again.
Lex Fridman (57:23.560)
There's a copy command.
Brian Kernighan (57:24.560)
I want to read input and do something to it
Lex Fridman (57:27.040)
and write it out again.
Brian Kernighan (57:27.960)
There's a grab.
Lex Fridman (57:28.800)
And so that kind of find things that are representative
Brian Kernighan (57:33.120)
of what people want to do and spell those out
Lex Fridman (57:36.600)
so that they can then take those and see the core parts
Lex Fridman (57:42.040)
and modify them to their taste.
Lex Fridman (57:45.680)
And I think that a lot of programming books that,
Brian Kernighan (57:48.760)
I don't look at programming books
Lex Fridman (57:51.120)
a tremendous amount these days, but when I do,
Brian Kernighan (57:52.880)
a lot of them don't do that.
Lex Fridman (57:54.440)
They don't give you examples that are both realistic
Lex Fridman (57:59.000)
and something you might want to do.
Lex Fridman (58:01.840)
Some of them are pure syntax.
Brian Kernighan (58:03.760)
Here's how you add three numbers.
Lex Fridman (58:05.280)
Well, come on, I could figure that out.
Lex Fridman (58:07.280)
Tell me how I would get those three numbers
Lex Fridman (58:09.160)
into the computer and how we would do something useful
Brian Kernighan (58:11.880)
with them and then how I put them back out again,
Lex Fridman (58:14.280)
neatly formatted.
Lex Fridman (58:15.520)
And especially if you follow that example,
Lex Fridman (58:17.160)
there is something magical of doing something
Brian Kernighan (58:19.440)
that feels useful.
Lex Fridman (58:21.000)
Yeah, right.
Lex Fridman (58:21.840)
And I think it's the attempt,
Lex Fridman (58:23.560)
and it's absolutely not perfect,
Lex Fridman (58:26.360)
but the attempt in all cases was to get something
Lex Fridman (58:28.760)
that was going to be either directly useful
Brian Kernighan (58:31.520)
or would be very representative of useful things
Lex Fridman (58:35.560)
that a programmer might want to do.
Lex Fridman (58:37.920)
But within that vein of fundamentally text processing,
Lex Fridman (58:41.080)
reading text, doing something, writing text.
Lex Fridman (58:43.640)
So you've also written a book on Go language.
Lex Fridman (58:47.360)
I have to admit, so I worked at Google for a while
Lex Fridman (58:50.920)
and I've never used Go.
Lex Fridman (58:53.640)
Well, you missed something.
Brian Kernighan (58:54.680)
Well, I know I missed something for sure.
Lex Fridman (58:56.320)
I mean, so Go and Rust are two languages
Brian Kernighan (58:59.520)
that I hear very, spoken very highly of
Lex Fridman (59:04.000)
and I wish I would like to, well, there's a lot of them.
Brian Kernighan (59:06.840)
There's Julia, there's all these incredible modern languages.
Lex Fridman (59:10.760)
But if you can comment before,
Brian Kernighan (59:12.680)
or maybe comment on what do you find,
Lex Fridman (59:16.280)
where does Go sit in this broad spectrum of languages?
Lex Fridman (59:19.640)
And also, how do you yourself feel
Lex Fridman (59:22.320)
about this wide range of powerful, interesting languages
Brian Kernighan (59:26.480)
that you may never even get to try to explore
Lex Fridman (59:30.520)
because of time?
Lex Fridman (59:31.520)
So I think, so Go first comes from that same
Lex Fridman (59:36.520)
Bell Labs tradition in part, not exclusively,
Lex Fridman (59:39.240)
but two of the three creators, Ken Thompson and Rob Pike.
Lex Fridman (59:42.480)
So literally, the people.
Brian Kernighan (59:44.040)
Yeah, the people.
Lex Fridman (59:45.600)
And then with this very, very useful influence
Brian Kernighan (59:49.080)
from the European school in particular,
Lex Fridman (59:51.880)
the Claude Speer influence through Robert Griesemer,
Brian Kernighan (59:55.600)
who was, I guess, a second generation down student at ETH.
🔗 相关节目