Kernighan Credits Unix Rise to Thompson Genius, University Licensing

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

Lex Fridman

Unix conquered modern computing through Ken Thompson's singular programming ability and low-cost university source licenses rather than predictable market evolution or open-source planning.

AI-assisted summary of Brian Kernighan: UNIX, C, AWK, AMPL, and Go Programming | Lex Fridman Podcast #109 — original source. Check the original for full context.

Source published:

Key ideas

  • Ken Thompson implemented the core components of UNIX—including a custom assembler, interactive text editor, hierarchical file system, and process manager—in bare-metal assembly on an abandoned DEC PDP-7 in just three weeks during the summer of 1969. (14:07)
  • Although AT&T Unix was proprietary and patented, low-cost source-code licensing for universities seeded global adoption, directly paving the way for Berkeley Unix (BSD), the free software movement, and the modern Linux kernel. (25:56)
  • Brian Kernighan warns that modern package ecosystems like npm and pip create massive security and reliability liabilities by encouraging developers to pull in opaque, sprawling dependency trees. (66:28)
  • Kernighan argues that society does not need every individual to become a coder, but non-programmers must develop an intuitive understanding of basic computing abstractions to evaluate technology and automated decision-making critically. (92:54)

Detailed notes

## Background This interview was published on YouTube by Lex Fridman on July 18, 2020, as episode #109 of the Lex Fridman Podcast. The episode features Brian Kernighan, computer science professor at Princeton University, co-author of 'The C Programming Language' with Dennis Ritchie, co-creator of AWK, and co-designer of AMPL, discussing the history of UNIX, programming languages, and computing.

## TL;DR Brian Kernighan reflects on the genesis of UNIX and C at Bell Labs, crediting Ken Thompson's singular programming ability and the tight collaborative culture that enabled rapid innovation. He explores the trade-offs of language design across decades—from assembly and Fortran to AWK, C++, Rust, and Go—emphasizing why no single language can satisfy every computing need. Kernighan also shares insights from his work on AMPL, graph partitioning, and text editors, while weighing the evolution of Moore's law and the double-edged societal impacts of ubiquitous computing, data privacy, and AI.

## Atmosphere & style The conversation carries a warm, understated reverence, anchored by Kernighan's self-effacing humility and encyclopedic grasp of computing history. Fridman approaches the exchange with earnest fascination, prompting Kernighan to demystify legendary eras into relatable stories of physical terminal rooms, rapid prototyping, and pragmatic design choices. Listening feels like sitting in an intimate, master-level office hour where foundational milestones of computer science are treated not as grand inevitabilities, but as the joyful result of tight feedback loops, sharp constraints, and good fortune.

## Bulletin - [14:07](https://www.youtube.com/watch?v=O9upVbGSBFo&t=847s) Ken Thompson implemented the core components of UNIX—including a custom assembler, interactive text editor, hierarchical file system, and process manager—in bare-metal assembly on an abandoned DEC PDP-7 in just three weeks during the summer of 1969. - [25:56](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1556s) Although AT&T Unix was proprietary and patented, low-cost source-code licensing for universities seeded global adoption, directly paving the way for Berkeley Unix (BSD), the free software movement, and the modern Linux kernel. - [01:06:28](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3988s) Brian Kernighan warns that modern package ecosystems like npm and pip create massive security and reliability liabilities by encouraging developers to pull in opaque, sprawling dependency trees. - [01:32:54](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5574s) Kernighan argues that society does not need every individual to become a coder, but non-programmers must develop an intuitive understanding of basic computing abstractions to evaluate technology and automated decision-making critically.

## Key takeaways - [04:24](https://www.youtube.com/watch?v=O9upVbGSBFo&t=264s) The transition from batch processing with punch cards to interactive time-sharing radically compressed feedback loops and fundamentally altered how programmers worked. - [14:07](https://www.youtube.com/watch?v=O9upVbGSBFo&t=847s) Bell Labs withdrew from the overly complex Multics project in 1969, prompting Ken Thompson and Dennis Ritchie to pursue a lightweight, bottom-up computing environment. - [18:21](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1101s) Kernighan describes Ken Thompson as a programming 'singularity', attributing the foundational breakthroughs of UNIX largely to Thompson's extraordinary individual capability. - [21:26](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1286s) UNIX prioritized creating a productive community environment for programmers rather than solving a specialized corporate or laboratory computing task. - [29:46](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1786s) Severe hardware constraints on early minicomputers forced Unix developers to pursue elegant, unified abstractions, such as treating files and peripheral devices under a single read/write interface. - [35:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2118s) AWK was designed to automate common text processing patterns, implicitly handling file reading, record splitting, and pattern matching without boilerplate loops. - [42:35](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2555s) The evolution of text editors from paper-based line editors like ed to screen-oriented tools like vi was directly driven by the shift from mechanical teletypes to CRT terminals. - [51:04](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3064s) C succeeded as the premier systems programming language because it balanced hardware-level control and efficiency with structured programming abstractions. - [53:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3198s) The tight symbiotic relationship between C and UNIX generated a self-reinforcing adoption cycle, making utilities and operating systems mutually portable. - [56:28](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3388s) Kernighan emphasizes that instructional programming literature should teach using realistic, functional utilities rather than artificial, toy puzzles. - [58:44](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3524s) Go introduced language-level concurrency via goroutines and channels based on Tony Hoare's Communicating Sequential Processes (CSP), reflecting modern multicore realities. - [01:01:57](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3717s) Kernighan's benchmark of a 60-character line-wrapping text formatter revealed dramatic differences in implementation friction, ranging from under an hour in Lua to weeks in Haskell. - [01:08:16](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4096s) Functional programming concepts like first-class functions, recursion, and lambdas have steadily been absorbed into mainstream imperative languages. - [01:10:30](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4230s) AMPL decoupled mathematical optimization modeling from input data formats and underlying numerical solvers, enabling algebraic formulation of complex linear and non-linear problems. - [01:18:01](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4681s) The Kernighan–Lin heuristic was developed to tackle graph partitioning because enforcing equal-sized subset divisions transforms polynomial-time min-cut problems into NP-complete challenges. - [01:24:41](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5081s) Machine learning systems trained on historical data risk scaling and codifying past societal biases unless explicitly addressed. - [01:29:45](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5385s) Exponential hardware scaling faces immutable physical constraints at atomic dimensions, driving software paradigms toward multithreading and code generation. - [01:36:35](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5795s) Ubiquitous computing and digital networks have simultaneously lowered communication barriers and accelerated political polarization, tribalism, and misinformation.

## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=O9upVbGSBFo&t=0s) Introduction and Sponsor Announcements

Lex Fridman introduces Brian Kernighan, a professor of computer science at Princeton University and a foundational figure in the computing community. Alongside UNIX creators Ken Thompson and Dennis Ritchie at Bell Labs, Kernighan played an integral role in early UNIX culture and history. Beyond co-authoring the seminal book *The C Programming Language* with Ritchie, Kernighan has authored numerous texts including *The Practice of Programming*, *The Go Programming Language*, and his memoir *UNIX: A History and a Memoir*. He also co-created the AWK pattern-scanning language and co-designed the AMPL algebraic modeling language, a tool Fridman notes he has personally used extensively for large-scale optimization. Fridman reflects that despite such extensive accomplishments, Kernighan remains remarkably humble and gracious: “I think I can keep going for a long time with his creations and accomplishments which is funny because given all that he's one of the most humble and kind people I've spoken to on this podcast.”

Fridman then covers the episode's sponsors, Eight Sleep and Raycon. He discusses the Eight Sleep Pod Pro mattress, highlighting its ability to cool down to 65 degrees, its dual-zone temperature regulation, and its biometric sensors tracking resting heart rate, heart rate variability, and respiratory rate. Fridman jokes about the independent side-temperature controls: “I don't happen to have one but the Eight Sleep app reminds me that I should probably get on that so ladies if a temperature controlled mattress isn't a good reason to apply I don't know what is.” He also highlights Raycon earbuds, describing how he wears them while running, exercising, and playing brown noise to concentrate during deep work, while listening to Santana’s guitar track "Europa" during the recording.

- Eight Sleep Pod Pro offers biometric tracking (HR, HRV, respiratory rate) and app-controlled cooling down to 65°F. - Raycon wireless earbuds feature six hours of battery life and easy Bluetooth pairing. - Fridman jokes that if Richard Feynman were alive today, he would be listening to *The Joe Rogan Experience* on Raycons.

---

[04:24](https://www.youtube.com/watch?v=O9upVbGSBFo&t=264s) The Shift from Batch Processing to Time-Sharing

Fridman opens the discussion by asking about the birth of UNIX roughly fifty years earlier in 1969. Kernighan points out that understanding UNIX requires tracing back an almost infinite regress into previous computing paradigms, beginning with the transition from batch systems to time-sharing. In the 1950s and early 1960s, computers were physically colossal machines housed in large dedicated rooms, yet possessed minuscule processing power compared to modern standards. Users interacted with them asynchronously through punch card decks. A programmer would punch out their code, hand the deck over a physical counter to a machine operator, and wait hours only to receive a printout indicating a syntax mistake, demanding another tedious cycle.

Time-sharing revolutionized this workflow by connecting multiple users simultaneously to the central computer via terminals resembling electric typewriters. Instead of monopolizing the central processor for one batch job at a time, the operating system rapidly cycled through all active terminals, allocating each user a tiny quantum of CPU time. Whenever a user typed a character, the system woke up, registered the keystroke into a buffer, and promptly returned to servicing other tasks. As Kernighan summarizes the core user experience: “And hence time sharing that is sharing the computing time resource of the computer among a number of people who are doing it without the individual people being aware that there's others.”

```mermaid flowchart TD accTitle: Evolution of Computing Paradigms accDescr: Flow diagram contrasting 1950s batch processing with 1960s interactive time-sharing.

subgraph Batch["Batch Processing (1950s-1960s)"] A["Programmer Punches Cards"] --> B["Operator at Counter"] B --> C["Mainframe Batch Run"] C --> D["Printed Error Report (Hours Later)"] end

subgraph TimeSharing["Time-Sharing (CTSS / Multics / UNIX)"] E["Teletype / Electric Typewriter"] -->|"Keystroke"| F["OS Round-Robin Scheduler"] F --> G["Dedicated Slice of Central CPU"] G -->|"Interactive Illusion"| E end ```

---

[07:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=438s) CTSS and the Multics Vision of a Computing Utility

Kernighan describes the Compatible Time-Sharing System (CTSS), developed at MIT under the leadership of Fernando Corbató ("Corby"), as arguably the first true realization of this model. Kernighan experienced CTSS firsthand during a formative summer in Cambridge in 1966. The system ran on a modified IBM 7094 mainframe equipped with two 32,768-word banks of 36-bit core memory—roughly 300 kilobytes total, which was considered an enormous and expensive amount of memory for its era. When Fridman inquires about the algorithmic complexity of early schedulers, Kernighan explains that the baseline approach relied on straightforward round-robin queueing, adapting dynamically depending on whether a task was an interactive text edit or a heavy compiler job.

CTSS directly inspired Multics (Multiplexed Information and Computing Service), a collaborative project among Bell Labs, MIT, and General Electric intended to scale time-sharing into a general-purpose, commercial-grade infrastructure. Multics envisioned computing as a public utility analogous to the electrical grid, anticipating the core concepts of modern cloud infrastructure fifty years ahead of its time. When Fridman asks whether researchers back then foresaw the ubiquity of contemporary computing, Kernighan clarifies the scope of their imagination: “I'm betting that they didn't have the same view of computing for the masses let's call it the idea that you know your grandmother would be shopping on Amazon I don't think that was part of it but if your grandmother were a programmer it might be very easy for her to go and use this kind of utility.”

- **CTSS Architecture**: Hosted on an IBM 7094 with two banks of 32K 36-bit words (approximately 150 KB per bank, ~300 KB combined). - **Key Figures**: Fernando Corbató ("Corby") at MIT pioneered CTSS and Multics time-sharing concepts. - **The Utility Model**: Multics conceived computing as an "information utility"—a shared resource accessed from remote wall jacks, laying the conceptual groundwork for cloud computing.

[10:51](https://www.youtube.com/watch?v=O9upVbGSBFo&t=651s) Early Computing Dreams and Arriving at Bell Labs

When asked whether he foresaw the future of modern computing during his early days in Cambridge, Brian Kernighan offers a blunt, amused assessment: “Short answer: absolutely not. I had no clue.” Rather than harboring a grand prophetic vision, he viewed his summer internship as simply a dream job where he relished the work, the fine summer weather, and the stimulating company of brilliant colleagues. That formative experience set off a chain reaction of good fortune, directly helping him secure a summer internship in 1966 at AT&T Bell Laboratories.

Bell Labs was a legendary research powerhouse physically distributed across New Jersey. Its flagship location sat in Murray Hill, straddling the border between the small suburban towns of New Providence and Berkeley Heights, about 15 to 20 miles west of New York City. The Murray Hill campus housed roughly 3,000 to 4,000 employees, an extraordinary proportion of whom held PhDs. While historically centered on the physical sciences—advancing chemistry, materials science, and physics—the institution possessed world-class mathematical talent and an accelerating appetite for computation. Researchers increasingly realized they could model experiments digitally instead of building physical laboratories.

- **Primary location**: Murray Hill, New Jersey (spanning Berkeley Heights and New Providence). - **Staffing profile**: 3,000 to 4,000 people, heavily weighted toward PhDs in physics, chemistry, materials, and mathematics. - **Corporate parentage**: Bell Labs operated as the research and development engine for AT&T, which held a regulated monopoly over American telephone service. - **Mission mandate**: While AT&T was tasked with providing universal phone service across the nation, Bell Labs was funded to relentlessly improve that service through foundational research, yielding breakthroughs such as the transistor, fiber-optic cables, and microwave transmission systems.

---

[14:07](https://www.youtube.com/watch?v=O9upVbGSBFo&t=847s) The Collapse of Multics and the Genesis of UNIX

During the late 1960s, Bell Labs participated in a joint project alongside MIT and General Electric to create Multics (Multiplexed Information and Computing Service). Conceived as an ambitious, centralized "information utility," Multics was laden with brilliant conceptual ideas, but it suffered from staggering complexity, runaway development costs, and severe delivery delays. By early 1969, management at Bell Labs concluded the platform would not deliver on a reasonable timescale and pulled out of the consortium.

The sudden cancellation stranded researchers who had developed a taste for sophisticated interactive computing. Deprived of a comfortable time-sharing system, team members began designing a replacement on paper, striving to merge the fluidity of the earlier Compatible Time-Sharing System (CTSS) with the architectural lessons learned from Multics. Concurrently, Ken Thompson located a largely neglected Digital Equipment Corporation (DEC) PDP-7 minicomputer and used it to test experimental file-system designs.

```mermaid flowchart TD accTitle: The Path from Multics to UNIX accDescr: Diagram illustrating how the withdrawal from Multics led directly to Ken Thompson's three-week sprint to build UNIX on a PDP-7.

subgraph MulticsEra["Multics Project (Late 1960s)"] M1["MIT + Bell Labs + General Electric"] M2["Ambitious 'Information Utility'"] M1 --- M2 end

subgraph TheBreak["1969 Bell Labs Withdrawal"] B1["High Costs & Delivery Delays"] B2["Researchers Left Without an Interactive OS"] MulticsEra --> B1 B1 --> B2 end

subgraph UnixGenesis["Birth of UNIX (Summer 1969)"] U1["Paper System Architecture Designs"] U2["Ken Thompson Explores File Systems on a PDP-7"] U3["Thompson's 3-Week Coding Sprint"] B2 --> U1 B2 --> U2 U1 --> U3 U2 --> U3 U3 --> OS["First UNIX Operating System"] end ```

The pivotal moment arrived during the summer of 1969 when Ken Thompson’s wife traveled to California for three weeks with their one-year-old son. Working alone during that brief window, Thompson wrote the core components of what would become the UNIX operating system. As Kernighan wryly notes about that burst of raw output, “Software productivity was good in those days.”

---

[15:49](https://www.youtube.com/watch?v=O9upVbGSBFo&t=949s) Building an Operating System on a DEC PDP-7 in Assembly

The hardware hosting this milestone was a DEC PDP-7, a minicomputer introduced in 1964 that was already verging on obsolescence by 1969. Minicomputers of that era were modest compared to room-sized mainframes: the PDP-7 typically possessed around 16 kilowords of memory and operated at relatively low clock speeds. While out of reach for a private individual at a price tag hovering near $100,000, it was inexpensive enough for small institutional teams to commandeer without upper-management oversight.

Kernighan clarifies that he had no role in writing this foundational kernel code, emphasizing that he has never written operating system code himself. Operating systems, he explains, fundamentally consist of routines to run processes, persist data reliably across reboots, and manage memory. Because there was no existing software ecosystem for the abandoned PDP-7, Thompson had to build every essential piece from bare metal up:

```mermaid flowchart LR accTitle: PDP-7 Bare Metal UNIX Architecture accDescr: Flowchart showing the components Ken Thompson implemented in assembly language on the PDP-7 to establish UNIX.

subgraph CoreOS["UNIX Kernel Essentials"] FS["File System Management"] Exec["Process Loader & Execution Dispatcher"] end

subgraph Toolchain["Userland Assembly Toolchain"] ASM["Custom PDP-7 Assembler"] ED["Text Editor"] end

ASM --> ED ED --> FS FS --> Exec ```

- **Assembly language origin**: The original 1969 UNIX implementation was written entirely in native PDP-7 assembly language; UNIX and its tools remained in assembly until rewritten in C around 1973–1974. - **Absence of tooling**: Early assembly development provided zero guard rails, run-time checks, or modern symbolic debuggers. When machine code failed, diagnosis required meticulous manual inspection. - **Essential components implemented by Thompson**: - A custom PDP-7 assembler to assemble code directly on the machine. - An interactive text editor to write and alter source files. - A hierarchical file system storing persistent directories and byte sequences. - A process manager to load executables from disk into memory, transfer CPU control to them, and cleanly recover control upon exit.

---

[18:21](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1101s) Ken Thompson as a Programming Singularity

Reflecting on the psychological and technical strain of writing an entire OS in assembly language, Kernighan acknowledges that the task would appear insurmountable to modern engineers. The smaller overall scale of computing in 1969 kept the big picture manageable, but overcoming the lack of tooling demanded an extraordinary mind. Kernighan highlights the immense gulf in individual programming talent, describing Thompson in singular terms: “Realistically, there's an enormous variation in the capabilities of programmers, and Ken Thompson, who did that first one, is kind of the singularity in my experience of programmers.” He adds that compared to Thompson, other skilled programmers are “several leagues removed.”

Lex Fridman remarks on the serendipity of history—how the alignment of a unique talent, a specific point in computer evolution, and a quiet three-week window when a family traveled out of town combined to create a system whose descendants now dominate the world's infrastructure. When Fridman asks what it feels like to look back on this tiny seed overtaking the digital globe, Kernighan admits that the modern footprint of UNIX-like architectures could never have been anticipated.

> “And you asked earlier about predictions—the answer is no, there's no way you could predict that kind of evolution, and I don't know whether it was inevitable or just a whole sequence of blind luck; I suspect more the latter.” > — *Brian Kernighan*

Kernighan insists that while Dennis Ritchie and a host of brilliant colleagues at Bell Labs made monumental contributions to refine and transform the system, the foundational credit belongs to Ken Thompson: “If you had to pick a single person, that would be Ken.” He concludes that the sustained creativity that followed was made possible by the rare, collaborative culture fostered within Bell Labs during that era.

[21:26](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1286s) The Culture and Philosophy of Bell Labs Unix

Brian Kernighan describes Bell Labs as an extraordinary workplace defined by brilliant colleagues and an open, cooperative culture. Researchers could walk into anyone's office to hash out complex technical problems. It was also an environment full of playful mischief, where researchers took delight in “tweaking the bureaucracy” whenever possible. Asked by Lex Fridman about the core philosophy that governed Unix from its beginnings and across the decades, Kernighan emphasizes that it was engineered strictly to serve developers rather than to solve a single specialized task. Although Unix ended up being used heavily for word processing, laboratory apparatus control, and serving as a front end for massive legacy mainframes, none of those were its explicit design target.

Kernighan points out that the real objective, as Dennis Ritchie observed at the conclusion of Kernighan's memoir, was the formation of a programmer community. Because writing software on Unix was unusually painless and productive, programmers built useful tools, which other developers adopted and improved upon, fostering a reinforcing community dynamic. Kernighan highlights Ritchie's insight:

> “From his standpoint the real goal was to create a community where people could work as programmers on a system.”

- Unix was widely adopted for tasks it was never explicitly built for, including lab device control, front-end interfacing for large mainframes, and text/word processing. - The overarching technical priority was reducing friction for software developers, creating a virtuous feedback loop of tool building.

```mermaid flowchart LR accTitle: The Unix Virtuous Circle accDescr: Diagram showing how a friction-free environment fueled developer tools and community growth. subgraph Environment ["Bell Labs Core"] A["Low-Friction System"] --> B["Fast Development"] end subgraph Community ["Ecosystem"] B --> C["Useful Programmer Tools"] C --> D["Adopted by Colleagues"] D -->|"Feedback & ideas"| A end ```

---

[23:40](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1420s) Rapid Feedback Loops and Physical Collaboration

Writing code in the early Unix period was, in Kernighan's words, “a blast.” He self-deprecatingly claims he is “not a terribly good programmer,” but stresses that the computing frontier back then was packed with low-hanging fruit—problems nobody had ever addressed on interactive computers. With responsive machines, sharp utilities, and outstanding colleagues, development cycles moved at breakneck speed. A developer could conceive a feature in the morning, hack together a prototype that evening, and receive candid evaluations the following morning: users would praise the concept while bluntly pointing out every flaw. That rapid, unvarnished feedback loop was immensely rewarding because programming is fundamentally about puzzle-solving, and having real people use what you built—even when they complained—made the work exciting.

Lex Fridman asks how that feedback was mediated before the internet existed. Kernighan clarifies that Bell Labs was largely housed under one enormous roof. The Unix team was concentrated across just two or three hallways, anchored by a shared room measuring roughly 50 feet by 50 feet. That communal hub housed terminals and a coffee machine where staff regularly hung out. Although internal electronic mail existed, all users shared a single central machine, eliminating any requirement for external computer networks to maintain instantaneous, tight communication.

Kernighan reflects on the role of physical co-location:

> “Programming itself is fun it's puzzle solving in a variety of ways but I think it's even more fun when you do something that somebody else then uses even if they whine about it not working the fact that they used it is as part of the reward mechanism.”

- The rapid feedback loop allowed developers to conceive an idea in the morning, prototype it by evening, and receive colleague feedback the very next day. - Team interactions were predominantly physical and face-to-face inside Bell Labs' shared 50x50-foot terminal/coffee room. - Early Unix email operated entirely local to a single shared computer system, requiring no internet connectivity.

---

[25:56](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1556s) Bell Labs in History: Survivor Bias and Institutional Influence

Reflecting on Fridman's suggestion that modern computing might not exist without Bell Labs, Kernighan cautions against historical survivor bias. Bell Labs was undeniably special, but other institutions made parallel, earth-shaking breakthroughs during the same era. He singles out Xerox PARC for pioneering many technologies taken for granted in contemporary computing, even though its corporate parent company failed to commercialize them as successfully. He also points to university computer science powerhouses like MIT as vital sources of innovation.

When Fridman suggests that Unix ended up as open-source software because AT&T was a regulated telephone monopoly constrained from selling software, Kernighan corrects the record: Unix was never open source in the modern sense. It was proprietary, patented, and licensed under strict agreements. However, AT&T licensed Unix source code to educational institutions for nominal administrative fees. This allowed generations of university students and professors to study, run, and modify the operating system internals. That widespread academic access eventually inspired Berkeley Unix (BSD)—driven by figures like Bill Joy—to systematically rewrite AT&T components until the codebase became fully independent, despite prolonged legal disputes throughout the late 1980s and early 1990s.

Kernighan emphasizes the direct continuity leading to modern Linux:

> “I think that's a mischaracterization in the sense it absolutely was not open source it was very definitely proprietary licensed but it was licensed freely to universities in source code form for many years and because of that generations of university students and their faculty people grew up knowing about Unix.”

- Xerox PARC and MIT are highlighted as equally groundbreaking research centers whose discoveries shaped modern computing. - AT&T Unix remained strictly proprietary, but broad, inexpensive university licensing gave it the operational feel of an open system long before open-source licensing models existed. - Berkeley's BSD effort, including contributions from Bill Joy, gradually stripped out AT&T proprietary code through clean-room reimplementation. - The culture of Unix knowledge paved the way for Richard Stallman's late-1980s free software efforts and Linus Torvalds' 1991 creation of the Linux kernel.

---

[29:46](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1786s) Constraints, Efficiency, and Unified Abstractions

Fridman asks why Unix proved to be so extraordinarily efficient and robust, wondering whether that was a deliberate byproduct of prioritizing the programmer experience. Kernighan explains that the early hardware constraints forced minimalism upon the developers. Ken Thompson and Dennis Ritchie operated on severely limited minicomputers with tiny memories and slow clock speeds, making bloated, convoluted designs physically impossible. The scarcity of hardware resources compelled them to search for overarching generalizations rather than crafting one-off special cases for individual features.

The defining example of this philosophy is the Unix file system. By establishing a simple, uniform read/write interface for files, the designers realized that peripheral hardware devices could be treated identically to disk files. Later operating systems pushed this uniform abstraction even further: Unix began treating active processes as directory structures (such as `/proc`), and Bell Labs' successor system, Plan 9, structured nearly all local and remote operating system services as synthesized file systems adhering to the exact same file API.

Kernighan summarizes how foundational design abstractions reduce system complexity:

> “Finding the right model of how to do something means that an awful lot of things become simpler and it means therefore that more people can do useful interesting things with them without him to think as hard about it.”

- Severe hardware limitations on early minicomputers prevented bloated code and enforced mechanical minimalism. - A single generalized file system abstraction (open, read, write, close) served both physical disk storage and hardware peripheral devices. - Bell Labs' later Plan 9 operating system carried this philosophy to its logical conclusion, presenting diverse computing resources across network nodes as unified file systems.

[32:01](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1921s) Programming as Art, Science, and Engineering

Lex Fridman remarks that despite Brian Kernighan's understated posture, he radiates a genuine love for programming, and asks whether Kernighan views programming as more of an art or a science—creativity versus rigor. Kernighan answers that it is an amalgam of art, science, and engineering:

> “I think it's some of each it's some combination some of the art is figuring out what it is that did you really want to do what should that program be what would make a good program and that's some understanding of what the task is what the people who might use this program want and I think that's that's art in many respects.”

The scientific aspect, Kernighan explains, lies in figuring out how to do it well using formal computer science principles—selecting correct algorithms and data structures, and ensuring scalability by avoiding quadratic algorithms when a linear approach is required. However, he emphasizes that programming is fundamentally an engineering discipline. Engineering departs from pure science because it requires navigating practical constraints: determining not just an optimal algorithm in the abstract, but the most appropriate algorithm given limited time to compute, limited time to write code, and future maintenance realities regarding who will maintain the software later. A scientist might push those practicalities over the horizon, and an artist would disregard them entirely, but an engineer must confront them directly.

When asked about his personal workflow—whether he sketches out software engineering designs on paper first or dives into iterative coding—Kernighan describes an informal, incremental approach. He notes that he no longer writes large programs; it has been a long time since he wrote a program exceeding a few hundred lines. Most of his current programming consists of: - Small experimental programs to satisfy personal curiosity. - Demonstrations and examples prepared for his university classes. - Exploratory data analysis scripts to investigate new datasets.

For exploratory data analysis, Kernighan often relies on simple existing command-line tools to count elements, or writes two- to three-line AWK scripts to inspect slices of data. When a project grows larger, up to a few hundred lines, he turns to Python because it scales better for that size.

---

[35:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2118s) The Design and Elegance of AWK

Lex asks Kernighan to define AWK and explain why it remains widely used for data exploration more than four decades after its inception. Kernighan explains that AWK is a scripting language developed in the late 1970s by Alfred Aho, Peter Weinberger, and himself. It was designed to make quick-and-dirty tasks trivial—such as counting records, rearranging text fields, or extracting summary information from text files.

Kernighan reflects on the unexpected longevity of the tool:

> “Well this is paternal interest I guess but I think in terms of programming languages you get the most bang for the buck by learning awk and it doesn't scale the big programs but it does pretty pretty darn well on these little things where you just want to see all the something's in something so yeah I find I probably write more awk than anything.”

When Fridman asks what brings Kernighan joy about using AWK, Kernighan points directly to its thoughtful default behaviors. AWK automatically handles what would otherwise require a quadruply nested loop: iterating through every input file, reading every line, testing each line against pattern regular expressions, and executing the corresponding action whenever a pattern matches. In addition, AWK automatically splits lines into fields delimited by whitespace and tracks metadata behind the scenes, such as line numbers and field counts. A task requiring 5, 10, or 20 lines in Python collapses into a single one- or two-line command in AWK, allowing programmers to execute it directly inside the terminal shell without switching tools.

```mermaid flowchart TD accTitle: AWK Implicit Execution Loop accDescr: Diagram showing how AWK automatically iterates over files, lines, and patterns without manual loop boilerplate.

subgraph InputProcessing["Input Processing"] A["Input Files"] --> B["Iterate Files"] B --> C["Read Line by Line"] C --> D["Split into Fields & Update Metadata"] end

subgraph PatternAction["Pattern Matching Engine"] D --> E{"Pattern Matches?"} E -- "Yes" --> F["Execute Bound Action"] E -- "No" --> G["Next Pattern / Next Line"] F --> G end ```

---

[38:40](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2320s) Command-Line Philosophy: grep, Windows, and WSL

Lex asks about other beloved shell commands, noting that `grep` acts like a simpler sibling to AWK. Kernighan agrees, noting that `grep` operates under the exact same pattern-action paradigm: it loops over files and lines, matches against a regular expression pattern, and performs a single fixed action—printing matching lines. In fact, one can implement `grep` as a one-line AWK script. Kernighan admits that he uses `grep` more than almost any other utility simply because it is so direct and natural.

Lex questions why mainstream graphical operating systems like Windows did not natively adopt this command-line search paradigm. Kernighan traces this divide back through operating system history:

> “Windows came from ms-dos ms-dos was a pretty pathetic operating system although common own and you know unbounded lis large number of machines but somewhere in roughly the 90s windows became a graphical system and I think Microsoft spent a lot of their energy on making that graphical interface what it is and that's a different model of computing it's a model of computing that where you point and click and sort of experiment with menus it's a model of computing worked right rather well for people who are not programmers just want to get something done whereas teaching something like the command line to non-programmers turns out just sometimes be an uphill struggle and so I think Microsoft probably was right and what they did.”

Lex brings up the ability to run these UNIX utilities natively on Windows via WSL (Windows Subsystem for Linux), jokingly musing over its pronunciation ("whistle"), which Kernighan finds amusing. Kernighan observes that bridging UNIX tooling to Windows has a long lineage, highlighting Cygwin as a project that has made favorite UNIX and Linux utilities run cleanly on Windows for over twenty years. Kernighan still runs Cygwin routinely on his single remaining Windows machine for batch and command-line computing, noting that the native Windows command equivalents remain unfamiliar to him. Lex adds that being able to run Bash scripts on Windows via WSL has completely transformed his workflow.

- AWK was created by Alfred Aho, Peter Weinberger, and Brian Kernighan in the late 1970s. - `grep` functions as a specialized, single-pattern/single-action subset of the AWK execution paradigm. - Cygwin has provided a POSIX/UNIX-like environment on Windows for more than two decades.

---

[42:03](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2523s) Personal Hardware and Computing Setup

Lex asks Kernighan to detail his ideal programming environment, pressing him on his favorite computer hardware, operating system, keyboard, and text editor. Kernighan pushes back gently on the framing, stating that "perfect is too strong a word."

He explains his practical daily setup: - **Machine:** A 13-inch MacBook Air. - **Form factor considerations:** He favors it because it strikes an ideal balance—it is lightweight and portable, packs enough computing horsepower for his tasks, provides an adequate display size, and has a comfortable keyboard. - **Workflow:** He conducts the vast majority of his everyday computing directly on that single laptop.

[42:35](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2555s) The Lineage of Text Editors: From Paper Terminals to Sam

Brian Kernighan notes that while he has a large iMac in his office that he fires up when he needs extra screen real estate, his daily driver relies on a specific set of tools. When asked what text editor he primarily uses, Kernighan names **Sam**, a multi-file text editor written by Rob Pike at Bell Labs. Lex Fridman asks whether Sam predates vi. Kernighan explains that Sam actually post-dates both vi and Emacs; it was directly informed by Pike's deep experience with the Unix line editor `ed` and Bill Joy's `vi`.

Fridman sheepishly admits his own allegiance—"I use Emacs, I'm sorry to say so... I'm sorry to come out with that"—and asks Kernighan to walk through the lineage of editors and their historical interplay. Kernighan traces text editors back to the early time-sharing era. On MIT's Compatible Time-Sharing System (CTSS), an early editor (possibly called `edit`) allowed users to enter and manipulate files. At Bell Labs, Ken Thompson wrote an editor called **QED**, which was exceptionally powerful.

Crucially, these primitive tools operated in an era long before mice, graphical displays, or on-screen cursors existed. Programs ran on teletype terminals that printed directly onto continuous rolls of real paper:

> “And that meant that if you changed a line, you had to print that line, using up another line of paper, to see what changed.”

When Unix was first being developed, Ken Thompson stripped QED down significantly to create `ed`, the lean, original line-oriented Unix editor. In `ed`, text was addressed purely by line numbers (from line 1 to the end of the file). Users manipulated blocks of text via cryptic single-character commands—printing ranges, appending, deleting, or running global substitution regular expressions—all executed blindly onto physical paper.

The breakthrough occurred when CRT (Cathode-Ray Tube) terminals replaced teletypes in the 1970s. For the first time, software could take advantage of cursor addressing to move arbitrarily across a persistent video screen without consuming sheets of paper. Bill Joy wrote `vi` at UC Berkeley in the late 1970s to fully exploit cursor control. Around the same era, Emacs emerged in the Lisp community. Kernighan mentions that although he rarely touches `ed` anymore, he still uses `vi` occasionally, while leaning on `Sam` as his primary editor whenever possible.

```mermaid flowchart TD accTitle: Evolution of Early Text Editors accDescr: Diagram tracing text editors from early time-sharing paper systems through CRT-based visual editors. subgraph PaperEra["Paper Terminal Era (Line-Oriented)"] CTSS["CTSS 'edit'"] QED["Ken Thompson's QED"] ED["Ken Thompson's 'ed' (Original Unix)"] CTSS -.-> QED QED -->|"stripped way down"| ED end

subgraph CRTEra["CRT Display Era (Screen & Cursor)"] VI["Bill Joy's vi (Late 1970s)"] EMACS["Emacs (Late 1970s)"] SAM["Rob Pike's Sam (Bell Labs)"] ED -->|"influenced"| VI ED -->|"influenced"| SAM VI -->|"influenced"| SAM end ```

- **Sam availability**: Maintained by enthusiasts, Sam is derived from the Plan 9 operating system distribution and can be compiled on modern Unix-like systems. - **Editor culture**: Fridman quips that one's primary programming tools feel like an indelible religious heritage: "I think it's like what religion were you brought up with." Though Fridman does his day-to-day work in C, C++, and Python, his foundational "religious upbringing" remains rooted in Lisp and Emacs.

---

[46:39](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2799s) The History of Programming Languages: From Machine Ciphers to High-Level Abstractions

Lex Fridman asks Kernighan to undertake an ambitious challenge: deliver a concise history of programming languages from his vantage point. Kernighan charts this evolution starting in the late 1940s, when computers had to be addressed by raw binary numbers via physical console toggles or punched paper tape—a process he describes as "extremely tedious, awful."

The first evolutionary leap was the invention of crude assembly languages in the late 1940s and early 1950s. Assemblers substituted human-readable mnemonics (like `ADD`) for binary opcodes and automated the grueling clerical labor of mapping memory locations to symbolic labels. Kernighan points out a recent news item: the passing of Tony Brooker, who developed Manchester Mark 1's *Autocode*—an early step above assembly that replaced Alan Turing's peculiar system of inputting binary patterns backwards to match hardware mechanics. However, early assembly code was tied one-to-one to machine architecture:

> “They have, exactly in their simplest form at least, one assembly language instruction per instruction in the machine's repertoire, and so you have to know the machine intimately to be able to write programs in it.”

If a lab acquired a different architecture—such as moving from the EDSAC to an IBM 704 or 7090—every program had to be scrapped and rewritten from scratch.

By the late 1950s, computer scientists realized they could lift the level of abstraction again, giving rise to high-level, domain-specific compiled languages: 1. **Fortran (Formula Translation)**: Developed at IBM to simplify scientific, numerical, and engineering computation. 2. **COBOL (Common Business-Oriented Language)**: Spearheaded by Grace Hopper and committee efforts to handle enterprise data and business workflows. 3. **ALGOL**: Designed to formally express algorithmic computations, establishing structured control flow patterns. 4. **BASIC**: Introduced slightly later to make computing accessible to non-specialists and students.

These languages represented a watershed moment because they decoupled source code from physical machine architectures. As long as a target architecture had an appropriate compiler, the code could run anywhere. Kernighan stresses that this shift was profoundly democratizing:

> “It meant you only had to write the program once, which is very important, and it meant that you could, in fact, if you were a random engineer, physicist, whatever, you could write that program yourself; you didn't have to hire a programmer to do it for you.”

---

[51:04](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3064s) Systems Programming, the Emergence of C, and the Scale Problem

During the late 1960s and early 1970s, the computing industry encountered an acute architectural void: high-level languages like Fortran and COBOL were poorly suited for systems programming. System programs—such as compilers, assemblers, text editors, and operating system kernels—required low-level machine control, tight memory management, bit-level data manipulation, and explicit access to runtime processes.

While many computer scientists pursued systems programming designs during that era, Kernighan notes that the C programming language stands out as the ultimate survivor. C struck an effective balance: it provided abstractions for structured programming and expressive data types while granting developers direct, disciplined access to the underlying machine hardware.

As software projects ballooned into hundreds of thousands of lines of code throughout the late 1970s and 1980s, developers ran headlong into the problem of scale:

> “As you write programs in a language like C, at some point scale gets to you, and it's too hard to keep track of the pieces, and there's no guardrails or training wheels or something like that to prevent you from doing bad things.”

To handle this complexity, object-oriented languages gained traction, most notably Bjarne Stroustrup's C++, which grew directly out of Bell Labs' C tradition to add encapsulation and class abstractions. Kernighan highlights the broader landscape that followed: - **Parallel Functional Track**: Functional paradigms descended from John McCarthy's Lisp. - **Modern Proliferation**: The explosion of general-purpose platforms like Java and web-centric languages like JavaScript. - **Contemporary Systems Languages**: Newer languages like Rust, which adopt modern safety mechanics to prevent memory corruption while retaining low-level performance.

Turning to Kernighan's iconic status as the co-author of *The C Programming Language* (with Dennis Ritchie), Fridman asks him to identify the core reason for C's enduring survival and influence. Kernighan identifies its central virtue as a rare, pragmatic design equilibrium:

> “I think it found a sweet spot of expressiveness, so you can write things in a pretty natural way.”

[53:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3198s) The Synergy of C, UNIX, and Writing the Definitive Book

Brian Kernighan explains that the enduring power of the C programming language came from combining expressiveness with raw efficiency. Looking back nearly fifty years—spanning four or five decades of Moore's law—efficiency was vital because hardware was vastly weaker than it is today. C’s fortunes were also tied directly to its native environment: UNIX. Because UNIX itself and nearly all of its supporting tools were implemented in C, any program written in the language became inherently portable across every computer capable of running UNIX. This created a powerful positive feedback loop where the language, the operating system, and the tooling reinforced one another.

```mermaid flowchart LR accTitle: C and UNIX Positive Feedback Loop accDescr: Diagram showing how C's design and UNIX's portability reinforced one another. subgraph Language ["Language Design"] E["Expressiveness & Efficiency"] C["C Programming Language"] E --> C end subgraph Platform ["Ecosystem Adoption"] U["UNIX Operating System & Tools"] P["Cross-Platform Portability"] C -->|"Used to write"| U U -->|"Runs on diverse hardware"| P P -->|"Reinforces demand"| C end ```

Lex Fridman asks Kernighan what it took to produce *The C Programming Language* (co-authored with Dennis Ritchie), noting that it became perhaps the definitive programming book in computer history—both popularizing C and setting the universal standard for how it should be written. Asked whether they harbored grand ambitions of that scale, Kernighan laughs off the suggestion: “Dennis and I wrote the book in 1977... and at that point UNIX was starting to spread I don't know how many there were but it would be dozens to hundreds of UNIX systems.” He attributes their success to an accident of skill, timing, and luck. C was gaining ground on non-UNIX platforms, Bell Labs was the sole authoritative source, and Dennis Ritchie had already authored a magnificent reference manual. Kernighan jokingly recalls that he simply “twisted his arm until he agreed to write a book,” noting the distinct advantage of being first to set the benchmark.

- In their division of labor, Ritchie wrote the entire reference manual while Kernighan took on the expository material, refining the text through constant back-and-forth iteration. - Kernighan describes Ritchie’s writing as authoritative and “crystal-clear prose.”

[56:28](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3388s) The Pedagogical Philosophy of Realistic Examples

Lex shifts to Kernighan's pioneering role in introducing the iconic `"hello, world"` test program, musing that centuries from now, an alien civilization discovering a half-broken human robot would likely find it communicating via `"hello, world"`. In response to what makes code examples truly resonate, Kernighan emphasizes that sample programs must be genuinely representative of real problems developers want to solve. Rather than constructing artificial toy syntax puzzles, the examples in the C book mirrored everyday UNIX utilities: reading an input stream and echoing it (like `cp`), or inspecting text to filter lines (like `grep`).

Kernighan criticizes modern instructional programming books for divorcing syntax from utility. He notes that seeing an example merely showing how to add three numbers together fails to teach how to ingest those numbers into the machine, transform them meaningfully, and format the output cleanly: “I think a good example will tell you how to do something and it will be representative of you might not want to do exactly that but you will want to do something that's at least in that same general vein.” By giving readers immediately practical building blocks centered on reading, transforming, and writing text, developers can intuitively adapt the patterns to their own tasks.

[58:44](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3524s) The Go Language and the Evolution of Concurrency

The discussion shifts to modern languages, with Lex mentioning his interest in Go, Rust, and Julia despite never having used Go during his time at Google. Kernighan remarks that Go shares direct lineage with Bell Labs through co-creators Ken Thompson and Rob Pike, alongside Robert Griesemer, who brought the European computer science tradition from Niklaus Wirth’s school at ETH Zurich. Often labeled as a "C for the 21st century," Go retains familiar C-like syntax and light data structures while introducing modern safety and ergonomics.

```mermaid flowchart TD accTitle: Lineage and Concurrency Model of the Go Language accDescr: Diagram tracing Go's influences from Bell Labs and ETH Zurich to its concurrency model. subgraph Influences ["Design Influences"] BL["Bell Labs: Ken Thompson & Rob Pike"] ETH["ETH Zurich: Robert Griesemer"] end subgraph Core ["Go Language"] CStyle["C-like Syntax & Data Structuring"] CSP["Communicating Sequential Processes (Tony Hoare)"] BL --> CStyle ETH --> CStyle CSP --> GR["Goroutines & Channels"] CStyle --> Go["Go Language"] GR --> Go end ```

Kernighan—who co-authored *The Go Programming Language* with Alan Donovan (whom he credits with doing roughly 90% of the book's heavy lifting)—points out that Go’s crowning achievement is its concurrency model: “Go provides a very nice model of concurrency it's basically the cooperating communicating sequential processes that Tony Hoare set forth I don't know 40-plus years ago and go routines are to my mind a very natural way to talk about parallel computation.” When Lex asks if early C and UNIX pioneers anticipated massive multithreading, Kernighan responds that early systems did not need to confront that problem because single-core processor speeds steadily escalated for decades. Only when physical limits on heat generation and power consumption halted CPU clock scaling did the industry pivot toward packing multiple processor cores onto chips, making parallel concurrency mechanisms essential.

[01:01:57](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3717s) Exploring the Landscape: Testing 20 Languages on a Single Problem

Lex asks Kernighan whether it breaks his heart that he will never have the time to master the explosion of modern programming languages. Kernighan admits that while his heart is not broken, he is fascinated by exploring them through an empirical benchmark he uses in his Princeton spring programming course. To test a language, he implements a single, narrow task: a trivial text formatter that reads variable-length lines and wraps them to wrap at no more than 60 characters wide—similar to text flowing inside a web browser.

The problem requires roughly 15 lines of AWK code, and Kernighan has implemented it across more than twenty languages to evaluate their learning curves, execution speed, and syntactic verbosity: - **Lua**: Downloaded the runtime and completed a working program in under an hour relying purely on web documentation, having never touched the language before. - **Scala**: Found it equally straightforward and simple to get running quickly. - **Haskell**: Required several weeks of effort to write correctly and "ran like a turtle." - **Fortran 90**: Proved painful to work with, though it eventually functioned. - **Rust**: Took several days to get working because its ownership and explicit memory management paradigm felt completely unfamiliar.

[01:04:17](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3857s) Learning Rust and the Evolution of JavaScript

Brian Kernighan reflects on his earlier attempt to learn Rust. When he tried it several years ago, the ecosystem was moving at breakneck speed; documentation was inconsistent, and working examples frequently failed because the language had already changed underfoot. Although he believes Rust has stabilized and remains a language he would like to revisit, he suspects he probably never will, noting: “I think one of the issues you have to have something you want to do if you don't have something that is the right combination if I want to do it and yet I have enough disposable time whatever to make it worse than learning a new language at the same time it's never going to happen.”

Lex Fridman turns the discussion to JavaScript, recalling that when he was coming up in computing, JavaScript was widely viewed as “probably like the ugliest language possible,” yet it has steadily conquered both client-side and server-side computing and grown remarkably fast. Kernighan agrees with that trajectory: in its earliest days, JavaScript was notoriously irregular, and within academic departments, claiming to work on JavaScript would get a researcher ridiculed because it was considered completely unfit for serious study. Over time, both the language itself and compilation technology advanced dramatically, making it a viable and performant solution for full-stack systems. Kernighan has written modest amounts of JavaScript and experimented with translators, though he doubts it will entirely take over the world.

[01:06:28](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3988s) Modern Dependency Culture: The Risks of Package Ecosystems

Lex contrasts the modern development experience—heavily dependent on sprawling third-party ecosystems like Python and JavaScript packages—with the earlier UNIX and C ethos where engineers built nearly everything from scratch. Kernighan finds this shift deeply significant. In the early days, software relied on tiny, well-understood interfaces like `printf` or the standard C library. By contrast, modern workflows require pulling in massive dependencies sight unseen:

> “I've been doing some playing with machine learning over the last couple of days and G something doesn't work well you pip install this okay and down comes another gazillion megabytes of something and you have no idea what it was and if you're lucky it works and if it doesn't work you have no recourse there's absolutely no way you could figure out which in these thousand different packages and I think it's worse in the MPM NPM environment for JavaScript I think there's less discipline less control there...”

Beyond the cognitive impossibility of understanding thousands of nested libraries, Kernighan highlights the severe implications for software reliability and supply-chain security, prompting Lex to joke that one would never want to run a nuclear power plant on JavaScript.

[01:08:16](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4096s) Language Proliferation and the Role of Functional Programming

Lex asks whether the software world should eventually consolidate around a tiny set of two or three dominant languages rather than remaining fragmented across disparate communities (such as Ruby, Python, and C++). Kernighan strongly rejects this ideal, insisting that no single language can address every computing requirement: “I certainly don't hope it I'd not sure that that's right because I honestly don't think there is one language that will suffice for all the programming needs of the world.”

While roughly a dozen languages handle about 95% of real-world production code alongside thousands of niche alternatives, Kernighan values the proliferation of experimental languages because they serve as essential testbeds for powerful abstractions. Lex characterizes this space as a “playground for rebels.” Kernighan points specifically to functional programming as a fertile testing ground where concepts that once seemed computationally impractical—such as recursion in Lisp, first-class functions, closures, pattern matching, and lambdas—were refined before migrating into mainstream imperative and multi-paradigm languages.

[01:10:30](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4230s) Mathematical Programming and the Origins of AMPL

Lex brings up AMPL (A Modeling Language for Mathematical Programming), expressing admiration for its elegance and abstraction power, while playfully preempting Kernighan's characteristic modesty about his contributions. Kernighan quips that AMPL is useful “for minimizing functions,” before demurring that the credit belongs to his co-creators: Robert Fourer (a professor in Industrial Engineering and Management Sciences at Northwestern University) and David Gay (a numerical analyst and optimization expert at Bell Labs).

Kernighan explains that mathematical programming centers on constrained optimization: defining decision variables subject to systems of constraints (equalities or inequalities) to maximize or minimize an objective function. While textbook linear programming is neatly expressed as $Ax \le b$, real-world models produce massive, highly intricate, and extremely sparse matrices whose coefficient distributions obscure the original problem structure. AMPL was created to bridge this gap, offering a readable, high-level algebraic notation that mirrors how humans write mathematics on a blackboard while strictly decoupling the problem formulation from the underlying data and numerical solvers (whether linear, nonlinear, convex, or non-convex).

```mermaid flowchart LR accTitle: AMPL Separation of Concerns accDescr: Diagram showing how AMPL decouples the mathematical model, instance data, and backend numerical solvers.

subgraph UserSpec["User Specification"] M["Algebraic Model<br/>(Variables, Objectives, Constraints)"] D["Problem Data<br/>(Parameters & Sets)"] end

subgraph AMPL_Engine["AMPL Environment"] T["AMPL Translator & Presolver"] end

subgraph Solvers["Optimization Solvers"] LP["Linear / Simplex"] NLP["Nonlinear / Interior-Point"] end

M --> T D --> T T --> LP T --> NLP ```

- AMPL allows optimization experts and domain/data specialists to work independently on the mathematical formulation versus the parameter values. - Solvers are decoupled from the modeling language, allowing users to swap between linear, nonlinear, convex, and non-convex optimization engines without rewriting the core mathematical model. - Prior to AMPL, earlier efforts like GAMS (General Algebraic Modeling System) had begun exploring domain-specific algebraic modeling languages to bypass manual matrix generation.

[01:14:19](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4459s) The Genesis and Architecture of AMPL

In 1984, Robert Fourer spent a sabbatical year at Bell Labs, occupying the office directly across from Brian Kernighan. Kernighan points out that progress often comes down to pure proximity: “it's always geography.” Bob Fourer, Dave Gay, and Kernighan began discussing the awkwardness of existing algebraic modeling systems, which were clunky and heavily resembled Fortran. Fourer envisioned a clean language that mirrored the mathematical notations written on a blackboard—such as summations over sets—and translated those high-level algebraic declarations into a matrix representation to be handed off to an external solver.

Kernighan wrote the very first prototype of AMPL (A Modeling Language for Mathematical Programming), which also happened to be his first C++ program. It was relatively compact—around 3,000 lines of code—but it demonstrated the feasibility of decoupling the human-readable problem formulation from both the underlying data and the specialized numerical solver. A single model could be reused across vastly different data sets without restructuring the mathematical logic.

```mermaid flowchart LR accTitle: AMPL Pipeline Architecture accDescr: Pipeline showing human readable AMPL model and data entering the AMPL translator, feeding into a solver, and returning readable solutions. subgraph Input ["User Specifications"] M["Algebraic Model<br>(AMPL notation)"] D["Input Data Sets"] end subgraph Engine ["AMPL Processing"] T["AMPL Translator<br>(Prototype in C++)"] end subgraph Backend ["Solver Execution"] S["Numerical Solver<br>(Linear / Non-linear)"] end M --> T D --> T T -->|"Matrix & constraints"| S S -->|"Raw numerical results"| T T -->|"Interpreted solution<br>(e.g., quantities to buy/ship)"| Out["Human-Readable Decisions"] ```

When Lex Fridman asks how difficult it is to bridge an algebraic specification with an optimization solver, Kernighan notes that it is manageable because most solvers accept models in standardized representations—either basic constraint matrices for linear programming or functional interfaces and constraint routines for non-linear models. AMPL takes the solver's raw output numbers and translates them back into the user’s original domain terms, telling practitioners how many items to produce, purchase, or ship. While Kernighan stepped back after 1984, he co-authored a book on AMPL, which Fridman praises as one of the best books ever written. Kernighan generously credits Fourer: “Bob wrote most of it and so it's really, really well done he must be a dynamite teacher.” Kernighan also reveals that the book was not typeset in LaTeX, but in `troff`, the Bell Labs formatting system created in the early 1970s that predates Donald Knuth's TeX family by five to ten years.

- **AMPL Origin**: Developed starting in 1984 at Bell Labs by Robert Fourer, David Gay, and Brian Kernighan. - **First Implementation**: Kernighan’s first C++ program, totaling roughly 3,000 lines of code. - **Core Principle**: Clear separation among the algebraic model, the input data, and the solver algorithms. - **Typesetting**: The AMPL book was formatted using Bell Labs' vintage `troff` system rather than TeX or LaTeX.

---

[01:18:01](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4681s) Graph Theory, Heuristics, and P vs. NP

Fridman pivots from system design to Kernighan's contributions to graph theory, asking him to place a bet on whether P equals NP. Kernighan promptly bets that P does not equal NP: “The answer is no, although I'm told that somebody asked Jeff Dean if that was the—what conditions P would equal NP, and he said either P is 0 or N is 1, or vice versa.” When asked whether he possesses an intuitive reason, Kernighan admits he relies on the consensus of expert theoretical colleagues who lean heavily toward P ≠ NP.

Kernighan explains that his work on computational hardness dates back to 1968—before the formal framework of NP-completeness existed. For his doctoral dissertation, Kernighan investigated the graph partitioning problem: given an edge-weighted graph, split the vertices into two equally sized sets while minimizing the total weight of the edges cut between them. Working alongside Shen Lin at Bell Labs, they could not devise an algorithm guaranteed to produce the optimal partition. Instead, they invented heuristic methods—notably the Kernighan–Lin algorithm—that yielded high-quality approximate solutions, while Kernighan isolated a few solvable special cases for his thesis.

```mermaid flowchart TD accTitle: Comparison of Graph Partitioning and Min-Cut accDescr: Diagram illustrating why graph partitioning is computationally hard due to equal partition size constraints compared to unconstrained min-cut. subgraph Easy ["Max-Flow / Min-Cut"] E1["Arbitrary Cut of Graph"] --> E2["No constraint on subset sizes"] E2 --> E3["Solvable in Polynomial Time (P)"] end subgraph Hard ["Graph Partitioning Problem"] H1["Bipartition of Graph Nodes"] --> H2["Strict constraint: equal subset sizes (|A| = |B|)"] H2 --> H3["NP-Complete (Heuristic needed: Kernighan-Lin)"] end ```

Kernighan emphasizes the contrast between graph partitioning and the standard maximum-flow/minimum-cut problem: without a constraint on partition sizes, minimum cut is polynomial and computationally easy, but demanding that the two subsets contain identical numbers of nodes turns it into an intractable, NP-complete problem. This practical work occurred right as Stephen Cook was formulating the foundational theories of NP-completeness.

- **Kernighan–Lin Algorithm**: A landmark heuristic for graph partitioning and the Traveling Salesperson Problem (TSP) designed to find near-optimal solutions quickly. - **Historical Timing**: Researched in 1968, predating Stephen Cook's 1971 paper that established NP-completeness. - **Theoretical CS Pivot**: When Fridman asks why Kernighan did not follow the Donald Knuth path of pure algorithm design, Kernighan self-deprecatingly responds: “Not smart enough... I just didn't have the talent for it.” He recalls briefly trying to work with future Turing Award laureate John Hopcroft at Princeton before concluding, “It became crystal clear I was not cut out for this stuff, period,” choosing instead to focus on building practical software and writing books.

---

[01:22:20](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4940s) 1964 and the Cycles of AI Optimism

Fridman asks about Kernighan's undergraduate senior thesis at the University of Toronto in 1964, which was a literature survey on artificial intelligence. Kernighan characterizes that era as an "AI summer"—the opposite of an AI winter. Researchers and writers widely believed that digital computers would soon solve virtually every high-level human intellectual challenge: automated language translation, grandmaster-level chess, and automated geometric theorem proving.

Kernighan recalls reading the 1963 anthology *Computers and Thought* (edited by Edward Feigenbaum and Julian Feldman), noting that he bought into the excitement: “I drank the Kool-Aid in some sense.” However, goals assumed to be right around the corner took nearly six decades of algorithmic iteration, vast increases in processing capacity, massive datasets, and interconnected open-source software ecosystems to achieve. While modern machines finally master Go and chess and handle complex translation tasks, progress was far slower than early pioneers imagined.

Reflecting on forecasting technological timelines, Kernighan invokes an observation from science fiction writer Arthur C. Clarke (Clarke’s First Law): “When some distinguished but elderly person says that something is possible, he's probably right; and if he says it's impossible, he's probably wrong.” This highlights the danger of near-term overconfidence alongside long-term technological pessimism.

- **1964 Senior Survey**: Conducted at the University of Toronto, examining early symbolic AI and cybernetics literature. - **Seminal Text**: *Computers and Thought* (1963), a foundational compendium that shaped initial optimism in machine cognition. - **Long-term Evolution**: Modern triumphs in machine translation and game playing required 50 to 60 years of hardware advances, massive empirical data, and ubiquitous global networking rather than quick algorithmic breakthroughs.

[01:24:41](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5081s) Machine Learning, Data Bias, and the Dream of Human-Level AI

Lex Fridman brings up the current resurgence of artificial intelligence, asking Brian Kernighan for his thoughts on this modern "summer of AI," marked by machine learning and deep neural networks. Fridman contrasts this new era—where systems absorb massive datasets to discover programs automatically—with the older paradigm of explicit algorithms and search heuristics. Kernighan prefaces his thoughts with self-deprecating humility, noting that he is far from an expert and that most of what he knows comes from his students, who are "probably disappointed in how little I've learned from them."

Kernighan recognizes the undeniable impact machine learning has had on fields like game playing, but he raises a profound caveat: these systems learn exclusively from the historical data supplied to them. If the training data reflects human biases—such as the historically entrenched and "flat wrong" premise that women are less capable than men at certain tasks—the algorithms inevitably learn, perpetuate, and scale those prejudices.

```mermaid flowchart LR accTitle: Data Bias in Machine Learning accDescr: Pipeline showing how historical bias in training data either amplifies societal harm or acts as a mirror for intervention.

subgraph Input ["Data Generation"] A["Historical Human Data"] -->|"Encodes social bias"| B["Training Dataset"] end

subgraph Model ["Machine Learning Model"] B --> C["Neural Network / Algorithm"] end

subgraph Outcomes ["Societal Impact"] C -->|"Pessimistic: Amplification"| D["Reinforced Past Injustices"] C -->|"Optimistic: Mirroring"| E["Exposes Latent Societal Bias"] end ```

When Fridman counters with an optimistic perspective—suggesting that machine learning can act as a mirror that forces society to confront and correct its flaws—Kernighan agrees that such an outcome would be wonderful, though he remains skeptical:

> “That's an optimistic point of view and if it works that way that would be absolutely great and and what I don't know is whether it does work that way or whether the the you know the AI mechanisms or machine learning mechanisms reinforce and amplify things that have been wrong in the past and I don't know I but I think that's a serious thing that we have to be concerned about.” — Brian Kernighan

Fridman then presses Kernighan on the grand, enduring ambition of artificial intelligence since the 1960s: building human-level or superhuman intelligence. When asked what it would take and whether humanity is close, Kernighan admits, "I haven't a clue." He references Alan Turing’s seminal early 1950s work proposing the Turing test, commenting that while the test is an interesting and somewhat objective benchmark, interpreting what it actually proves about intelligence is an entirely different matter.

---

[01:27:49](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5269s) Computing Everywhere and the Erosion of Privacy

Broadening the conversation, Fridman asks whether Kernighan feels excitement or dread about the ubiquitous expansion of computing into everyday human life. Kernighan reflects that while technology generally trends toward good over the long run, there are numerous cases where it produces severe short-term or long-term harms for specific groups.

He highlights corporate and governmental surveillance as an immediate, pressing threat. With social media and modern tracking technologies, an unprecedented amount of personal information is amassed and controlled by external entities—far more than any individual should reasonably feel comfortable with.

Fridman observes that attitudes toward data surveillance vary sharply across generations, noting that younger people often seem less anxious about privacy issues. Fridman speculates that within fifty years, evolving human psychology might alter or invert the public's perception of what constitutes a genuine privacy violation.

---

[01:29:45](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5385s) Moore's Law, Hardware Limits, and Declarative Programming

Fridman transitions to hardware constraints, asking whether Moore's law and exponential computing growth can continue indefinitely or whether a plateau is inevitable. Kernighan responds with a fundamental principle:

> “Well the furball is answer there's no exponential can go on forever you run out of something.” — Brian Kernighan

Kernighan explains that the nature of Moore's law has already changed dramatically. Raw clock speeds no longer increase vertically; instead, manufacturers scale chips horizontally by cramming more processor cores, cache, and memory onto a single die. Ultimately, this approach must bump into physical boundaries when circuit dimensions reach the scale of individual atoms. Fridman references a recent conversation with chip architect Jim Keller, who argued that transistor density could still shrink roughly a thousandfold before reaching insurmountable quantum limits.

Turning to software, Fridman asks how programming languages will adapt to these changing architectural limits. Kernighan predicts that the industry will increasingly move toward higher abstractions where code is generated by software rather than handwritten line by line:

- **Programs writing programs:** The act of writing software will increasingly belong to automated systems rather than manual human coders. - **Declarative over procedural paradigms:** Instead of writing detailed procedural steps specifying *how* a task must be accomplished, developers will express *what* end state they want, leaving the underlying language or system to determine the execution path. - **Broadening domain-specific tools:** The declarative approaches currently confined to narrow, specialized domains will slowly generalize into broader development environments.

---

[01:32:54](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5574s) Demystifying Tech: Teaching Non-Majors at Princeton

Kernighan reflects on his experience teaching "Computers in Our World" at Princeton, an introductory course designed specifically for non-engineering students, such as history and English majors. Addressing the common pedagogical debate over whether "everybody should learn to code," Kernighan demurs:

> “I think this is one of these questions of should everybody know how to program and I think the answer is probably not but I think everybody should at least understand sort of what it is so that if you say to somebody I'm a programmer they have a notion of what that might be or if you say this is a program or this was decided by a computer running a program that they have some vague intuitive understanding and an accurate understanding of what that might imply.” — Brian Kernighan

The curriculum focuses on deconstructing the black box of modern technology, explaining the fundamentals of: 1. How computer hardware processes information. 2. What a software program actually is and how code is structured. 3. How networked devices communicate with one another over modern digital channels.

Kernighan notes that while practically none of the humanities students who take the course go on to become professional software engineers, they leave with an accurate mental model of how computing impacts society. To ground this understanding, he does not start with high-level languages; instead, students are introduced to a simple toy machine model equipped with a tiny instruction set of roughly a dozen operations, on which they write simple assembly language programs to experience firsthand how machines execute instructions at the lowest level.

[01:35:06](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5706s) Levels of Abstraction: From Assembly to Modern Apps

Continuing his explanation of how he teaches non-technical students, Brian Kernighan reflects on where to set the floor of understanding. While one could theoretically keep drilling deeper down into physical gates and electrons, he draws the line at a simple instruction set architecture. He shows students that computers operate on a very small repertoire of fundamental operations—such as adding, subtracting, and branching. From there, he introduces layers of abstraction: higher-level languages like Fortran and C allow programmers to write software that is easier to comprehend and largely independent of specific hardware architectures.

Kernighan points out that users constantly interact with immense software systems without recognizing that they are built upon these very same basic principles. People run operating systems like macOS or Windows and download phone applications every day, taking them for granted. Lex Fridman observes how easy it is to forget that behind these everyday consumer tools are real engineers who wrote code. Kernighan acknowledges that it requires an enormous conceptual leap for a student to connect a five- or ten-line toy assembly program that adds two numbers to a modern mobile web browser, yet at the foundational level, they are fundamentally the same mechanism.

```mermaid flowchart TD accTitle: Levels of Computing Abstraction accDescr: Diagram illustrating how low-level operations build up to modern consumer applications.

subgraph LowLevel["Hardware & Machine Level"] A["Simple Operations<br/>(add, subtract, branch)"] B["Toy Assembly Language<br/>(5-10 line programs)"] A --> B end

subgraph Languages["Abstraction Layers"] C["Higher-Level Languages<br/>(Fortran, C, etc.)"] B --> C end

subgraph Applications["Everyday Consumer Scale"] D["Operating Systems<br/>(macOS, Windows)"] E["Modern Phone Apps<br/>& Web Browsers"] C --> D C --> E end ```

[01:36:35](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5795s) The Changing Nature of Human Interaction

Looking broadly at history, Fridman asks how computing has reshaped the world, noting how students on campus seem constantly glued to their devices. Kernighan reflects on the staggering transformation in how human beings interact both locally and across great distances. During his youth in the 1960s, placing a long-distance telephone call was a major event that cost significant money. Today, people routinely bypass voice calls entirely in favor of text messages, or casually hold regular video calls with friends and family on the other side of the planet without giving the underlying technology a second thought.

When Fridman asks whether this omnipresent connectivity brings people closer together or erodes genuine intimacy, Kernighan views the outcome as nuanced. On a personal level, technology has strengthened his family ties, allowing him to exchange messages with his brother and sister in Canada every two or three days—far more often than they would have spoken over the phone twenty years ago. Conversely, he observes students walking around campus with their heads down, buried in their smartphones to the point that passersby have to dodge out of their way. Kernighan cites sociological research suggesting that individuals may feel less genuinely connected today, musing that it sometimes makes one want to tell them to “wake up and smell the coffee.”

[01:38:57](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5937s) Hopes, Concerns, and the Societal Impact of Computing

Fridman asks whether Kernighan feels optimistic about the next ten to twenty years, considering that computers have expanded from virtually nonexistent machines to ubiquitous devices in nearly every hand worldwide, from Asia to Africa. Kernighan confesses that his outlook is mixed. While access to computing creates immense potential for people to improve their lives globally, he is troubled by the negative social patterns emerging in the short term.

He highlights the surge in tribalism and parochialism, noting that computing platforms frequently magnify an “us versus them” mentality. Furthermore, digital tools make it trivial to spread misinformation, misrepresent reality, or outright lie, which has destabilized local and global political systems. Fridman remarks that while giving marginalized populations a voice is profoundly empowering, granting every single person an unfiltered megaphone unleashes an unpredictable, chaotic reality. “Yeah, it’s kind of scary,” Kernighan agrees regarding the uncertain long-term consequences for society.

[01:40:27](https://www.youtube.com/watch?v=O9upVbGSBFo&t=6027s) The Golden Age at Bell Labs and the Creation of AWK

Fridman asks Kernighan if there is a particular transformative or profoundly happy moment in his career that he would choose to relive. Rather than selecting a single isolated day, Kernighan recalls the vibrant, collaborative environment of the 1970s at Bell Labs. It was a golden era when UNIX was young, the computing landscape was full of low-hanging fruit, and an tight-knit group of talented colleagues built software together. If someone engineered a utility, peers would eagerly test it out and offer feedback.

“I don’t think specific moments; I think there were lots and lots and lots of good times at Bell Labs where you would build something and it worked, and somebody used it, and they said, ‘Gee, that’s neat,’” Kernighan says. He mentions AWK as a prime example of building a tool that his colleagues quickly embraced. When Fridman points out that AWK is now used by millions of people worldwide, Kernighan wryly adds that having millions of users also means all your original mistakes are laid bare for everyone to see. Fridman concludes the interview by thanking Kernighan, calling the discussion an honor.

[01:41:53](https://www.youtube.com/watch?v=O9upVbGSBFo&t=6113s) Outro and Closing Thoughts

Following the conversation, Fridman thanks listeners and acknowledges episode sponsors Eight Sleep and Raycon earbuds. He encourages listeners to support the show via YouTube subscriptions, five-star reviews on Apple Podcasts, Patreon support, and Twitter interactions. He adds a humorous aside about his Twitter handle (@lexfridman), explaining that his surname is spelled without an "e" because his family was not particularly adept at spelling when they immigrated to the United States.

Fridman closes the episode by leaving listeners with a classic programming aphorism from Brian Kernighan: “Don't comment bad code; rewrite it.”

## Notable quotes > [01:41:53](https://www.youtube.com/watch?v=O9upVbGSBFo&t=6113s) Don't comment bad code; rewrite it. — Brian Kernighan

> [51:04](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3064s) As you write programs in a language like C, at some point scale gets to you, and it's too hard to keep track of the pieces, and there's no guardrails or training wheels or something like that to prevent you from doing bad things. — Brian Kernighan

## Mentioned Brian Kernighan, Lex Fridman, Ken Thompson, Dennis Ritchie, Rob Pike, Bill Joy, Alfred Aho, Peter Weinberger, Fernando Corbató, Richard Stallman, Linus Torvalds, Bjarne Stroustrup, Robert Griesemer, Alan Donovan, Tony Hoare, Niklaus Wirth, Robert Fourer, David Gay, Shen Lin, Jim Keller, Alan Turing, Donald Knuth, Bell Labs, AT&T, MIT, General Electric, Xerox PARC, Digital Equipment Corporation (DEC), Microsoft, Princeton University, University of Toronto, UNIX, Multics, CTSS, Plan 9, BSD, Linux, PDP-7, IBM 7094, MacBook Air, iMac, Sam, ed, vi, Emacs, QED, C, C++, Go, Rust, AWK, AMPL, Python, JavaScript, Fortran, COBOL, ALGOL, BASIC, Lua, Scala, Haskell, troff, TeX, Moore's law, Kernighan–Lin algorithm, The C Programming Language, The Practice of Programming, The Go Programming Language, UNIX: A History and a Memoir, Eight Sleep, Raycon

## Video description Brian Kernighan is a professor of computer science at Princeton University. He co-authored the C Programming Language with Dennis Ritchie (creator of C) and has written a lot of books on programming, computers, and life including the Practice of Programming, the Go Programming Language, his latest UNIX: A History and a Memoir. He co-created AWK, the text processing language used by Linux folks like myself. He co-designed AMPL, an algebraic modeling language for large-scale optimization.

Support this podcast by supporting our sponsors: - Eight Sleep: https://eightsleep.com/lex - Raycon: http://buyraycon.com/lex

EPISODE LINKS: Brian's website: https://www.cs.princeton.edu/~bwk/ Unix: A History and a Memoir (book): https://amzn.to/3fFJ1yM Understanding the Digital World (book): https://amzn.to/30ktBJI

PODCAST INFO: Podcast website: https://lexfridman.com/podcast Apple Podcasts: https://apple.co/2lwqZIr Spotify: https://open.spotify.com/episode/5OtSR9U7Nv9Ly9ixzmerrU RSS: https://lexfridman.com/feed/podcast/ Full episodes playlist: https://www.youtube.com/playlist?list=PLrAXtmErZgOdP_8GztsuKi9nrraNbKKp4 Clips playlist: https://www.youtube.com/playlist?list=PLrAXtmErZgOeciFP3CBCIEElOJeitOr41

OUTLINE: 0:00 - Introduction 4:24 - UNIX early days 22:09 - Unix philosophy 31:54 - Is programming art or science? 35:18 - AWK 42:03 - Programming setup 46:39 - History of programming languages 52:48 - C programming language 58:44 - Go language 1:01:57 - Learning new programming languages 1:04:57 - Javascript 1:08:16 - Variety of programming languages 1:10:30 - AMPL 1:18:01 - Graph theory 1:22:20 - AI in 1964 1:27:50 - Future of AI 1:29:47 - Moore's law 1:32:54 - Computers in our world 1:40:37 - Life

CONNECT: - Subscribe to this YouTube channel - Twitter: https://twitter.com/lexfridman - LinkedIn: https://www.linkedin.com/in/lexfridman - Facebook: https://www.facebook.com/LexFridmanPage - Instagram: https://www.instagram.com/lexfridman - Medium: https://medium.com/@lexfridman - Support on Patreon: https://www.patreon.com/lexfridman

[Source](https://www.youtube.com/watch?v=O9upVbGSBFo)

中文简报

柯林汉将Unix的崛起归功于汤普森的天才与大学授权模式 Unix征服现代计算领域靠的是肯·汤普森非凡的编程能力以及面向大学的低成本源代码授权,而非可预测的市场演进或开源规划。 布莱恩·柯林汉回顾了贝尔实验室诞生UNIX和C语言的历程,将其归功于肯·汤普森非凡的编程才能以及促进快速创新的紧密协作文化。他探讨了数十年来从汇编语言、Fortran到AWK、C++、Rust和Go等编程语言设计的权衡取舍,强调了为何没有任何单一语言能够满足所有计算需求。柯林汉还分享了他在AMPL、图划分及文本编辑器方面的研究心得,并评估了摩尔定律的演进,以及泛在计算、数据隐私和人工智能所带来的双刃剑般的社会影响。 1969年夏天,肯·汤普森仅用三周时间,就在一台废弃的DEC PDP-7上用纯汇编语言实现了UNIX的核心组件,包括定制汇编器、交互式文本编辑器、分层文件系统和进程管理器。 (14:07) 尽管AT&T Unix属于专有软件且拥有专利,但面向大学的低成本源代码许可推动了其在全球的普及,直接为伯克利Unix(BSD)、自由软件运动以及现代Linux内核铺平了道路。 (25:56) 布莱恩·柯林汉警告称,像npm和pip这样的现代包生态系统鼓励开发者引入不透明且庞大的依赖树,从而带来了巨大的安全与可靠性隐患。 (66:28) 柯林汉认为,社会并不需要每个人都成为程序员,但非编程人员必须建立起对基本计算抽象概念的直观理解,以便批判性地评估技术和自动化决策。 (92:54)

Reading summary

Computing pioneer Brian Kernighan reflects on how severe resource constraints, unified design abstractions, and tight collaborative feedback loops drove the foundational breakthroughs of UNIX, C, and domain-specific tools at Bell Labs. He balances appreciation for these enduring paradigms against modern concerns regarding sprawling software dependencies, pervasive data surveillance, and societal polarization. Minimalist Abstractions Born from Severe Hardware Limits (14:07) The early architecture of UNIX emerged directly from severe computational scarcity following Bell Labs' withdrawal from the complex, delayed Multics project in 1969. Ken Thompson implemented the original kernel, file system, process dispatcher, and editor on an obsolete DEC PDP-7 equipped with only roughly 16 kilowords of memory. Kernighan emphasizes that because bloated code could not physically run, developers were forced to generalize rather than invent bespoke special cases. Unified Models and Symbiotic Software Ecosystems (29:46) The quintessential outcome of this design restraint was the unified Unix file abstraction, which treated peripheral hardware devices, files, and later active processes through an identical read/write interface. This economy of design extended to programming languages: C succeeded because it paired high-level structured control with direct machine access, replacing brittle assembly across diverse hardware architectures. Furthermore, implementing UNIX and its toolchain in C established a self-reinforcing ecosystem where any system supporting UNIX inherently gained cross-platform portability for all C programs. Physical Co-Location and High-Impact Language Design (23:40) Kernighan attributes much of Bell Labs' productivity to rapid feedback loops anchored in physical proximity. Concentrated along a few hallways around a communal terminal room, developers conceived prototypes in the morning and gathered direct peer critique the next day. This environment nurtured purpose-built tools: AWK collapsed complex nested loops for line-by-line text processing into expressive one-line pattern-action scripts, while AMPL originated from informal hallway discussions with Robert Fourer and David Gay to decouple high-level algebraic models from backend numerical solvers. Modern Ecosystem Fragility and Software Scale (66:28) Contrasting the Unix ethos of small, well-understood interfaces with modern development practices, Kernighan warns against the risks of package-heavy dependency cultures like npm and Python's pip. Downloading hundreds of opaque packages to resolve minor functional requirements introduces severe vulnerabilities for supply-chain security and cognitive comprehension, leaving engineers powerless when systems break. Kernighan also rejects the idea that computing should consolidate into two or three universal languages, noting that experimental and functional paradigms remain essential incubators for language concepts such as closures, lambdas, and modern concurrency models like Go's channels. Pervasive Surveillance and Computing's Societal Footprint (87:49) While Kernighan acknowledges that computing has enabled unprecedented global connectivity, he expresses deep reservations regarding corporate surveillance, automated data gathering, and platform-driven tribalism. He cautions that machine learning inevitably mirrors and amplifies historical societal biases present in training data. In teaching introductory technology to non-engineers at Princeton, Kernighan focuses on demystifying hardware instructions and software abstractions so citizens understand the mechanical reality behind automated decisions rather than viewing computers as black boxes. Looking back over five decades of computing history, Kernighan maintains that technological shifts are rarely predictable through grand visions, but rather stem from serendipity, pragmatic engineering, and evolutionary steps. He leaves open the unresolved question of how modern societies will effectively govern pervasive digital tracking and algorithmic bias without sacrificing the expressive utility that computing tools afford.

精炼阅读摘要

计算机科学家布莱恩·柯林汉(Brian Kernighan)在访谈中指出,UNIX、C语言及相关工具之所以能在半个世纪中奠定现代计算的基础,核心在于早期极度受限的硬件迫使设计者追求极简与统一抽象,并通过紧密的物理协作形成了以开发者为中心的社区生态。 硬件约束与统一抽象的威力 (29:46) 柯林汉回顾,UNIX最初由肯·汤普逊(Ken Thompson)在已被淘汰的DEC PDP-7小型机上用汇编语言独立开发而成,当时该设备仅有约16K字内存。由于严苛的硬件资源限制,开发者无法承载臃肿杂乱的设计,必须探索高度通用的抽象模型,而非针对单一场景堆叠特例。最典型的成果是将文件系统设计为极简且统一的读写接口,使操作系统能够将外设甚至运行中的进程(如/proc)均抽象为普通文件。这种设计哲学大幅降低了系统复杂度,让后续的开发者能够以更直观的方式处理复杂的底层交互。 贝尔实验室的物理协作与反馈回路 (21:26) 针对贝尔实验室的创新文化,柯林汉强调,UNIX并非为了解决某一特定工业任务而生,其首要目标是构建一个让程序员能高效编写工具并互通有无的社区。在互联网普及前,整个团队集中在仅两三条走廊和一间配备终端与咖啡机的公共活动室内。这种紧凑的物理空间带来了极高密度的面对面沟通与敏捷的反馈闭环:开发者早上构思的功能,傍晚写出原型,次日清晨便能从同事那里收到直率的使用评价。柯林汉也指出,外界常因幸存者偏差而将计算史归功于单一机构,但施乐帕克研究中心(Xerox PARC)和麻省理工学院(MIT)等机构同样做出了并行而关键的奠基性突破。 专用工具与正交组合的系统哲学 (35:18) 柯林汉所参与设计的AWK语言以及广泛应用的grep命令,体现了UNIX生态中通过简单模式处理复杂文本的核心范式。AWK通过将自动读取文件、逐行遍历、正则匹配及空格切分等高频操作内置为隐式默认行为,使得许多需要几十行Python代码的任务可以在一至两行脚本中解决。同样,C语言与UNIX的深度共生则构成了强大的正向增强反馈:C兼顾了底层硬件访问控制与结构化表达,而UNIX内核及其周边工具均由C编写,使得用C编写的软件具备了天然的跨硬件移植性,最终打破了早期汇编代码高度依赖特定机器架构的桎梏。 现代软件的依赖膨胀与生态演进 (66:28) 对比早期UNIX强调构建微小且透明的接口(如标准C库与printf),柯林汉对当今Python及JavaScript(如npm)生态中不可控的依赖链蔓延表达了深切忧虑。现代工程往往需通过安装命令引入数以千计来源不明的第三方包,不仅导致认知层面上完全无法审查其内部机制,更为供应链安全与系统鲁棒性埋下了隐患。在谈及编程语言前景时,他坚决反对将技术栈收敛为极少数通用语言的构想,认为多样化的实验性语言(如函数式编程社区)是探索闭包、高阶函数和模式匹配等前沿抽象必不可少的演进试验场。 计算泛化的社会影响与教学落地 (92:54) 柯林汉在普林斯顿大学面向文科非专业学生讲授通识课程时主张,普通公众并非必须学会写代码,但需要建立对计算本质的理性认知,以破除对“算法决定”的技术迷信。他通过极简指令集的玩具机器模型展示现代应用的底层运行机制。面对人工智能与移动互联的全面渗透,柯林汉表达了矛盾的心态:虽然数字化极大便利了个人沟通,但海量个人隐私被外部机构掌控、训练数据将历史社会偏见无限放大,以及算法推波助澜的群体部落化与虚假信息传播,都正在对公共生活构成严峻挑战。 柯林汉的观察表明,技术演进在很大程度上取决于偶然的时代契机与物理邻近性,而非预设的宏大蓝图。随着摩尔定律逼近原子尺度与物理极限,软件开发势必进一步迈向高阶声明式与自动化生成;然而,早期UNIX所崇尚的模块化、工具正交性及对底层细节的敬畏,仍然是应对当下日益臃肿的软件体系不可或缺的解毒剂。

Detailed notes — zh

## Background 该视频由 Lex Fridman 于 2020 年 7 月 18 日发布在 YouTube 频道上(播客第 109 期)。根据节目简介,本期对话嘉宾是普林斯顿大学计算机科学教授 Brian Kernighan,他不仅与 C 语言之父 Dennis Ritchie 合著了传世名著《C 程序设计语言》,还参与创造了 AWK、设计了大规模优化建模语言 AMPL,并著有《程序设计实践》与《UNIX:一段历史与回忆》等多部重要著作。 ## TL;DR 在访谈中,Brian Kernighan 详尽回顾了从打孔卡批处理到分时系统的演进历程,以及 Ken Thompson 在 PDP-7 上利用三周雏形催生 UNIX 的历史细节。他阐释了 UNIX 将“一切皆文件”作为抽象基础、建立开发者协作社区的核心哲学,并梳理了 C 语言、AWK、AMPL 等经典工具的设计基因与其在效率和表达力上的黄金平衡点。此外,Kernighan 还横向对比了从汇编、Fortran 到 Go、Rust、JavaScript 等现代语言的生态流变,探讨了 P 对 NP 问题与早期图论探索,并反思了当代机器学习中的数据偏见、现代海量第三方依赖的安全隐患,以及泛在计算对人际社会联结的复杂影响。 ## Atmosphere & style 整场对话洋溢着对技术早期拓荒史的深情追忆与学者特有的谦和儒雅,Kernighan 虽身为奠定现代软件基石的泰斗,言辞间却始终将诸多划时代的突破归因于“纯粹的盲目运气”与同事的天才。Fridman 带着敬畏与求知欲引导话题,两人在严谨的技术原理剖析与风趣幽默的历史逸事之间自如切换。听众仿佛置身于当年贝尔实验室弥漫着咖啡香气的走廊,既能真切触摸到早期黑客在极简硬件上构建系统的纯粹快乐,又能感受到一位计算机元老对现代技术盲目膨胀、算法偏见与隐私侵蚀的深刻自省与理性审慎。 ## Bulletin - [14:07](https://www.youtube.com/watch?v=O9upVbGSBFo&t=847s) Brian Kernighan 回顾了 UNIX 的起源:在贝尔实验室退出 Multics 项目后,Ken Thompson 仅用三周时间便在一台闲置的 PDP-7 小型机上用汇编语言写出了 UNIX 的最初雏形。 - [53:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3198s) C 语言与 UNIX 形成的互促飞轮奠定了现代软件基石,而《C 程序设计语言》(K&R C)的诞生源于抢占先机确立行业事实标准的历史机缘。 - [35:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2118s) AWK 凭借“模式-动作”与全自动行处理循环的设计哲学,成为历经四十余年依然高效的命令行极简数据探索利器。 - [01:06:28](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3988s) Kernighan 警示现代开发中过度嵌套第三方黑盒依赖(如 npm 与 pip)带来的系统脆弱性与安全隐患,并强调编程本质上是受现实约束驱动的工程学科。 ## Key takeaways - [04:25](https://www.youtube.com/watch?v=O9upVbGSBFo&t=265s) 打孔卡批处理极其低效,而以 CTSS 为代表的分时技术通过毫秒级 CPU 时间片轮转,赋予了用户独占巨型计算机的划时代交互幻觉。 - [14:07](https://www.youtube.com/watch?v=O9upVbGSBFo&t=847s) UNIX 诞生于 Multics 退出后的算力断档期,Ken Thompson 在三周内以汇编语言独立打造出包含核心文件系统与工具链的操作系统雏形。 - [21:26](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1286s) 贝尔实验室紧密的物理走廊空间与鼓励尝试、戏谑官僚的叛逆极客文化,催生了高频面对面的即时反馈闭环与正向创新飞轮。 - [27:07](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1627s) UNIX 从未以开源名义发布,但 AT&T 向全球高校近乎免费分发源码专有许可证的做法,客观上培育了整整几代深刻理解其架构的技术人才,为后来的 Linux 奠定了共识基础。 - [29:46](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1786s) 早期极度匮乏的硬件资源逼迫 UNIX 团队追求极致泛化,从而孕育了以 open、read、write、close 统一驱动外设的“一切皆文件”优雅字节流抽象。 - [32:01](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1921s) 编程兼具探索意图的“艺术”与算法效率的“科学”,但在更大程度上是一门必须在运行时间、维护成本与交付周期等约束下寻求权衡的“工程”。 - [35:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2118s) AWK 将四重嵌套循环(文件、行、字段、正则匹配)隐式封装,以极简的“模式-动作”范式大幅降低了纯文本切片与探索性数据分析的心智负担。 - [46:40](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2800s) 高级语言的核心民主化价值在于打破人与特定底层硬件的物理绑定,让任何愿意学习通用表达的人都能编写跨平台程序。 - [52:48](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3168s) C 语言找到了贴近底层硬件控制与自然语法表达力之间的黄金平衡点,并借助作为 UNIX 操作系统及其工具链载体的生态共生实现了长盛不衰。 - [56:28](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3388s) 优秀的教学范例(如“Hello, World”和文本流转换)不应空洞罗列语法,而必须贴近真实程序员想要完成的实际工具构建场景。 - [58:44](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3524s) Go 语言承袭了贝尔实验室的工程血统,通过在语言层内置基于 CSP 理论的 Goroutine,优雅且高效地解决了多核时代的并发编程难题。 - [01:06:28](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3988s) 现代开发中由 npm 和 pip 驱动的无节制黑盒第三方依赖树拉取,严重削弱了底层代码的可追溯性,带来了极大的调试障碍与安全漏洞隐患。 - [01:08:16](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4096s) 非主流的长尾语言(尤其是函数式编程)扮演了前沿思想孵化器的角色,孕育出的一等公民函数、闭包与模式匹配等概念最终反哺了主流命令式语言。 - [01:10:30](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4230s) AMPL 建模语言实现了数学代数模型、底层数据集与外部优化求解器之间的三层解耦,化解了现实工业优化中超大型稀疏矩阵晦涩不可读的痛点。 - [01:18:01](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4681s) 在理论计算机科学诞生前夕,求解带平衡约束图分割问题的挫折直接促成了工程实用的 Kernighan-Lin 启发式算法,也反映了理论研究与工程实践的分野。 - [01:24:41](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5081s) 机器学习由数据驱动的范式潜藏着严重隐忧:一旦历史训练数据中包含社会既有偏见或错误待遇,算法输出往往会进一步放大并固化这些不公。 - [01:32:54](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5574s) 大众教育无需强求每个人都成为专业程序员,但应通过微型计算机与汇编玩具模型打破黑箱认知,理解数字世界决策背后的机械逻辑与能力边界。 ## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=O9upVbGSBFo&t=0s) 访谈引言与传奇计算机科学家 Brian Kernighan 本期播客的对话嘉宾是普林斯顿大学计算机科学教授 Brian Kernighan。在现代计算机科学的奠基时期,他是贝尔实验室(Bell Labs)的核心人物之一,与 UNIX 操作系统的联合缔造者 Ken Thompson 和 Dennis Ritchie 并肩工作。Kernighan 拥有极度耀眼的学术与工程履历:他与 Dennis Ritchie 共同编写了被誉为“C 语言圣经”的《C 程序设计语言》(*The C Programming Language*,即著名的 K&R C),撰写了《程序设计实践》(*The Practice of Programming*)、《Go 语言圣经》(*The Go Programming Language*)以及历史回忆录《UNIX:一段历史与回忆》(*UNIX: A History and a Memoir*)。在工具开发方面,他参与创造了 Linux 和类 UNIX 系统中广泛使用的文本处理语言 AWK,还参与设计了用于大规模优化的代数建模语言 AMPL。 主持人 Lex Fridman 在开场中表达了对 Brian Kernighan 的极高敬意,直言其贡献数不胜数,但最令人敬佩的是他的为人修养。关于 Kernighan 的人格魅力,Lex Fridman 评价道:“I think I can keep going for a long time with his creations and accomplishments, which is funny because given all that he's one of the most humble and kind people I've spoken to on this podcast.” 在随后的赞助商环节中,Lex 穿插介绍了 Eight Sleep 智能温控床垫和 Raycon 降噪耳机,幽默地调侃了自己缺乏睡眠与缺少伴侣的现状,并笑称如果物理学家理查德·费曼(Richard Feynman)活在今天,肯定会戴着无线耳机一边做事一边收听 Joe Rogan 的播客。 - **核心成就与代表作**: - 图书著作:《C 程序设计语言》(K&R C)、《程序设计实践》、《Go 语言圣经》、《UNIX:一段历史与回忆》 - 编程与建模语言:AWK(三位创始人 Aho、Weinberger、Kernighan 中的“K”)、AMPL(代数建模语言) - 历史地位:贝尔实验室计算科学研究中心核心成员,长期任教于普林斯顿大学 --- ### [04:25](https://www.youtube.com/watch?v=O9upVbGSBFo&t=265s) UNIX 的起源背景与打孔卡批处理时代 访谈正式开始时,Lex 提及 UNIX 的诞生已有五十余年,并邀请 Kernighan 讲述当年 UNIX 诞生的历史脉络。Kernighan 幽默地感叹道:“如果我还能记起那么久远的事情的话……那确实是相当长一段时间之前了。”他指出,UNIX 的源头可以追溯到 1969 年贝尔实验室团队所经历的转折点。当时,一群研究人员刚刚结束了 Multics 项目的研发,而 Multics 本身又是麻省理工学院(MIT)兼容分时系统(CTSS, Compatible Time-Sharing System)的后续演进。Kernighan 笑称,追溯操作系统的源流就像是陷入了“时间的无限倒退”。 为了让现代听众理解分时系统出现的划时代意义,Kernighan 回顾了 1950 年代至 1960 年代初期的计算机运行模式。那时的计算机体积巨大,通常被放置在戒备森严的恒温大型机房中,但按当今标准衡量其运算能力却微乎其微。程序员唯一的交互方式是批处理(Batch Processing)与纸质打孔卡(Punch Cards)。开发者需要在厚厚的一叠卡片上打孔编写代码,将卡片堆送到机房柜台交给专业的操作员,然后陷入漫长而折磨的等待。谈及这种令人抓狂的低效开发周期,Brian Kernighan 形象地描述道:“So you would take a deck of cards, write your program on it, send it over a counter, hand it to an operator, and some while later back would come something that said, 'Oh, you made a mistake,' and then you'd recycle, and so it's very, very slow.” ```mermaid flowchart LR accTitle: 批处理与分时系统交互模式对比 accDescr: 对比早期的打孔卡批处理模式与革新后的分时多任务交互模式 subgraph Batch["批处理模式(1950s - 1960s)"] B1["编写打孔卡片"] --> B2["柜台移交机房操作员"] B2 --> B3["离线排队运行"] B3 --> B4["数小时或数天后返回报错"] B4 -.->|"重新打孔修改"| B1 end subgraph TimeSharing["分时共享模式(CTSS / UNIX)"] T1["交互式打字机终端"] -->|"键盘按键中断"| T2["操作系统分配时间片"] T2 -->|"毫秒级轮转切换"| T3["多用户并发响应"] T3 -->|"即时错误反馈"| T1 end ``` --- ### [06:00](https://www.youtube.com/watch?v=O9upVbGSBFo&t=360s) 分时系统的诞生与 CTSS 的技术架构 分时技术(Time-Sharing)的核心思想彻底颠覆了人机交互机制。其核心逻辑在于:主机依然是昂贵的中央计算资源,但允许多名用户通过类似于电动打字机(电传打字机/终端)的设备远程或近程接入系统。操作系统的主要职责变为快速调度,为每一个发起请求的用户分配极短的 CPU 时间片(Time Slice)。例如,当某个用户正在编辑文本时,终端每输入一个字符,操作系统就会唤醒并记录该按键,随后迅速切换去处理另一名用户的计算任务。由于机器的处理速度远快于人类的按键反应,调度器在多个用户之间高速轮转,使得每位操作者都产生了一种独占整台巨型计算机的完美幻觉。 谈及这种体验的飞跃,Kernighan 赞叹道:“If it were well done and if it were fast enough, and other people weren't doing too much, you did have the illusion that you had the whole machine to yourself, and it was very much better than the punch card model.” 在所有早期分时尝试中,麻省理工学院研发的 CTSS 是最具代表性的系统。该系统大约成型于 1964 年,由图灵奖得主 Fernando Corbató(被同事们亲切地称为“Corby”,于 2019 年底逝世)领导开发。Kernighan 曾在 1966 年夏天以实习生身份在剑桥体验了 CTSS,并对其留下了极佳的印象。 - **CTSS 硬件平台与规格**: - 核心主机:经过特殊定制改装的 IBM 7094 大型机。 - 内存配置:打破当时单内存存储库的惯例,配备了两个 32K 机器字(words)的存储体(Banks)。 - 数据字长与容量:每个机器字为 36 位(bits),每个 32K 存储体折合现代容量约为 144 KB 至 150 KB,总内存大约 300 KB。 - 时代背景:在 1960 年代中期,磁芯内存极其昂贵,300 KB 已属罕见的“豪华巨额配置”,而如今这一数字在现代硬件规格中早已被视作微不足道的噪点。 --- ### [08:31](https://www.youtube.com/watch?v=O9upVbGSBFo&t=511s) Multics 项目与早期的“计算公共设施”构想 当 Lex 追问早期分时调度算法的内部细节与复杂指标时,Kernighan 坦诚且风趣地回答:“答案是我完全不知道(The answer is I don't have a clue)。”他解释称,调度器的基本逻辑非常朴素:核心就在于统筹当前谁有任务需求。如果在深夜系统空闲,单个用户便能独占全部计算资源;如果是在正午的高峰并发时段,系统采用的最基础算法便是轮转调度(Round-Robin),在各个进程间均分时间片,或者根据进程的具体行为(如轻量级的文本编辑交互还是高负荷的程序编译)动态微调优先级。 正是在 CTSS 取得成功后,贝尔实验室、MIT 与通用电气(GE)联合发起了 Multics 项目(全称为 Multiplexed Information and Computing Service)。Multics 的目标不仅是修补 CTSS 的不足,而是希望构建一个前所未有的庞大计算环境,其终极定位是一种“计算公共设施”(Computing Utility)——用户如同使用自来水或插入墙上插座用电一样,随时随地插上终端即可调用算力。Lex 指出,这实际上在五十年前就描绘了当今“云计算”(Cloud Computing)的蓝图。 Kernighan 赞同早期先驱确实拥有计算效用化、随取随用的超前构想,但他指出当时的视野与现代大众互联网仍存在时代局限性。关于当年研发团队是否预见到现代计算的普及程度,Kernighan 精准地总结道:“I'm betting that they didn't have the same view of computing for the masses, let's call it—the idea that, you know, your grandmother would be shopping on Amazon, I don't think that was part of it, but if your grandmother were a programmer, it might be very easy for her to go and use this kind of utility.” 这种公共设施当时主要是面向专业程序员与科研人员设计的,而非直接赋能大众消费级市场。 ### [10:51](https://www.youtube.com/watch?v=O9upVbGSBFo&t=651s) 贝尔实验室的传奇与环境 Lex Fridman 询问 Brian Kernighan 当年在麻省理工学院实习时,是否曾对计算机的未来有过梦想,能否预见到如今计算机的发展态势。Kernighan 坦诚而干脆地回答:“简短的回答是,完全没有;我毫无头绪。”(“short answer absolutely not I have no clue”)他解释说,自己当时并没有多么宏大的梦想,那只是一份梦寐以求的好工作(dream job):他打心底里喜欢自己所做的事情,周围全是极其优秀友善的人,而且剑桥市在夏天是一个极为宜人的地方——虽然冬天常会大雪纷飞。正是那个夏天的幸运经历,为他引荐了次年夏天在贝尔实验室(Bell Labs)的另一份实习工作。 对于这个诞生了众多计算机传奇的地方,Kernighan 详细介绍了它的地理位置与科研生态。贝尔实验室在当时分散于新泽西各处,其核心总部位于默里山(Murray Hill),横跨新泽西的两个小城镇(New Providence 与 Berkeley Heights),大致在纽约市正西方向 15 到 20 英里处。当时那里聚集了三四千名科研人员,其中绝大多数拥有博士学位,主要从事物理、化学、材料科学等基础物理科学的研究,同时拥有极其深厚的数学底蕴。随着人们意识到计算机可以建立实验模型、甚至取代部分物理实验室,实验室对计算技术的兴趣迅速攀升。 谈及贝尔实验室诞生了如此多的图灵奖与诺贝尔奖得主,Kernighan 指出其背后的特殊土壤:贝尔实验室隶属于 AT&T,而 AT&T 承担着全美电话服务的国家级重任。母公司的目标是为所有人提供优质通信服务,而贝尔实验室的核心使命则是让这项服务不断变得更好。这种使命驱使科学家们在极广泛的物理与工程领域展开前沿研究——从晶体管、光纤线缆到微波系统,而计算机科学正好在 1966 年左右(Kernighan 初入贝尔实验室时)迎来了爆发性增长的开端。 ### [14:07](https://www.youtube.com/watch?v=O9upVbGSBFo&t=847s) Multics 的退场与 UNIX 的诞生 UNIX 的诞生直接源于另一个雄心勃勃的宏大项目——Multics 的受挫。Multics 当时汇聚了麻省理工学院、贝尔实验室以及负责制造硬件的通用电气(General Electric)。尽管 Multics 孕育了大量的奇思妙想,并凝聚了一大批顶级人才,但 Kernighan 评价道,它在短期内(甚至在长远来看)都未能实现构建“信息公用设施”(information utility)的初衷:它过于昂贵,承诺交付的功能也严重拖期。大约在 1969 年初,贝尔实验室意识到这一项目在他们期望的时间尺度内无法落地,果断决定退出。 退出的决定让几位贝尔实验室的研究员陷入了尴尬境地:他们已经培养出了对极其舒适的交互式计算环境的品味,手头却没有可用的机器环境。于是他们开始在纸上推演,探讨如何设计一个既具备 CTSS 的舒适性、又能继承 Multics 优良特性的全新操作系统。此时,Ken Thompson 在实验室找到了一台鲜有人用的 PDP-7 小型机,并开始在上面做高效存储信息的文件系统实验。随后便发生了计算机史上著名的传奇一幕:Ken Thompson 的妻子带着一岁大的儿子回加州探亲三周,就在这短短的三周内,他独自坐下来编写出了一个操作系统的雏形,这最终演化为了 UNIX。Kernighan 幽默地感叹道:“那个年代的软件生产力真是惊人。”(“software productivity was good in those days”) ```mermaid flowchart TD accTitle: UNIX 的诞生脉络 accDescr: 展示从 Multics 项目退出到 Ken Thompson 在 PDP-7 上开发 UNIX 雏形的过程 subgraph Background ["研发背景"] M["Multics 联合项目<br/>(MIT / 贝尔实验室 / GE)"] W["项目进度延宕、成本过高<br/>1969 年初贝尔实验室撤出"] M --> W end subgraph Transition ["酝酿与实验"] N["研究人员失去舒适计算环境<br/>在纸上构思全新系统"] P["Ken Thompson 寻获闲置 PDP-7<br/>开展文件系统原型实验"] W --> N N --> P end subgraph Birth ["系统诞生"] K["妻子携子回加州三周<br/>Ken 集中开发系统核心与工具"] U["UNIX 早期原型诞生<br/>(汇编实现、精简实用)"] P --> K K --> U end ``` - **PDP-7 硬件概况**:由数字设备公司(DEC)于 1964 年推出,属于“小型机”(minicomputer)。内存容量极小(大约仅 16K 个 16 位字长),运算速度相对较慢,售价大约在 10 万美元左右。到了 1969 年,该机器已显陈旧,因此在实验室处于闲置状态。 ### [16:42](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1002s) 用汇编写操作系统的壮举与天才 Ken Thompson 针对主持人和公众常常产生的美化误解,Kernighan 澄清道,自己并未参与这一最初阶段的代码编写:“我从来没有写过操作系统的代码,所以我不清楚具体细节。”他进一步拆解了一个最基础的操作系统所需的核心结构:操作系统本身也是代码,最初的版本并不庞大,其核心功能是运行进程(执行编写好的代码)、在关机或重启后依然持久化保存信息(文件系统),以及在文件系统与内存之间调度加载可执行文件并收回控制权。为了支撑这套系统,Ken Thompson 还顺手编写了一套关键工具链,包括 PDP-7 汇编器以及用于创建文本的文本编辑器。这套系统完全用汇编语言写成,直到 1973 或 1974 年左右才用高级语言重构。 Fridman 提出疑问,在汇编语言下开发如此复杂的系统并考虑大局架构,听起来几乎是一项不可逾越的艰巨任务。Kernighan 坦承这确实非常困难:在汇编语言里一旦出错,系统没有任何防护机制或辅助提示(“there are no training wheels whatsoever”),程序崩溃了你只能一头雾水,而且连调试器本身都得自己动手实现。但他指出两点关键原因: 1. **系统体量较小**:当时的系统规模无法与今天同日而语,整体架构在认知上更易把控; 2. **程序员能力的悬殊**:Kernighan 评价 Ken Thompson 是编程界的“奇点”(singularity),并直率地说道:“绝无对你甚至是对我自己的不敬,他比我们高出好几个档次。”(“with no disrespect to you or even to me he's gonna die several leagues removed”) 回顾这套仅用三周雏形构筑、如今几乎驱动全球绝大多数计算机的 UNIX 体系,Kernighan 认为这根本无法被预测。当被问及这是历史的必然还是纯粹的运气时,Kernighan 回答:“我不知道这是不可避免的,还是只是一连串盲目的运气;我怀疑更多是后者。”(“I don't know whether it was inevitable or just a whole sequence of blind luck I suspect more the latter”)尽管 Dennis Ritchie 等人在贝尔实验室环境内贡献巨大,但如果要指出最初源头的那个人,那必然是 Ken Thompson。 ### [21:26](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1286s) 贝尔实验室的叛逆文化与非正式合作 贝尔实验室之所以是一个极富魅力的工作场所,很大程度上得益于聚集在此的一大批奇人异士,以及极为开放、自由且高度协作的氛围。如果你手头遇到了棘手或者有趣的难题,随时可以穿过走廊敲开别人的办公室门,对方就会坐下来和你一起推演解决方案。Brian Kernighan 笑着回忆,这里充斥着一种奇妙的趣味,大家热衷于尝试古怪的事物,甚至变着法子去“捉弄”和挑战公司刻板的官僚机构(bureaucracy)。对于这种带点叛逆的技术极客文化,Brian Kernighan 坦言: > “I think most people didn't take too kindly to the bureaucracy and I'm sure the bureaucracy put up with an enormous that they didn't really want to.” 这种对繁文缛节的不屑与管理层某种程度上的隐忍共存,为实验室日后诞生的重大创新提供了绝佳的温床。 --- ### [22:09](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1329s) UNIX 的核心哲学:构建属于程序员的社区 当 Lex Fridman 询问贯穿 UNIX 多年发展的核心哲学究竟是什么时,Brian Kernighan 纠正了一种常见的误解:UNIX 并不是为了某个具体的特定业务应用而构建的。尽管它后来被广泛用于文字处理(word processing)、实验室设备控制,或是充当大型笨重主机系统的前端,但它的设计初衷绝非专用的排版软件或工控系统。UNIX 的根本诉求,是提供一个让程序员写代码变得极为容易、高效的交互式环境。 Dennis Ritchie 曾指出,UNIX 真正的终极目标在于建立一个社区,让程序员们能够在这个系统上协同工作。正是因为系统极大降低了编程的摩擦力,程序员们开始自主开发各种有趣的小工具;而这些工具随即又被身边的其他同行采纳,进而激发了更多优质软件的诞生。这种正向的良性循环(virtuous circle),让 UNIX 从单纯的操作系统蜕变为一个紧密相连的技术共同体。 --- ### [23:42](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1422s) 早期黑客体验与物理空间的即时反馈闭环 谈到当年在早期 UNIX 上编程的感受,Brian Kernighan 兴奋地形容那简直“太痛快了”(it was a blast)。尽管他谦虚地声称自己算不上多么优秀的程序员,但在那个年代,计算机世界到处都是“唾手可得的低垂果实”(low-hanging fruit)。在友好的工具链、响应灵敏的系统以及顶级同事的加持下,软件迭代速度快得惊人:早晨冒出一个构想,白天写代码实验,当晚或次日清晨就能跑出一个粗糙但可用的原型。 在互联网尚未普及的岁月里,人与人之间的沟通依靠极其紧密的物理空间。贝尔实验室本质上是一座庞大的建筑,参与 UNIX 开发的核心人员主要集中在两三条走廊内,走廊尽头有一间大约 50 英尺见方(约 15 米 × 15 米)的活动室,里面摆放着终端机和一台咖啡机。同事们端着咖啡穿梭于各个办公室之间,直截了当地指出软件的问题:“这东西太棒了,但你在这里完全搞砸了。”这种面对面、周期极短的高密度反馈循环,让许多沿用至今的核心工具在短短几天内就迅速定型。 --- ### [26:17](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1577s) 历史的偶然、幸存者偏差与施乐 PARC 面对 Lex Fridman 对贝尔实验室空前绝后的赞叹,Brian Kernighan 保持了理性的审慎,指出这其中存在明显的“幸存者偏差”(survivor bias)。他强调,即使贝尔实验室没有创造出这些技术,同时代也有其他顶级机构在推进类似的先锋探索。其中最典型的代表便是施乐帕罗奥多研究中心(Xerox PARC),今天我们习以为常的大量现代计算概念都源自 PARC 的研究,只不过其母公司在商业转化层面没能充分把握住机遇;此外,MIT 等顶尖高校的研究实力同样不容小觑。 ```mermaid flowchart TD accTitle: 贝尔实验室与现代计算起源的关系 accDescr: 展示贝尔实验室、施乐PARC及高校在计算技术发展中的并行探索与交互影响。 subgraph BellLabs["贝尔实验室 (Bell Labs)"] direction TB BL_Env["开放协作与极简环境"] BL_OS["UNIX 操作系统"] BL_C["C 语言与核心工具链"] BL_Env --> BL_OS --> BL_C end subgraph OtherHubs["同时代创新先锋"] direction TB Xerox["施乐 PARC (图形界面/面向对象/以太网)"] Univs["顶尖高校 (MIT / UC Berkeley 等)"] end subgraph ModernComp["现代计算生态"] direction TB OpenEco["类 UNIX 系统 (Linux / BSD / macOS)"] GUI_OOP["现代 GUI 与工作站概念"] end BL_C --> OpenEco Xerox --> GUI_OOP Univs -.->|"技术交流与学术验证"| BL_Env Univs --> OpenEco ``` --- ### [27:07](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1627s) “伪开源”误解:源码授权与 Linux 的诞生脉络 针对外界常有的“UNIX 一开始就是开源软件”的印象,Brian Kernighan 明确给出了否定,称这是一种性质上的误读: > “I think that's a mischaracterization in the sense it absolutely was not open source it was very definitely proprietary licensed but it was licensed freely to universities in source code form for many years and because of that generations of university students and their faculty people grew up knowing about Unix.” 由于母公司 AT&T 当时受到反垄断监管,主营业务聚焦于电话通信,UNIX 遂以近乎免费的名义向全球大学分发包含完整源码的专有许可证。这导致整整几代计算机系的师生是在深入剖析 UNIX 源码的环境下成长起来的。当加州大学伯克利分校(UC Berkeley)在 Bill Joy 等人的带领下逐渐替换掉 AT&T 原生代码、打造出纯净的 BSD,并伴随 20 世纪 80 年代末至 90 年代初激烈的版权官司时,社区已积累了庞大的知识沉淀。随后 Richard Stallman 发起自由软件运动,1991 年 Linus Torvalds 开发出 Linux 内核。正因为 UNIX 的系统调用接口与工具设计早已深入人心,Linus 拥有了清晰的目标,最终促成了如今 Linux 事实性代表 UNIX 的格局。 - **法律与许可性质**:UNIX 在法理上完全属于 AT&T 的专有资产,但学术许可极其宽松,形成了“事实上的开源”社区氛围。 - **伯克利 BSD 的角色**:逐步用重写的自由代码替换专有源码,最终实现摆脱 AT&T 限制,期间经历了长达数年的法律博弈。 - **Linus Torvalds 的契机**:1991 年开发 Linux 时,标准的 POSIX/UNIX 系统调用和工具集已成行业共识,无需凭空设计架构。 --- ### [29:46](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1786s) 极简硬件塑造的高效性:“一切皆文件”的高度抽象 探讨 UNIX 架构何以兼具出色的健壮性(robustness)与运行效率时,Brian Kernighan 指出,这种优势并非凭空设计出来的,而是早期极其简陋的硬件条件所逼出来的自然结果。初代 UNIX 运行在算力微弱、内存极为狭小的机器(如 PDP-11)上,资源匮乏迫使开发者无法引入繁复冗余的特殊逻辑,必须千方百计寻找普适的泛化方案(generalizations),以单一机制解决多种问题。 最经典的范例莫过于 UNIX 的文件系统接口。通过将磁盘文件、外设设备乃至后续演进中的系统进程统一抽象为“字节流”(stream of bytes),开发者只需使用一套简单的 `open`、`read`、`write`、`close` 系统调用,就能驱动截然不同的硬件与资源。这种优雅的模型不仅大幅简化了系统内核,更让应用程序员能够毫无负担地构建复杂工具。后来在 20 世纪 80 年代末诞生的 Plan 9 操作系统中,贝尔实验室团队将这种“一切皆文件系统”的泛化理念推向了极致。当 Lex Fridman 感叹于这种高超的设计艺术并提到 Brian 的自我评价时,话题自然而然地转向了程序员的修养与代码审美的哲学思辨。 ### [32:01](https://www.youtube.com/watch?v=O9upVbGSBFo&t=1921s) 编程是艺术、科学还是工程? Lex Fridman 观察到 Brian Kernighan 身上散发着对编程的热爱,于是向他抛出一个经典问题:编程到底更偏向于艺术还是科学,是属于创造力还是严谨逻辑?Kernighan 回答道,编程兼具这两者的特质。“艺术”的部分在于搞清楚自己到底想做什么、程序应该长成什么样、以及什么才算是一个好程序,这需要深刻理解任务本身以及潜在用户的实际诉求。而“科学”的部分则是探寻如何把程序写好,涉及硬核的计算机科学知识,比如应该选用什么算法、怎样保证算法能正确运行与扩展,以及如何避免把本该是线性时间($O(n)$)的问题写成了二次方时间($O(n^2)$)的算法,数据结构的选择也是同理。 然而,Kernighan 进一步指出,编程在很大程度上其实更是一门“工程”(engineering)。工程与科学有着微妙但本质的区别:工程必须在各种实际约束下开展工作。作为工程师,你不仅要思考哪种算法在理论上最好,还得权衡在现有的计算时间和开发周期内哪种算法最合适,同时必须考量未来的系统维护,思考后续接手维护代码的人能否看懂。科学家也许可以把这些现实琐事抛到脑后,艺术家更是完全不必理睬,但身处工程领域就必须对这些约束负起责任。 当 Fridman 问及他个人的写代码习惯——是立刻动手敲代码边写边迭代,还是先拿出一张纸进行严谨的设计——Kernighan 直言自己的风格远比大学软件工程课教的那套要非正式得多: > “I don't write big programs at this point it's been a long time since I wrote a program that weighs more than I call it a few hundred or more lines something like that.” 他现在的编程多属于探索性质,要么是为了满足自己的某种好奇心,要么是为了给课堂教学准备实验案例,因此代码规模普遍在几百行以内。如今他写代码最常见的场景是“探索性数据分析”(exploratory data analysis)。面对一堆未知的原始数据,他往往会先用系统自带的基础命令行工具快速统计算量,或者写两三行 AWK 脚本切片观察数据特征;只有当程序逻辑变得更复杂、需要扩展到几百行时,他才会转向 Python。 --- ### [35:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2118s) AWK 的诞生、设计哲学与极简威力 话题顺理成章转到了 Kernighan 联合创造的著名脚本语言 AWK。AWK 是在 20 世纪 70 年代末由 Alfred Aho、Peter Weinberger 和 Brian Kernighan 共同研发的(名字即取自三人姓氏的首字母 A、W、K)。它诞生的初衷,就是为了让用户能够极其轻松地完成各种快速而粗糙的任务,例如在纯文本文件中计数、筛选出感兴趣的特定信息、重新排列数据格式或是生成汇总摘要。 Fridman 赞叹 AWK 至今依然被全天下的 Linux 用户广泛使用,其简洁优雅令人惊叹——往往只需在命令行敲出一行看似微不足道的脚本,就能瞬间切出关键数据维度,揭示出数据集底层的核心特征。Kernighan 坦言,当年他们创造这门语言时,完全没有料到这一模型对于大量数据处理任务会如此契合,更没想到它能历经 40 多年依然保持旺盛的生命力: > “Well this is paternal interest I guess, but I think in terms of programming languages you get the most bang for the buck by learning AWK and it doesn't scale to big programs, but it does pretty pretty darn well on these little things where you just want to see all the somethings in something.” 谈及 AWK 带来快乐的核心特质,Kernighan 强调是其“开箱即用”的默认行为设计。AWK 的执行模型本质上隐式包含了一个四重嵌套循环(quadruply nested loop):自动遍历所有输入文件、自动逐行读取每个文件、并在每一行上自动匹配用户指定的模式(pattern),匹配成功便执行对应的动作(action)。这种“模式-动作”(pattern-action)的范式极为自然高效,程序员完全不需要显式编写文件读取或循环遍历语句。此外,AWK 还免费帮开发者做好了诸多脏活累活:自动按空白字符将每行数据切分为不同的字段(fields),并在后台自动维护当前行号(`NR`)、字段总数(`NF`)等元数据。在 Python 里可能要写十行到二十行的逻辑,在 AWK 里往往一两行就能解决,因而可以直接在 Shell 终端里一气呵成。 ```mermaid flowchart TD accTitle: AWK Implicit Execution Model accDescr: The four nested processing steps executed automatically by AWK for each input stream. subgraph InputFiles["1. 文件级遍历"] F["遍历用户指定的输入文件列表"] end subgraph LineLoop["2. 行级遍历与字段切分"] L["自动逐行读取记录"] S["免费按空白符自动切分为字段 $1, $2... 并更新 NR, NF"] end subgraph PatternAction["3. 模式匹配与动作执行"] P{"是否命中 Pattern 正则/条件?"} A["执行对应 Action 代码块"] N["跳过,读取下一行"] end F --> L L --> S S --> P P -->|"是"| A P -->|"否"| N ``` - **AWK 的三位联合创造者**:Alfred Aho、Peter Weinberger、Brian Kernighan。 - **核心编程范式**:基于模式匹配与动作触发(`pattern { action }`),辅以全自动的行循环与字段分割。 - **适用场景与边界**:极其适合两三行的 Shell 快速即兴统计和探索性数据分析,但不适合扩展构建大型程序。 --- ### [38:40](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2320s) 从 grep 到 Windows/WSL 的环境变迁 在探讨 UNIX 命令行生态时,Fridman 询问 Kernighan 是否还有其他钟爱多年的 Shell 神器。Kernighan 毫不犹豫地提到了 `grep`。在他看来,`grep` 本质上可以视作 AWK 的一个极致简化版:两者共享了完全相同的底层心智模型,都是读入文件流并逐行匹配正则模式,只不过 `grep` 固化了单一模式(目标正则表达式)和单一动作(命中即打印)。事实上,在 AWK 里写一个一行脚本就能实现 `grep` 的功能。Kernighan 透露,由于其无可比拟的直观与便捷,`grep` 大概是他日常使用频率最高的一个工具。 Fridman 随后提出了一个疑问:为什么像 Windows 这样主流的操作系统,原本却没有自然诞生出类似 grep 或 AWK 这般优雅纯粹的文本处理工具,使得这种计算风格长期专属于 UNIX 和 Linux 生态?Kernighan 给出了解读: > “I think some of it's the weight of history that Windows came from MS-DOS, MS-DOS was a pretty pathetic operating system although common on an unboundedly large number of machines, but somewhere in roughly the 90s Windows became a graphical system and I think Microsoft spent a lot of their energy on making that graphical interface what it is.” 他指出,图形用户界面代表了一种截然不同的计算模型——基于鼠标点击、菜单探索和即时视觉反馈。对于非程序员的普通大众而言,图形界面非常有效,而强行向普通人推行命令行界面往往是一场痛苦的逆水行舟,从这个意义上说,微软当年的战略选择是完全合理的。 谈到如今跨平台的互通,Fridman 兴奋地提到了 WSL(Windows Subsystem for Linux,Fridman 在对话中半开玩笑地尝试将其拼读为 "whistle"),称能在 Windows 里顺畅跑 Bash 脚本改变了他的生活。Kernighan 则补充道,这类桥接工具其实已有悠久历史,例如 20 多年前就诞生的 Cygwin,它把 UNIX/Linux 上的全套趁手工具完好地搬到了 Windows 平台。直到现在,Kernighan 自己手头保留的那台唯一的 Windows 电脑上依然常备 Cygwin,只要涉及批处理或命令行操作,这套 UNIX 工具链对他而言依然是无可替代的最佳解法。 --- ### [42:03](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2523s) 硬件与编程装备的选择 当 Fridman 询问 Kernighan 心目中“完美的编程配置”(perfect programming setup)——包括电脑型号、操作系统、键盘以及文本编辑器时,Kernighan 笑着打趣说,“完美”这个词用在这里分量太重了,自己目前的配置其实只是各种现实需求权衡后的折中产物。 Kernighan 透露,自己目前默认使用的主力机是一台 13 英寸的 MacBook Air。在他看来,这款设备在各个维度上取得了极其舒适的平衡:机身轻便易于随身携带、计算性能完全够用、屏幕尺寸适中,键盘敲起来也过得去。正因如此,他绝大部分的日常计算和编码工作都是直接在这台便携笔记本上完成的。 ### [42:35](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2555s) 文本编辑器的演变:从纸带打印终端到图形化屏幕 Brian Kernighan 谈到自己的办公硬件配置:他在办公室放了一台大屏 iMac,主要在需要大显示器工作时使用,但平日里使用频次并不算太高。谈及代码编辑器,Kernighan 透露自己大部分时间都在使用 Sam,这是 Rob Pike 很久以前在贝尔实验室(Bell Labs)编写的编辑器。当被问及 Sam 是否早于 vi 时,Kernighan 澄清道,Sam 实际上晚于 vi 和 Emacs,它是 Rob Pike 结合了对 ed 和 vi 的使用体验后写出来的。而 ed 才是 Unix 上最初的编辑器,诞生时间“恐怕比你出生还要早”。 Lex Fridman 坦言自己是 Emacs 的忠实粉丝,甚至带着几分打趣自嘲自己误入了“嬉皮士圈子”,随后请求 Kernighan 梳理一下早期文本编辑器的演化史。Kernighan 从最早的分时系统(如 CTSS,Compatible Time-Sharing System)讲起:那个时期的编辑器(比如可能叫 edit)功能极其初级,仅仅能录入文本、保存并做些简单的修改。后来 Ken Thompson 编写了极其强大的 QED 编辑器。然而在那个年代,所有编辑器都是纯命令行驱动的,既没有鼠标,也没有光标——因为终端直接连接的是打印在纸上的打字机,根本没有 CRT(阴极射线管)显示器,更不用说 LED 屏幕了。 随着 Unix 的问世,Ken Thompson 将 QED 进行了极度精简,打造出著名的行编辑器 ed。作为一个面向行的编辑器,用户载入文件后,通过指定行号范围(如第 1 行到末行)来进行打印、插入、删除、修改或全局替换(substitute)。由于终端设备是真正的打印纸,“如果你改动了一行,你就必须把那一行重新打印出来,占用新的一行纸才能看清改了什么”。直到后来 CRT 屏幕终端普及,开发者才拥有了光标控制能力,可以在屏幕上任意移动位置修改字符,而无需每次都把整段内容重新打印在纸上。 ```mermaid flowchart TD accTitle: 文本编辑器演进历程 accDescr: 展示从早期的纸质打印终端编辑器到现代屏幕编辑器的技术演进脉络 subgraph PaperEra["纸质终端时代 (无光标 / 行编辑)"] CTSS["CTSS Edit<br/>早期分时系统"] QED["QED (Ken Thompson)<br/>功能极其强大"] ED["ed (Unix 原始编辑器)<br/>极度精简 / 命令行行编辑"] CTSS --> QED --> ED end subgraph CRTEra["CRT 屏幕时代 (光标控制 / 全屏编辑)"] VI["vi (Bill Joy, 1970年代末)"] EMACS["Emacs (约同期出现)"] SAM["Sam (Rob Pike)<br/>吸收 ed 与 vi 经验"] ED --> VI VI --> SAM end ``` - **vi 的诞生**:由 Bill Joy 在 1970 年代末打造,充分利用了光标控制机制,Kernighan 至今仍偶尔使用它。 - **Emacs 的定位**:几乎与 vi 在同一历史时期出现;Kernighan 表示自己从未真正深入掌握(internalize)过 Emacs。 - **获取 Sam 的途径**:如今依然可以在大多数现代操作系统上获取 Sam,通常可以从 Plan 9 操作系统的发行版源码中下载编译,社区一直在维护它。 - **编辑器的“宗教信仰”**:Fridman 笑称编辑器如同宗教,自己从小在 Lisp 和 Emacs 的文化熏陶中长大,尽管如今最常写的语言是 C、C++ 和 Python,但内心深处仍留存着对 Lisp 的信仰。 --- ### [46:39](https://www.youtube.com/watch?v=O9upVbGSBFo&t=2799s) 编程语言的演进:从纸带穿孔到高级抽象与系统级语言 Fridman 请 Kernighan 概述编程语言的整个发展史。Kernighan 追溯到 1940 年代末:最初人们通过控制台上的物理拨动开关或纸带上的穿孔输入 0 和 1 机器码,整个过程极其枯燥痛苦。到了 1940 年代末至 1950 年代初,最初的汇编语言诞生,程序员可以用助记符(如 `ADD`)替代二进制位模式,由汇编器负责繁杂的内存地址计算。每款硬件都有其专属汇编器(如 EDSAC、曼彻斯特机、IBM 704 / 7090 等)。汇编语言的指令与机器底层指令几乎是一对一的关系,这意味着程序员必须对硬件架构了如指掌;一旦更换机器,就必须彻底重写全部代码。 到了 1950 年代末,计算机学界意识到可以把抽象层次再往上推进一步,创造更贴近人类思维方式的“高级语言”。这一时期诞生了三大支柱:用于科学和工程计算的 Fortran(代表 Formula Translation,公式翻译);由 Grace Hopper 等人主导、面向商业事务处理的 COBOL(Common Business-Oriented Language);以及用于描述算法计算的 ALGOL。随后 BASIC 语言也很快问世。高级语言的出现带来了革命性的突破:编译器屏蔽了底层硬件差异,“你只需要写一次程序”,而且“任何愿意花时间学习编程语言的人”都可以直接编写代码,不再必须雇佣专业低级程序员,这极大地推进了计算编程能力的平民化与普及。 到了 1970 年代,为满足编写文本编辑器、汇编器、编译器以及操作系统本身等系统软件的需求,系统级编程语言应运而生。系统编程语言必须具备强大的底层控制力,能够精确操作内存、调用进程并支持多样的数据组织结构。Kernighan 指出,在当年那一批探索中,C 语言是唯一的真正幸存者。此后,随着软件工程规模不断膨胀,缺乏类型防护和模块封装的 C 语言在大型项目中变得极难驾驭,促成了 C++ 等面向对象语言的崛起。再往后,伴随着函数式语言(如 Lisp 分支)的发展,计算机界迎来了 Java、JavaScript 以及当代年轻开发者推崇的 Rust 等语言百花齐放的爆炸时代。 - **早期的反向输入历史**:Kernighan 提到刚去世的 Tony Brooker 曾在曼彻斯特大学开发过一种名为 Autocode 的语言;它取代了 Alan Turing 设计的系统——图灵的系统甚至需要因为硬件工作原理而将二进制 0 和 1 反向输入。 - **高级语言的核心民主化价值**:Kernighan 强调高级语言打破了人与机器的物理绑定:“它让编程的能力交到了像你这样的人手中——任何愿意投入时间学习编程语言的人,都不再被绑定在某种特定的计算机上。” - **系统编程语言的特质**:这类语言在保持相对抽象的同时,与底层机器硬件保持着敏锐的接触,支持对内存的精细掌控和多样化的原生数据结构。 --- ### [52:48](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3168s) C 语言的长盛不衰:表达力的黄金分割点 Fridman 指出,Kernighan 与 Dennis Ritchie 合著的《C 程序设计语言》(The C Programming Language,通常简称 K&R)是计算机科学史上最具影响力的著作之一,而 C 语言本身也是整个软件历史上最具影响力的基石。面对“C 语言究竟凭借何种优雅与力量历经数十年依然屹立不倒”的问题,Kernighan 给出了精辟的归因: > “我认为它找到了表达力上的一个黄金平衡点,让你可以用一种非常自然的方式来编写代码。” > —— Brian Kernighan C 语言既没有陷入汇编语言那种琐碎至极的机器细节泥潭,也没有被过于臃肿繁琐的抽象语法所束缚。它提供了恰到好处的控制力,在保证运行效率极致贴近硬件的同时,赋予了程序员极具美感且直接的表达自由,这也是它能从 1970 年代那场系统语言的竞争中脱颖而出并统治现代底层软件体系的关键所在。 ### [53:18](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3198s) C 语言与 Unix 的良性循环及《C 程序设计语言》的诞生 谈及 C 语言的成功,Brian Kernighan 指出其核心在于表达力与运行效率的兼备。在将近五十年前,计算机算力远不及今天,经历了摩尔定律大约四到五个代际(数十年)的演进,当时的每一分计算资源都弥足珍贵。除了语言本身的特质,C 语言还伴随着 Unix 操作系统的兴起。这意味着只要写出一个 C 程序,它就能运行在所有装有 Unix 的机器上,而由于 Unix 系统本身及其所有的配套工具都是用 C 语言编写的,使得整套生态彼此嵌入、相得益彰,形成了一种正向循环。 Lex Fridman 询问,Kernighan 与 Dennis Ritchie 合著的《C 程序设计语言》(The C Programming Language,常被称为“K&R”)可以说是所有编程语言书籍中最具权威性的一本,它不仅普及了这门语言,更确立了该语言的使用规范与编码范式。Fridman 问他当年写作时是否有这种宏大野心。Kernighan 笑着回应道:“那怎么可能,完全没有,这纯粹是时机、技巧和运气的巧合。” 1977 年两人动笔时,Unix 正在扩散,装机量从几十台增长到几百台,而 C 语言也开始出现在与 Unix 无关的其他计算机上,初显潜力。当时贝尔实验室是这门语言唯一的源头,市面上没有任何一本关于 C 的书籍。 由于 Dennis Ritchie 是 C 语言的创造者,并且已经撰写了一份极其出色的参考手册,具有无可置疑的权威性,Kernighan 于是“软磨硬泡直到他同意写书”。Kernighan 回忆说,抢先写出第一本书的巨大优势在于,后来者若想做任何事情都必须遵循你的标准。在两人的合作中,Dennis Ritchie 负责撰写附录中那篇行文极为严谨透彻的参考手册,而 Kernighan 负责大部分正文的讲解说明。随后两人像打乒乓球一样来回打磨书稿。Kernighan 花费了大量心血去寻找兼具连贯性与实用性的代码范例,力求在读者恰好需要某项知识的时刻,精准地呈现出来。 - **时代背景**:1970 年代硬件资源极度匮乏,C 语言的高效与可移植性成为关键优势。 - **合作分工**:Dennis Ritchie 全权撰写了精炼严谨的语言参考手册;Brian Kernighan 撰写了大部分阐述性内容并精心设计了教学示例。 - **历史地位**:抢占先机使该书成为了 C 语言事实上的规范与工业基石。 ```mermaid flowchart LR accTitle: C 语言与 Unix 生态的正向循环 accDescr: 展示 C 语言、Unix 操作系统与便携开发工具之间互相促进的飞轮机制。 subgraph Ecosystem["Unix 与 C 语言的协同发展"] direction TB C["C 语言<br/>兼顾表达力与极高执行效率"] -->|"编写与移植"| OS["Unix 操作系统<br/>实现跨硬件平台移植"] OS -->|"提供开发环境"| Tools["配套软件工具链<br/>均用 C 语言重写"] Tools -->|"丰富生态与推动普及"| C end ``` --- ### [56:28](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3388s) 代码范例的力量与“Hello, World”的哲学 作为名垂青史的“Hello, World!”示例的提出者,Kernighan 与 Fridman 探讨了优质示例代码在技术传播中的深远力量。Fridman 调侃道,即便几百年后外星文明造访地球废墟,找到一个半损坏的机器人,它向外星人发出的第一句通讯可能依然是“Hello, World”。对此,Kernighan 强调了一个好示例的核心标准:它必须告诉人们如何完成某项具体任务,并且必须具备代表性。 Kernighan 直言不讳地批评了许多现代编程书籍的糟糕做法:“其中有些完全是纯粹的语法罗列,比如‘这里告诉你怎么把三个数字相加’——拜托,这种东西我自己就能想明白;告诉我怎么把这三个数字读入计算机、怎么对它们做有用的处理,以及怎么把格式整理得漂漂亮亮地输出出来。”在《C 程序设计语言》中,他挑选的大多是非常简单、直接的文本处理问题,这正是典型 Unix 环境的日常写照: - 比如读取输入并原样输出,这是 `cp` 命令的原型; - 比如读取输入、过滤特定内容并输出,这是 `grep` 的原型。 Kernighan 认为,示例必须体现真实程序员会想要做的事情。读者在跟着步骤亲手敲出代码并运行成功时,会产生一种创造出有用工具的奇妙满足感。整本书的教学重心自始至终围绕着“读取文本、处理转换、写出文本”这条极其经典且实用的 Unix 哲学主线展开。 --- ### [58:44](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3524s) Go 语言的设计基因、并发模型与时代演进 谈到新一代编程语言时,Fridman 提到 Go 与 Rust 饱受赞誉,但他自己在 Google 工作期间从未用过 Go。Kernighan 幽默地回应:“那你可错过好东西了。”作为《Go 程序设计语言》(The Go Programming Language)的合著者,Kernighan 谦虚地表示,该书约 90% 的繁重工作其实是由 Google 的 Go 语言专家 Alan Donovan 完成的,自己并非顶尖的 Go 专家。 Kernighan 梳理了 Go 语言的纯正血统与设计脉络。Go 语言由 Ken Thompson、Rob Pike 与 Robert Griesemer 联合打造,它深度承袭了贝尔实验室的设计传统,同时融入了来自欧洲学派(尤其是苏黎世联邦理工学院 ETH Zurich 尼克劳斯·维尔特 Niklaus Wirth 派系)的严谨工程思想。在表层上,Go 常被形容为“21 世纪的 C 语言”,其语法风格与 C 非常相似;而在深层,它引入了极佳的数据结构化能力,尤其是优雅并发模型: - **CSP 理论实践**:Go 的并发范式建立在 Tony Hoare 四十多年前提出的通信顺序进程(CSP,Communicating Sequential Processes)之上。 - **Goroutine 的轻量高效**:Kernighan 称赞道:“Go 协程(goroutines)在我看来是一种表达并行计算非常自然的方式,而且在我做过的少数几次实验中,它们不仅易于编写、通常都能顺利运行,并且效率非常高。” Fridman 询问早期的 C 语言或 Unix 是否预见到了线程与大规模并行计算。Kernighan 直言:“我猜并没有真正预见到,或者即便注意到了,也还没到必须为此采取行动的地步。”他解释了硬件发展的历史转折:长久以来,单核处理器的运行频率不断提升,单线程程序自然跑得越来越快;然而受限于功耗与发热极限,主频无法无限制提升,硬件厂商转而堆叠更多核心,这才导致了线程与并行计算在现代软件开发中成为生死攸关的课题。 --- ### [01:01:57](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3717s) 用行包装程序“以武会友”:横跨二十余种语言的初体验 谈到层出不穷的现代新语言(如 Julia、Rust 等),Fridman 问他面对海量无法深入探究的语言是否会感到遗憾。Kernighan 坦言虽不至于心碎,但确实非常渴望亲自上手体验。为了在有限精力下感受各门语言的精髓,他在普林斯顿大学春季开设的编程课上设计了一个绝妙的“试金石”(他形容这就像武术中的套路 kata)。 这是一个极简的文本格式化程序:读取变长文本行,并将其格式化输出为每行不超过 60 个字符的段落(类似于网页浏览器排版文字的基础逻辑)。Kernighan 解释说,这个程序用 AWK 写只需 15 行,在其他语言中也基本差不多。他通过在不同语言中从零实现该程序,来横向对比不同语言的学习曲线、代码体量、执行速度与认知阻力: | 编程语言 | 学习与实现用时 | 体验感受与 Kernighan 的评价 | |:--- |:--- |:--- | | **Lua** | 约 1 小时 | 极其顺畅。此前从未写过 Lua,仅查阅在线文档便迅速跑通。 | | **Scala** | 极短时间 | 体验与 Java 近似,同样轻而易举搞定。 | | **Haskell** | 数周 | “花了我好几个星期,而且跑起来慢得像只乌龟。” | | **Fortran 90** | 过程痛苦 | 尽管过程充满折磨,但最终顺利跑通。 | | **Rust** | 数天 | 由于其独特的内存管理机制(所有权/借用检查器)较为陌生,花费了几天时间才调试成功。 | Kernighan 指出,学习一门新语言最难的往往就是迈出第一步。这种微型基准测试虽然切面极其狭窄,却能让开发者直观体会到语言的设计取舍。当谈及 Rust 时,其陡峭的学习曲线正是由其独特的内存管理模型所带来的。 ### [01:04:17](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3857s) 学习新语言的困境与 JavaScript 的崛起 谈及学习新语言的过程,Brian Kernighan 回顾了自己几年前接触 Rust 语言时的受挫经历。当时整个 Rust 生态处于剧烈演进中,官方文档缺乏一致性,网上找到的示例代码往往在本地安装的版本上完全无法运行。Kernighan 指出,学习一门新语言必须具备明确的动力与充足的闲暇时间,“如果你手头没有一件事能完美结合‘我非常想做’与‘我有充裕的闲置时间’,那么把时间花在学新语言上是永远不会发生的。”尽管他希望能重新研究 Rust,但他坦言自己可能再也不会去了。 随后,Lex Fridman 将话题转向了 JavaScript。Fridman 调侃道,在他成长受教育的时期,JavaScript 被普遍视为“最丑陋的语言”,但如今它不仅完全统治了前端,而且通过极具成效的底层优化进军后端,甚至有席卷整个计算世界的势头。Kernighan 赞同这一观察,并回忆起 JavaScript 初诞生时,学术界对它嗤之以鼻,若有学者声称自己在研究 JavaScript,甚至会招致同行嘲笑,被认为根本登不上大雅之堂。然而随着语言规范的演进以及编译与执行技术的飞跃式提升,JavaScript 已经演化为一个完全可行、表现优异的解决方案。虽然 Kernighan 并不认为 JavaScript 会彻底统领整个编程世界,但他肯定了它如今的成熟度与重要性。 - Rust 早期问题:文档不一致,版本更新迭代过快导致已有代码示例频繁失效。 - 早期学术界偏见:JavaScript 因语法规则不规整一度被学术圈鄙视,如今编译优化技术已彻底改变其地位。 - Kernighan 个人经验:他自己曾编写过适量 JavaScript 代码,并把玩过相关的代码转换器(Transpilers)。 > “I think one of the issues you have to have something you want to do if you don't have something that is the right combination if I want to do it and yet I have enough disposable time whatever to make it worse than learning a new language at the same time it's never going to happen.” —— Brian Kernighan --- ### [01:06:28](https://www.youtube.com/watch?v=O9upVbGSBFo&t=3988s) 现代第三方库依赖危机与生态管理 Fridman 提出,现代编程范式(尤其是 Python 和 JavaScript 生态)与 Unix 及 C 语言时代的“从零构建一切”存在根本差异——现代开发者极度依赖层层嵌套的第三方库。针对这种在他人代码上搭建软件的现状,Kernighan 表达了深切的忧虑。他回忆道,早期编程之所以充满乐趣,是因为程序员对所有底层逻辑了如指掌,当时所用的库仅限于标准库或 `printf` 之类的基础工具,规模极小。 而在今天的 Python 或 JavaScript 开发中,一旦代码报错,开发者的下意识操作往往是敲入 `pip install` 或使用 npm 下载依赖。伴随而来的,是数以百兆计完全未知的外部代码被拉取到本地,开发者对其内部逻辑毫无概念。Kernighan 指出,一旦底层依赖出现故障,面对成千上万个嵌套扩展包,开发者根本无从排查排错。特别是 JavaScript 的 npm 生态,缺乏严格的规范和准入纪律,这不仅带来了代码失控的问题,更带来了巨大的安全漏洞与鲁棒性隐患。Fridman 顺势打趣称,绝不能用 JavaScript 来控制核电站,Kernighan 也笑着认同了这一点。 ```mermaid flowchart LR accTitle: 传统编程模式与现代依赖驱动模式对比 accDescr: 对比早期Unix与C语言环境下完全自主可控的小型依赖开发,与现代Python和npm环境下下载海量未知黑盒依赖包的开发模式差异。 subgraph EarlyDays["早期传统模式 (Unix / C)"] direction TB A["自主从零编写核心代码"] --> B["极简标准库 (如 printf)"] B --> C["完全掌控与可追溯性"] end subgraph ModernDays["现代依赖驱动模式 (Python / JS)"] direction TB D["业务代码编写"] --> E["执行 pip / npm install"] E --> F["下载数百兆未知黑盒依赖"] F --> G["安全漏洞 / 故障难以调试"] end ``` - 传统模式:依赖库极少且透明,核心逻辑基本由作者亲自手写。 - 现代痛点:自动化拉取庞大依赖树(Dependency Hell),黑盒化严重,排错无门。 - 安全与工程风险:npm 生态纪律性匮乏,软件可靠性不足以支撑高危关键基础设施(如核设施控制)。 > “One of the reasons programming was fun in the old days was that you were really building it all yourself the number of libraries you had to deal with was quite small maybe it was printf or the standard library or something like that and that is not the case today.” —— Brian Kernighan --- ### [01:08:16](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4096s) 编程语言百花齐放的价值与函数式思潮 Fridman 询问,如今编程语言的分裂导致了社区割裂(如 Ruby、Python、C++ 社区各立门户),编程语言是否终究应该收敛为少数两三种主流工具。Kernighan 明确表示自己绝不希望看到语言的高度收敛,因为世界上没有任何一门单一语言能够覆盖人类全部的计算需求。 在 Kernighan 看来,现实中的编程语言分布遵循长尾效应:大概十几门主流语言承载了全球 95% 的实际开发,剩下的数千门语言虽然鲜有人高频使用,但它们的存在极有意义。新语言往往是探索前沿计算思想的试验田,最典型的例子便是函数式编程语言。尽管纯函数式语言自身未曾成为统治级的主流,但其社群在早期算力不足时探索的概念——从 Lisp 的递归,到一等公民函数(First-class functions)、模式匹配、闭包(Closures)和 Lambda 表达式——最终都被现代主流语言所吸收。Fridman 将其形象地比作“反叛者的游乐场”,Kernighan 深表赞同,认为游乐场本身虽非主流,但孕育出的思想价值不可估量。 - 市场分布:约 12 门主流语言占据 95% 的开发场景,其余 2000 余种长尾语言作为思想孵化器。 - 思想反哺:函数式编程孕育了递归、Lambda、闭包、模式匹配等范式,并持续输入主流命令式语言。 > “I certainly don't hope it I'd not sure that that's right because I honestly don't think there is one language that will suffice for all the programming needs of the world.” —— Brian Kernighan --- ### [01:10:30](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4230s) 数学规划建模语言 AMPL 的诞生与架构 Fridman 随后将话题引向 Kernighan 参与创造的另一项重要成果——AMPL(A Mathematical Programming Language,一种代数建模语言)。Fridman 盛赞 AMPL 在解决大规模优化问题时所展现的优雅抽象能力,并将 Kernighan 开玩笑式的“自我贬低贡献”双关为优化问题中的“极小化目标函数(minimizing functions)”。 Kernighan 详细解释了 AMPL 的本质及其解决的核心痛点。AMPL 是一门专用于数学规划(如线性规划、非线性规划、凸与非凸优化)的领域特定建模语言。在大学教学中,线性规划通常被抽象为极其简单的矩阵形式: $$\min / \max \quad c^T x$$ $$\text{subject to} \quad A x \le b$$ 其中 $A$ 为约束矩阵,$b$ 为约束边界向量,$x$ 为待求解的决策变量。然而 Kernighan 强调,在现实工业世界中,矩阵 $A$ 往往极其庞大且高度稀疏,模型中各组成部分在矩阵稀疏系数中的分布方式极其晦涩错乱,根本无法直接手工编写或人工维护。 人类习惯用代数符号表达问题(如“某项之和大于等于另一项之和”),因此急需一种将数学直觉转化为求解器可解析格式的高阶语言。AMPL 的核心设计理念实现了严格的三层解耦: 1. **模型定义**(目标函数与约束关系) 2. **底层数据集**(具体的参数与数值) 3. **求解引擎**(各类线性/非线性求解器,如 CPLEX 等) 这种分离允许优化专家、数据工程师和求解器算法专家各自专注于自身的专业领域。Kernighan 谦虚地指出,AMPL 的核心理论贡献主要归功于另外两位合作者:西北大学工业工程与管理科学系教授 Bob Fourer,以及贝尔实验室的数值分析与优化专家 Dave Gay,而他们此前参考的先驱系统则是世界银行开发的 GAMS。 - 核心痛点:现实优化问题的系数矩阵极其稀疏繁复,缺乏人类可读性。 - 架构解耦:将数学公式表达、数据集载入、后台求解器(Solver)三者彻底剥离。 - 创始团队:Robert Fourer、David Gay 与 Brian Kernighan。 > “The problem is that in the real world that matrix A is a very very very intricate very large and very sparse matrix where the various components of the model are distributed among the coefficients in a way that is totally non-obvious to anybody and so what you need is some way to express the original model which you and I would write.” —— Brian Kernighan ### [01:14:19](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4459s) AMPL 的诞生:从黑板代数到求解器代码 谈及代数建模语言(Algebraic Modeling Language)的起源,Brian Kernighan 回忆起当时的早期系统非常类似于 Fortran,显得相当笨拙笨重。转折点发生在 1984 年,当时正在休学术年假的 Robert Fourer(Bob Fourer)来到贝尔实验室,恰巧坐在 Brian 对面的办公室里。Brian 感叹这完全是“地理位置带来的机缘”(“it's always geography”)。Bob 加上 Dave Gay 和 Brian 三人聚在一起,开始探讨如何让建模变得自然。Bob 渴望设计出一种语言,能把数学家在黑板上随手画出的求和符号、集合关系等代数公式,直接转换成内部的数学矩阵,随后直接扔给后端的求解器(Solver)去计算。 Brian 承担了编写 AMPL 早期原型的任务,这是他写过的第一个 C++ 程序。整个原型系统仅约 3000 行代码,规模不大,却立竿见影地验证了概念的可行性:让用户用极度接近数学直觉的文本格式书写模型,系统负责解析并交付给外部求解器。AMPL 的核心优势在于将“模型结构”与“具体数据”彻底解耦,同一个通用模型可以套用完全不同的数据集来求解各种场景。Lex Fridman 对此深有共鸣,提到自己以前做优化项目时,甚至可以直接把可读性极强的 AMPL 模型文件发给完全不懂编程的同事看,对方一眼就能看懂问题的约束条件。 关于模型与求解器之间的转换难度,Brian 解释说由于大多数求解器都提供导入接口(无论是直接接收矩阵还是传入非线性约束的函数钩子),AMPL 所做的只是生成求解器能够解析的数据结构,真正的重活全由求解器搞定。待求解器计算出数值后,AMPL 再把数字映射回模型原本的业务语义中,告诉用户“该采购多少原料、制造多少产品或运输多少货物”。 三人后来合著了关于 AMPL 的经典书籍。Lex 盛赞那是他读过最优秀的著作之一,并好奇它是不是用 LaTeX 排版的。Brian 笑着反驳:“不,你在开玩笑吗?(No no no, are you kidding?)”他透露整本书完全是用贝尔实验室自主研发的 `troff` 排版的。Brian 指出 `troff` 诞生于 70 年代初,比 Donald Knuth 的 TeX 系列还要早五到十年,是 TeX 的真正先驱。 ```mermaid flowchart LR accTitle: AMPL 工作原理与架构 accDescr: 展示用户代数规范如何经由 AMPL 转化为矩阵传给求解器并映射回业务结果 subgraph User["用户交互层"] A["黑板数学代数规范<br>(集合求和、业务约束)"] --> B["AMPL 建模文本<br>(模型与数据严格分离)"] end subgraph Engine["AMPL 引擎处理"] B --> C["AMPL 原型系统<br>(约 3000 行 C++ 编写)"] C --> D["数学矩阵 / 约束函数"] end subgraph Backend["求解与反馈"] D --> E["底层独立求解器<br>(Solver)"] E --> F["输出原始计算数值"] F --> C C --> G["人类可读的业务解<br>(采购/生产/物流方案)"] end ``` --- ### [01:18:01](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4681s) 图论、P 对 NP 问题与早期复杂度探索 Lex 话锋一转,抛出了著名的千禧年大奖难题:如果必须下注,P 是否等于 NP?Brian 毫不犹豫地回答:“不(The answer is no)。”随后他幽默地转述了关于 Google 著名工程师 Jeff Dean 的段子:“有人问 Jeff Dean 在什么条件下 P 会等于 NP,他回答说要么 P 是 0,要么 N 是 1,反之亦然。”谈到对该问题的直觉,Brian 坦承:“我没有直觉,但我很多同事有直觉,他们的下注都是‘不’,这是大众观点(I have no intuition, but I've got a lot of colleagues who've got intuition and their betting is no)。” 在谈到计算复杂度理论时,Brian 坦言自己在该理论正式诞生之前就碰过这个领域了。1968 年,他在普林斯顿大学攻读博士学位,论文研究的是图分割问题(Graph Partitioning):给定一个带有边权重的节点图,如何将节点严格划分为两个大小相等的集合,使得跨越两边的边权重总和最小。 Brian 曾与贝尔实验室的 Shen Lin 合作,试图找到一种必定能得出最优解的方法,但始终未能成功。最终他们发明了在工程上极其有效的启发式算法(即著名的 Kernighan-Lin 算法,常用于图划分与旅行商问题)。就在那一时期,Stephen Cook 发表了里程碑式的理论,揭示出存在一类极难求解的复杂度分类,图分割正是其中之一。Brian 强调自己的工作完全早于该理论的成熟: - **无约束划分 vs 约束划分**:无约束的最大流最小割(Max-Flow Min-Cut)问题属于多项式时间可解的简单问题;而一旦加入“两边节点数量必须完全对等”的平衡约束,问题立刻沦为极难求解的 NP-Hard 问题。 - **理论与启发式的抉择**:当时根本没有“复杂度分类”的概念,他们只想找到能解决实际问题的确定性算法,在发现无路可走后便转向了启发式近似解。 --- ### [01:21:06](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4866s) 放弃理论计算机科学的自省 Lex 借用罗伯特·弗罗斯特(Robert Frost)关于“未选择的路”的名诗发问:是否存在某个平行宇宙,Brian 像 Donald Knuth 那样投身于纯粹的算法理论设计?Brian 自嘲地笑称原因很简单:“不够聪明(Not smart enough)。” 尽管 Lex 赞美他过分谦逊,Brian 还是认真回顾了自己的心路历程。当他初到普林斯顿读研究生、在第一年年底寻找研究方向时,曾短暂跟随图灵奖得主 John Hopcroft 学习工作。正是在那段经历中,Brian 意识到自己与顶尖理论家之间的差距:“非常清楚的是,我根本不是吃这碗饭的料(It became crystal clear I was not cut out for this stuff, period)。”认清自己的局限后,他果断转向了自己更擅长、也更享受的方向——脚踏实地编写程序,并最终撰写了影响一代代程序员的技术著作。 --- ### [01:22:20](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4940s) 1964 年的人工智能盛夏与历史轮回 谈话随后回溯到了 Brian 在多伦多大学读本科的岁月。1964 年,他完成了一篇关于人工智能(AI)的高年级论文文献综述。Lex 好奇在半个多世纪前,人们眼中的 AI 是怎样的愿景与蓝图。 Brian 回顾道,那根本不是“AI 寒冬”,而是“AI 盛夏(AI summer)”——一个充满无限盲目乐观的黄金年代。人们笃信计算机能搞定一切棘手难题:机器翻译、国际象棋对弈、几何定理证明等。当时有一本极具影响力的论文集叫《Computers and Thought》,里面的乐观氛围深深感染了包括年轻 Brian 在内的许多人。然而历史证明,当年被认为“几年内即可攻克”的技术目标,足足耗费了漫长的时间,有些至今才勉强摸到门槛。 对于跨越近 60 年的技术巨变,Brian 和 Lex 梳理了促成如今突破的关键要素: - **算力与硬件的翻天覆地**:芯片性能和硬件规模历经数十年指数级进化,为算法提供了算力基石。 - **海量训练数据**:现代系统能够从真正海量的数据中自主学习模式,这在 1964 年是不可想象的。 - **协作开发基础设施**:互联网基础设施和开源软件运动,使得全球开发者能够以前所未有的效率协同演进系统。 当被问及从当年狂热的盛夏到如今的技术演变中汲取了什么教训时,Brian 沉思后引用了著名科幻作家阿瑟·克拉克(Arthur C. Clarke)的经典定律: > “当一位杰出但年长的学者声称某件事是可能的时候,他几乎总是对的;但当他声称某件事是不可能的时候,他很可能是错的。” ### [01:24:41](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5081s) 现代机器学习的繁荣与数据偏见困境 Lex Fridman 将话题引向当前以机器学习和神经网络为核心的“AI 新夏”(New Summer of AI)。他指出,当下的 AI 研究范式与早期基于启发式和搜索算法的逻辑截然不同,完全转变为从海量数据中提取规律、让程序由数据中自动生成。Brian Kernighan 坦承自己远非这方面的专家,笑称自己的大部分知识都是从学生那里学来的,“他们可能还会对我学得这么少感到失望”。尽管如此,他肯定了机器学习在游戏等特定领域的巨大突破,但随即表达了强烈的隐忧:机器学习从人类喂给它的数据中汲取知识,一旦数据本身存在偏差或缺陷,模型学到的也将是错误的结论。 Brian Kernighan 举了一个具体的偏见例子:如果历史数据中潜藏着“女性在某些方面不如男性”这样荒唐且彻头彻尾错误的记录,机器学习机制便会在未来的预测中盲目延续这种不公。正如 Brian Kernighan 所警告的:“这纯粹是错的,但如果因为历史待遇的原因它出现在数据里,那么机器学习就会将它传播下去,这是个严重的隐忧。”(“that's just flat wrong but if it's in the data because of historical treatment then that machine learning stuff will propagate that and that is a serious worry.”)对此,Lex Fridman 提出了一个更加乐观的镜像假说,认为机器学习能像镜子一样映照出人类社会的顽疾,倒逼人类修正自我;Kernighan 虽然认可这是一种美好的设想,但他依然保持审慎,怀疑现实中的算法究竟是在帮助人类消除偏见,还是在不断强化并放大历史遗留的错误。 ```mermaid flowchart TD accTitle: 机器学习中数据偏见的双重影响路径 accDescr: 展示带有偏见的历史数据如何经由机器学习模型传播或被视为反思镜像 A["历史数据 (含社会既有偏见)"] --> B["机器学习模型训练"] B --> C{"算法输出与应用"} C -->|"担忧路径: 放大并固化"| D["放大并固化历史偏见与不公"] C -->|"乐观路径: 镜像反思"| E["映照社会问题,推动人类自我反思与修正"] ``` ### [01:27:00](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5220s) 通用人工智能的虚实与计算泛在化的隐私危机 当 Lex Fridman 询问实现人类水平甚至超人类水平的人工智能(AGI)究竟需要什么、人类离这一步还有多远时,Kernighan 干脆地回答:“我毫无头绪,我也不知道。”(“I haven't a clue and I don't know.”)他回顾了阿兰·图灵(Alan Turing)在 20 世纪 50 年代初发表的开创性论文及著名的图灵测试(Turing Test),评价图灵测试至少在某种模糊层面上提供了一个客观测试,但人们能否从中推导出关于真正智能的定论,则是另一回事。 谈话随即从纯粹的人工智能拓展到泛在计算(Computing everywhere)席卷全球所带来的冲击。Kernighan 观察到,虽然历史上大多数技术从长远来看利大于弊,但无论短期还是长期,都曾给部分群体带来负面代价。在当代计算世界中,最直接的危机便是隐私侵蚀。商业监控与社交媒体的极速膨胀,使得企业与政府对普通人的了解远远超出了令人舒适的界限。Lex Fridman 对此补充了心理学视角的观察:公众对数据隐私的焦虑程度与年龄层高度相关,年轻人对隐私的态度已发生显著变化,50 年后人类对于隐私的定义和焦虑很可能会彻底反转。 ### [01:29:45](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5385s) 摩尔定律的物理极限与编程范式的演进 针对计算系统指数级性能提升的规律,Lex Fridman 抛出了关于摩尔定律(Moore's Law)能否无限延续的讨论。Kernighan 引用了物理现实直截了当地指出,任何指数级增长都不可能永无止境地持续下去,“你总会耗尽某些东西”。他指出处理器的单核时钟频率早已不再提升,当前的半导体产业是通过水平扩展而非垂直提升来消化芯片面积红利,即在单颗芯片上塞入越来越多的核心与内存。尽管业界(如 Lex 提到的处理器架构师 Jim Keller)保持乐观,认为在触及单原子与量子物理极限前晶体管仍有千倍缩小的空间,但 Kernighan 认为终极的物理天花板客观存在。 在编程语言设计层面,Kernighan 预言硬件的演化并不会直接颠覆编程语言的核心构架,未来的演进将沿着过去数十年的轨迹继续向前推进: - **由程序编写程序**:越来越多的编程任务将由程序自身完成,而非人工手写。 - **声明式取代过程式**:开发模式将由过程式(Procedural)进一步转向声明式(Declarative)。开发者只需下达“我想要这个结果”的意图,底层机制自主推导“如何实现”。 - **专用领域走向泛化**:当前局限于特定狭窄领域的领域特定语言(DSL)抽象模式将逐步拓宽,形成更高层次的软件抽象层,让开发者彻底脱离底层琐碎细节的束缚。 ### [01:32:54](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5574s) 普林斯顿“数字世界”课程:给非专业人士的计算机通识 作为普林斯顿大学的资深教授,Brian Kernighan 介绍了自己专门为非计算机专业学生开设的通识课程《Computers in Our World》(以及基于该课程撰写的书籍)。谈及社会上热议的“是否每个人都应该学会编程”这一命题,Kernighan 表达了非常清醒且务实的态度:“我认为答案大概是否定的,但我认为每个人至少都应该理解它大致是什么。”(“I think the answer is probably not but I think everybody should at least understand sort of what it is.”) Kernighan 强调,这门课的目标绝非将历史学或英语文学专业的学生培养成职业软件工程师,而是要打破技术黑箱: - 当别人自称是程序员,或者听到某项社会决策“是由运行程序的计算机做出的”时,大众能够拥有准确且符合直觉的判断力,明白其背后的机制与边界。 - 课程系统解释计算机底层的运转逻辑、程序的编写过程,以及计算机之间如何进行通信与协同交互。 - 为了让学生亲手触摸硬件底色,Kernighan 甚至绕过了高级语言,设计了一台仅有约 12 条指令的“玩具机器”(Toy Machine),要求毫无理工科背景的学生亲手写一段微型的汇编语言程序,以此直观体会机器底层是如何逐条执行代码的。 ### [01:35:06](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5706s) 计算机底层的抽象层次与学生的认知跨越 Brian Kernighan 谈到他在教学中如何向非计算机专业学生解释计算机的工作原理。他认为从某种意义上来说,并不存在所谓的“最低层”,因为人们总能继续向下探究物理或硬件细节,但他划定的边界是指令集层次。计算机实际上只具备一套非常小且极其简单的指令库,诸如加法、减法、条件分支(branch)等。在那个层面上写代码就能驱动机器运转;接着人们引入了更高层次的抽象,也就是像 Fortran 或 C 这类高级程序设计语言,它们极大地减轻了编码负担,并摆脱了对特定机器硬件架构的强依赖。 随后,Kernighan 引导学生审视日常生活中时刻在运行、却鲜少被意识到也是程序的软件:笔记本上的 macOS 或 Windows、手机上下载安装的各类 App。在本质上,这些极其庞大复杂的系统和学生用五行、十行玩具汇编代码把两三个数字相加并无二致,全都是软件工程师一行行写出来的代码。Lex Fridman 感慨人们很容易忘记这一点,而 Kernighan 也坦言,要求学生从几行汇编玩具程序瞬间理解手机浏览器这样复杂的宏大软件,确实是一个巨大的概念跨越(conceptual leap),但它们的底层逻辑确实完全相同。 ```mermaid flowchart TD accTitle: 计算机系统的抽象层级 accDescr: 展示从微观机器指令到宏观现代软件应用程序的抽象与演进关系 subgraph HardwareLevel["底层指令执行"] A["基础机器指令<br/>(加法、减法、跳转分支)"] B["微型玩具汇编代码<br/>(5-10 行数值计算)"] A --> B end subgraph LanguageLevel["语言抽象层"] C["高级程序设计语言<br/>(C、Fortran 等)"] B -->|"抽象与解耦硬件"| C end subgraph ApplicationLevel["现代复杂系统"] D["操作系统<br/>(macOS, Windows)"] E["终端应用程序<br/>(手机浏览器、移动 App)"] C -->|"大规模工程构建"| D C -->|"大规模工程构建"| E end ``` ### [01:36:35](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5795s) 计算机革命对人际交往与社会联结的双重影响 Lex Fridman 询问从长远历史维度来看,计算机究竟给世界带来了怎样的改变,并指出当身处其中时很难看清全貌,最直观的现象就是如今的学生走在路上都在低头看屏幕。Kernighan 赞同计算机带来的改变极其剧烈,其中最显著的体现之一便是人与人之间交流方式的重塑——无论彼此身处近邻还是大洋两岸。Kernighan 回忆自己在 1960 年代处于学生年纪时,拨打一通长途电话是极其重大的事情,需要花费不菲的真金白银;而如今的人们几乎不再打电话,而是发短信或即时消息,随时随地与世界任何角落的亲朋好友进行高频文字交流、视频通话,甚至对这种便利习以为常。 针对 Lex Fridman 关于“这种数字化通信究竟是拉近了人与人的距离,还是剥夺了面对面接触的亲密感”的追问,Kernighan 认为答案因情境而异: - **亲情联络的加深**:Kernighan 提到自己与远在加拿大的哥哥和姐姐如今每隔两三天就会互发邮件通信,这比二十年前频繁得多(当时很少通电话),从这个角度来看,技术确实拉近了他们之间的关系。 - **物理现实中的冷漠与疏离**:但在普林斯顿校园里,Kernighan 看到学生们低着头摆弄手机走路,甚至需要别人侧身躲避他们以防相撞。Kernighan 强调自己不确定这是否真正拉近了年轻人之间的关系,并提到社会学研究显示人们在某种程度上其实比以往更加疏远,忍不住感叹道:“真想对他们说,‘拜托,醒醒吧,闻闻咖啡香吧’。” Kernighan 直言:“在那个年代打长途电话是一件大事,因为要花很多钱,那是六十年代的事;而今天人们都不打电话了,他们发短信之类的。”(“When I was, you know, the age of those kids, making a phone call to somewhere was a big deal because it cost serious money, and this was in the 60s, right? And today people don't make phone calls, they send texts or something like that.”) ### [01:38:57](https://www.youtube.com/watch?v=O9upVbGSBFo&t=5937s) 对技术未来的审慎展望与贝尔实验室的黄金时代 展望未来 10 到 20 年的计算技术发展,Lex Fridman 提问 Kernighan 作为见证了“从几乎没有计算机到如今连亚洲、非洲乃至全球几乎每个人手中都握有计算设备”的先驱,对未来是乐观还是抱有希望。Kernighan 坦承自己的心情非常复杂(mixed)。虽然计算技术带来了巨大的向善潜力,让世界各地的人们生活得以改善,但至少在短期内,负面效应极为明显:群体日趋部落化(tribalistic)和狭隘狭隘化,充斥着“我们对抗他们”的对立情绪;人们广泛利用计算机手段误导、歪曲事实甚至蓄意撒谎,这已经对全球多地的政治生态造成了深远影响。Lex 赞同这种技术赋权的复杂性——受压迫者获得了发声渠道,但同时每个人都有了扩音器,由此涌现的混乱令人着迷却又心生恐惧。 当 Lex 询问若能重返生命中除家庭之外某个真正快乐或具有深刻转变意义的时刻时,Kernighan 表示没有某个孤立的单一瞬间,而是贝尔实验室(Bell Labs)那段充满创造力的流金岁月: - **贝尔实验室的 1970 年代黄金期**:在 UNIX 刚刚诞生的年代,计算机科学领域遍地都是触手可及的“低垂果实”(low-hanging fruit),有着数不清的有趣课题。 - **卓越且紧密的群体氛围**:实验室有一群志同道合、荣辱与共的顶尖同行,每当有人做出了新工具,其他人立刻就会乐意去试用,并由衷赞叹“天哪,这真棒”。 - **AWK 的诞生与长久影响**:Kernighan 共同设计的 AWK 语言便是这种环境下的产物。写出来后同事们迅速采用,如今更有数以百万计的开发者每天都在使用它。Kernighan 打趣道,让数百万人用着你写的工具,意味着“你犯下的所有愚蠢错误都摆在所有人眼前任其打量”,这种体验既令人感到脆弱恐惧,又极为美丽。 Brian Kernighan 总结贝尔实验室的岁月时说道:“我认为在某种意义上那是一段非常非常美好的时光,AWK 就是一个例子,你把它造了出来,大家便立刻用上了它。”(“I think that was in some sense a really really good time, and AWK was an example of that, then you built it and people use that.”) 在访谈结语中,Lex Fridman 引用了 Brian Kernighan 在编程领域的传世格言作为收尾:“不要给糟糕的代码写注释,重写它。”(“Don't comment bad code, rewrite it.”) ## Notable quotes > [01:43:57](https://www.youtube.com/watch?v=O9upVbGSBFo&t=6237s) Don't comment bad code, rewrite it. — Brian Kernighan > [01:08:16](https://www.youtube.com/watch?v=O9upVbGSBFo&t=4096s) I certainly don't hope it I'd not sure that that's right because I honestly don't think there is one language that will suffice for all the programming needs of the world. — Brian Kernighan ## Mentioned Brian Kernighan, Lex Fridman, Ken Thompson, Dennis Ritchie, Alfred Aho, Peter Weinberger, Rob Pike, Robert Griesemer, Alan Donovan, Fernando Corbató, Bill Joy, Linus Torvalds, Richard Stallman, Robert Fourer, David Gay, Stephen Cook, Shen Lin, John Hopcroft, Donald Knuth, Alan Turing, Arthur C. Clarke, Jeff Dean, Tony Hoare, Niklaus Wirth, Grace Hopper, Tony Brooker, Jim Keller, 贝尔实验室, 普林斯顿大学, 麻省理工学院, AT&T, 通用电气, 加州大学伯克利分校, 施乐帕罗奥多研究中心, UNIX, Linux, Multics, CTSS, Plan 9, C 语言, AWK, AMPL, Go 语言, Python, JavaScript, Rust, Fortran, COBOL, ALGOL, BASIC, Scala, Lua, Haskell, Lisp, Sam, ed, vi, Emacs, QED, grep, troff, TeX, WSL, Cygwin, IBM 7094, PDP-7, PDP-11, 《C 程序设计语言》, 《Go 语言圣经》, 《程序设计实践》, 《UNIX:一段历史与回忆》 ## Video description Brian Kernighan is a professor of computer science at Princeton University. He co-authored the C Programming Language with Dennis Ritchie (creator of C) and has written a lot of books on programming, computers, and life including the Practice of Programming, the Go Programming Language, his latest UNIX: A History and a Memoir. He co-created AWK, the text processing language used by Linux folks like myself. He co-designed AMPL, an algebraic modeling language for large-scale optimization. Support this podcast by supporting our sponsors: - Eight Sleep: https://eightsleep.com/lex - Raycon: http://buyraycon.com/lex EPISODE LINKS: Brian's website: https://www.cs.princeton.edu/~bwk/ Unix: A History and a Memoir (book): https://amzn.to/3fFJ1yM Understanding the Digital World (book): https://amzn.to/30ktBJI PODCAST INFO: Podcast website: https://lexfridman.com/podcast Apple Podcasts: https://apple.co/2lwqZIr Spotify: https://open.spotify.com/episode/5OtSR9U7Nv9Ly9ixzmerrU RSS: https://lexfridman.com/feed/podcast/ Full episodes playlist: https://www.youtube.com/playlist?list=PLrAXtmErZgOdP_8GztsuKi9nrraNbKKp4 Clips playlist: https://www.youtube.com/playlist?list=PLrAXtmErZgOeciFP3CBCIEElOJeitOr41 OUTLINE: 0:00 - Introduction 4:24 - UNIX early days 22:09 - Unix philosophy 31:54 - Is programming art or science? 35:18 - AWK 42:03 - Programming setup 46:39 - History of programming languages 52:48 - C programming language 58:44 - Go language 1:01:57 - Learning new programming languages 1:04:57 - Javascript 1:08:16 - Variety of programming languages 1:10:30 - AMPL 1:18:01 - Graph theory 1:22:20 - AI in 1964 1:27:50 - Future of AI 1:29:47 - Moore's law 1:32:54 - Computers in our world 1:40:37 - Life CONNECT: - Subscribe to this YouTube channel - Twitter: https://twitter.com/lexfridman - LinkedIn: https://www.linkedin.com/in/lexfridman - Facebook: https://www.facebook.com/LexFridmanPage - Instagram: https://www.instagram.com/lexfridman - Medium: https://medium.com/@lexfridman - Support on Patreon: https://www.patreon.com/lexfridman [Source](https://www.youtube.com/watch?v=O9upVbGSBFo)

Source quotes

[103:57] Brian Kernighan: Don't comment bad code, rewrite it. [68:16] Brian Kernighan: I certainly don't hope it I'd not sure that that's right because I honestly don't think there is one language that will suffice for all the programming needs of the world.

Source quotes

[101:53] Brian Kernighan: Don't comment bad code; rewrite it. [51:04] Brian Kernighan: As you write programs in a language like C, at some point scale gets to you, and it's too hard to keep track of the pieces, and there's no guardrails or training wheels or something like that to prevent you from doing bad things.

Original transcript

[0:00] the following is a conversation with [0:01] Brian Kernighan a professor of computer [0:04] science at Princeton University he was a [0:07] key figure in the computer science [0:09] community in the early UNIX days [0:11] alongside UNIX creators Ken Thompson and [0:14] Dennis Ritchie he co-authored the C [0:17] programming language with Dennis Ritchie [0:19] the creator of C and has written a lot [0:23] of books on programming computers and [0:25] life including the practice of [0:27] programming the goal programming [0:29] language and his latest UNIX a history [0:32] and a memoir he co-created awk the text [0:36] processing language used by Linux folks [0:37] like myself he Co designed ample an [0:41] algebraic modeling language that I [0:43] personally love and have used a lot in [0:47] my life for large scale optimization I [0:49] think I can keep going for a long time [0:51] with his creations and accomplishments [0:53] which is funny because given all that [0:56] he's one of the most humble and kind [0:58] people I've spoken to on this podcast [1:00] quick summary of the ads - new sponsors [1:04] the amazing self cooling 8 sleep [1:09] mattress and rake on earbuds please [1:13] consider supporting the podcast by going [1:15] to 8 sleep complex and going to buy a [1:20] rake on comm slash flex click the links [1:23] buy the stuff it really is the best way [1:26] to support this podcast and a journey [1:28] I'm on if you enjoy this thing subscribe [1:31] on youtube review it with fire stars an [1:33] apple podcast supported on patreon or [1:35] connect with me on Twitter at lex [1:37] friedman as usual i'll do a few minutes [1:40] of ads now and never any ads in the [1:42] middle that can break the flow of the [1:44] conversation this show is sponsored by 8 [1:48] sleep and it's incredible pod Pro [1:50] mattress you can checkout at 8 sleep [1:53] calm slash flex to get $200 off the [1:57] mattress controls temperature with an [1:59] app and can cool down to as low as 65 [2:02] degrees [2:03] research shows the temperature has a big [2:05] impact on the quality of our asleep [2:08] anecdotally he's been a game changer for [2:10] me I love it [2:11] the [2:12] patro is packed with sensors that track [2:14] heart rate heart rate variability and [2:16] respiratory rate showing it all on their [2:19] app once you wake up plus if you have a [2:22] partner you can control the temperature [2:24] of each side of the bed I don't happen [2:27] to have one but the a sleep app reminds [2:29] me that I should probably get on that so [2:32] ladies if a temperature controlled [2:34] mattress isn't a good reason to apply I [2:36] don't know what is the apps health [2:39] metrics are amazing but the cooling [2:41] alone is honestly worth the money as [2:44] some of you know I don't always sleep [2:46] but when I do I choose the a sleep pod [2:50] Pro mattress check it out at a sleep [2:52] calm slash flex to get $200 off this [2:57] show is also sponsored by Ray con [3:00] earbuds get them at buy rake on Comm [3:03] slash flex they've quickly become a main [3:07] method of listening to podcasts [3:08] audiobooks and music when I run do the [3:12] push ups and pull ups that have begun to [3:14] hate at this point or just living life [3:16] in fact I often listen to brown noise [3:19] with these what I'm thinking deeply [3:21] about something it helps me focus the [3:23] mind they're super comfortable pair [3:25] easily great sound great bass six hours [3:28] of play time in fact for fun I have one [3:32] of the earbuds in now and I'm listening [3:34] to Europa by Santana probably one of my [3:36] favorite guitar songs it kind of makes [3:39] me feel like I'm in a music video so [3:41] they told me to say that a bunch of [3:44] celebrities use these like Snoop Dogg [3:46] Melissa Etheridge and cardi B I don't [3:50] even know cardi B is but her earbud game [3:53] is on point to mention celebrities [3:56] actually care about [3:57] I'm sure if Richard Fineman was still [4:00] with us he'd be listening to the Joe [4:02] Rogan experience with Rick on earbuds [4:05] get them at by Drake on comm / Lex [4:08] it's how they know I sent you and [4:10] increases the chance that he'll support [4:12] this podcast in the future so for all of [4:15] the sponsors click all the links it [4:17] really helps this podcast and now here's [4:20] my conversation with Brian Kernighan [4:25] started being developed fifty years ago [4:27] in me more than fifty years ago can you [4:30] tell the story like you're describing [4:32] your new book of how UNIX was created ha [4:35] if I couldn't remember that far back [4:37] well it was some while ago um so I think [4:41] the gist of it is that at Bell Labs and [4:44] in 1969 there were a group of people who [4:46] had just finished working on the multics [4:49] project which was itself falling on to [4:52] CTS s so we can go back sort of an [4:55] infinite regress in time but the CTS s [4:58] was a very very very nice time sharing [5:00] system was very nice to use I actually [5:02] used it as that summer I spent in [5:04] Cambridge in 1966 for was the hardware [5:07] there right so what's the operating [5:09] system what's the hardware there what's [5:10] the CTS look like so cts s looked like [5:13] kind of like a standard time sharing [5:16] system certainly at the time it was the [5:18] only time sharing if no let's go back to [5:20] the basic ok in the beginning was the [5:23] word and the word sign there was time [5:25] sharing systems yeah if we go back into [5:28] let's call it the 1950s and early 1960s [5:31] most computing was done on very big [5:33] computers physically big although not [5:36] terribly powerful by today's standards [5:38] that were maintained in very large rooms [5:41] and you used things like punch cards to [5:45] write programs on talk to him so you [5:47] would take a deck of cards write your [5:49] program on it send it over a counter [5:51] hand it to an operator and some while [5:53] later back would come something that [5:55] said oh you made a mistake and then [5:57] you'd recycle and so it's very very slow [5:58] so the idea of time sharing was that you [6:01] take basically that same computer but [6:04] connect to it with something that looked [6:07] like an electric typewriter they could [6:09] be a long distance away it could be [6:11] closed but fundamentally what the [6:13] operating system did was to give each [6:16] person who was connected to it and [6:18] wanting to do something a small slice of [6:20] time on to do a particular job so I [6:24] might be editing a file so I would be [6:27] typing and every time I hit a keystroke [6:29] the operating system would wake up and [6:30] said oh he typed character let me [6:32] remember that and then it go back to [6:34] doing something else would be going [6:35] around and around a group of [6:37] who were trying to get something done [6:39] giving each a small slice of time and [6:42] giving them each the illusion that they [6:45] pretty much hit the whole machine to [6:46] themselves and hence time sharing that [6:49] is sharing the computing time resource [6:51] of the computer among a number of people [6:53] who are doing it without the individual [6:55] people being aware that there's others [6:57] in a sense the illusion the feeling is [6:59] that you the machine is your own pretty [7:02] much that was the idea yes you had if it [7:05] were well done and if it were fast [7:07] enough and other people were doing too [7:09] much you did have the illusion that you [7:11] had the whole machine to yourself and it [7:13] was very much better than the punch card [7:15] model and so cts s the compatible time [7:18] sharing system was I think arguably the [7:21] first of these it was done I guess [7:23] technically 64 or something like that it [7:26] ran on an IBM 7090 for slightly modified [7:29] to have twice as much memory as the norm [7:32] it had two banks of 32 k words instead [7:36] of one so 32 K words yes where's this 36 [7:41] bit so call it you know about a hundred [7:43] and fifty kilobytes times two so by [7:47] today's standards that's down in the [7:48] noise yeah at the time that was a lot of [7:51] memory and memory was expensive so C TSS [7:54] was just a wonderful environment to work [7:56] on it was done by the people that MIT [7:58] led by Fernando Corbett Oh of Cour be [8:02] who died just earlier this year and a [8:05] bunch of other folks and then so I spent [8:07] the summer of 66 working on that had a [8:09] great time met a lot of really nice [8:12] people and indirectly knew of people at [8:16] Bell Labs who were also working on a [8:19] follow-on to C TSS that was called [8:22] multics so multics was meant to be the [8:25] system that would do everything that C [8:26] TSS did but do it better for a larger [8:29] population that's all the usual stuff [8:31] now the actual time sharing the [8:33] scheduling how much what's the algorithm [8:37] that performs the scheduling what's that [8:39] look like how much magic is there what [8:41] are the metrics how does it all work in [8:43] the beginning so the answers I don't [8:45] have a clue I think the basic idea was [8:47] nothing more than who all wants to get [8:49] something done suppose things are very [8:51] in the middle of the night then I get [8:54] all the time that I want suppose that [8:56] you and I are contending at high noon [8:57] for something like that then probably [9:00] the simplest algorithm is a round robin [9:02] one that gives you a bit of time gives [9:03] me a bit of time and then we could adapt [9:05] to that like what are you trying to do [9:08] are you text editing or are you [9:10] compiling or something and we might [9:12] adjust the scheduler according to things [9:14] like that so okay so multics [9:16] was trying to just do some of the clean [9:19] it up a little bit well it was it was [9:21] meant to be much more than that so [9:22] multix was the multiplexed information [9:24] and computing service and it was meant [9:26] to be a very large thing we would [9:28] provide computing utility something that [9:30] where you could actually think of it as [9:33] just a plug in the wall service sort of [9:35] like cloud computing today yeah same [9:37] idea but 50 odd years earlier [9:40] and so what multix offered was a richer [9:44] operating system environment piece of [9:47] hardware that was better designed for [9:49] doing the kind of sharing of resources [9:51] and presumably lots of other things do [9:56] you think people at that time had the [9:57] dream of what cloud computing is [10:00] starting to become now which is [10:01] computing is everywhere that you can [10:03] just plug in almost no you know and you [10:06] never know how the magic works you just [10:09] kind of plug in add in your little [10:11] computation they need to perform and it [10:12] does it it was that the dream I don't [10:15] know where that was the dream I wasn't [10:16] part of it at that point remember I was [10:17] an intern first summer but my sense is [10:20] given that it was over 50 years ago yeah [10:23] they had that idea that it was an [10:25] information utility that it was [10:26] something where if you had a computing [10:28] task to do you could just go and do it [10:31] now I'm betting that they didn't have [10:34] the same view of computing for the [10:37] masses let's call it the idea that you [10:39] know your grandmother would be shopping [10:42] on Amazon I don't think that was part of [10:44] it but if your grandmother were a [10:46] programmer it might be very easy for her [10:48] to go and use this kind of utility what [10:51] was your dream of computers at that time [10:53] what did you see as the future of [10:54] computers could you have predicted what [10:57] computers are today that you sense Oh [10:59] short answer absolutely not I have no [11:02] clue I'm not sure I had a dream it was a [11:04] dream job in the sense [11:05] that I really enjoyed what I was doing I [11:07] was surrounded by really really nice [11:09] people Cambridge is a very fine city to [11:11] live in in the summer less so in the [11:13] winter when it snows but in the summer [11:14] it was a delightful time and so I really [11:17] enjoyed all of that stuff and I learned [11:19] things and I think the good fortune of [11:23] being there for summer led me then to [11:25] get a summer job at Bell Labs the [11:27] following summer and that was going to [11:29] useful for the future so this Bell Labs [11:32] is this magical legendary place so first [11:36] of all where is Bell Labs and can you [11:41] start talking about that journey towards [11:44] Unix at Bell Labs [11:46] yeah so Bell Labs is physically [11:48] scattered around at the time scattered [11:51] around New Jersey the primary location [11:53] was in a town called Murray Hill where a [11:55] location called Murray Hill is actually [11:56] then across the boundary between two [11:59] small towns in New Jersey called New [12:01] Providence and Berkeley Heights think of [12:03] it as about 15-20 miles straight west of [12:05] New York City and therefore but an hour [12:08] north of here and for instance and at [12:12] that time it had make up a number three [12:15] or four thousand people there many of [12:16] whom had PhDs and mostly doing physical [12:19] sciences chemistry physics materials [12:23] kinds of things but very strong math and [12:26] it rapidly growing interest in computing [12:29] as people realized you could do things [12:31] with computers that you might not have [12:33] been able to do before you could replace [12:36] labs with computers that had worked on [12:38] models of what was going on so that was [12:42] the essence of Bell Labs and again I [12:44] wasn't the permanent play there I was [12:46] that was another internship I got lucky [12:48] in internships I mean if you could just [12:51] linger in a little bit what was the what [12:54] was in the air there because some of [12:55] this is the number of Nobel Prizes the [12:57] number of touring Awards and just [12:59] legendary computer scientists that come [13:01] from their inventions including [13:03] developments including UNIX it's just is [13:07] unbelievable so is it was there [13:09] something special about that place oh I [13:11] think there was very definitely [13:12] something special I mentioned the number [13:15] of people's a very large number of [13:16] people very highly skilled [13:19] working in an environment where there [13:20] was always something interesting to work [13:22] on because the goal of Bell Labs which [13:25] was a small part of a TMT which provided [13:27] basically the country's phone service [13:29] the goal of a TMT was to provide service [13:32] for everybody and the goal of Bell Labs [13:35] was to try and make that service keep [13:37] getting better so improving service and [13:39] that meant doing research on a lot of [13:42] different things physical devices like [13:45] the transistor or fiber optical cables [13:48] or microwave systems all of these things [13:51] the labs worked on and it was kind of [13:54] just the beginning of real boom times in [13:56] computing as well is when I was there I [13:59] went there first in 66 so computing was [14:02] at that point fairly young and so people [14:05] were discovering that you could do lots [14:06] of things with computers [14:07] so how's Unix born so multix in spite of [14:13] having an enormous number of really good [14:15] ideas lots of good people working on it [14:16] fundamentally didn't live up at least in [14:19] the short run and I think ultimately [14:21] really ever to its goal of being this [14:24] information utility it was too expensive [14:27] and certainly what was promised was [14:29] delivered much too late and so in [14:32] roughly the beginning of 1969 Bell Labs [14:35] pulled out of the project the project at [14:38] that point had included MIT Bell Labs [14:42] and General Electric General Electric [14:44] made computers so General Electric was [14:46] the hardware operation so Bell Labs [14:48] realizing this wasn't going anywhere on [14:50] a time scale they cared about [14:52] pulled out his project and this left [14:54] several people with an acquired taste [14:58] for really really nice computing [15:00] environments but no computing [15:02] environment and so they started thinking [15:04] about what could you do if you're going [15:07] to design a new operating system that [15:09] would provide the same kind of [15:11] comfortable computing as cts s head but [15:14] also the facilities of something like [15:16] multics sort of brought forward and so [15:19] they did a lot of paper design stuff and [15:21] at the same time Ken Thompson found what [15:24] is characterized as a little-used pdp-7 [15:26] where he started to do experiments with [15:30] file systems just how do you [15:31] store information on a computer in an [15:33] efficient way and then this famous story [15:36] that his wife went away to California [15:38] for three weeks taking their [15:39] one-year-old son and three weeks and he [15:42] sat down and wrote an operating system [15:45] which ultimately became Unix so software [15:48] productivity was good in those days [15:49] the PDP what's the PDP seven so it's a [15:52] piece of hardware yeah it's a piece of [15:53] part where it was one of our leading [15:56] machines made by Digital Equipment [15:57] Corporation Dec and it was a mini [16:01] computer so called [16:03] it had yeah I would have to look up the [16:06] numbers exactly but it had a very small [16:08] amount of memory maybe 16 K 16-bit words [16:12] or something like that relatively slow [16:14] probably not super expensive maybe again [16:18] making this up I'd have to look it up a [16:19] hundred thousand dollars or something [16:21] like that which is not super expensive [16:23] in the sious right it was expensive it [16:25] was enough that you and I probably [16:26] wouldn't be my white one but a modest [16:28] group of people could get together but [16:30] in any case in it came out if I recall [16:33] in 1964 so by 1969 it was getting a [16:37] little obsolete and that's why it was [16:39] little used if you can sort of comment [16:42] what do you think it's like to write an [16:44] operating system like that so that [16:45] process that Ken went through in three [16:47] weeks because you were I mean you're [16:51] part of that process you've contributed [16:53] a lot to UNIX his early development so [16:57] what do you think it takes to do that [17:00] first step that first kind of from [17:03] designed to a reality on the PDP well [17:05] let me correct one thing I had nothing [17:07] to do with it so I did not write it I [17:10] have never written operating system code [17:12] and so I don't know now an operating [17:17] system is simply code and this first one [17:19] wasn't very big but it's something that [17:22] lets you run processes of some that you [17:24] execute some kind of code that has been [17:27] written it lets you store information [17:28] for periods of time so that it doesn't [17:31] go away when you turn the power off or [17:33] reboot or something like that and [17:35] there's a kind of a core set of tools [17:38] that are technically not part of an [17:40] operating system but you probably need [17:42] them in this case Ken wrote an assembler [17:44] for [17:45] pdp-7 that worked he needed a text [17:47] editor so that he could actually create [17:48] text he had the file system stuff that [17:51] he had been working on and then the rest [17:52] of it was just a way to load things [17:55] executable code from the file system [17:57] into the memory give it control and then [18:00] recover control when it was finished or [18:02] in some other way [18:04] quit what was the code written in the [18:06] primarily the programming language was [18:08] it in assembly pdp-7 assembler that Ken [18:11] created these things were assembly [18:14] language until probably the call at 1973 [18:18] or 74 something like that yeah [18:21] forgive me if it's a dumb question but [18:23] it feels like a daunting task to write [18:25] any kind of complex system in assembly [18:28] absolutely it feels like impossible to [18:32] do any kind of what we think of a [18:33] software engineering assembly is to work [18:37] on a big picture I think it's hard it's [18:41] been a long time since I wrote assembly [18:43] language it is absolutely true that in [18:44] some other language if you make a [18:45] mistake nobody tells you there are no [18:47] training wheels whatsoever and so stuff [18:50] doesn't work now what and there's no the [18:52] buggers well there could be debuggers [18:54] but that's the same problem right how do [18:56] you actually get something that will [18:59] help you debug it so part of it is is an [19:02] ability to see the big picture now these [19:05] systems were not big in the sense of [19:07] today's picture so the big picture was [19:09] in some sense more manageable I mean [19:12] then realistically there's an enormous [19:14] variation in the capabilities of [19:16] programmers and Ken Thompson who did [19:19] that first one is kind of the [19:21] singularity in my experience of [19:23] programmers with no disrespect to you or [19:27] even to me he's gonna die several [19:29] leagues removed I know there's levels [19:31] this is it's a it's a fascinating thing [19:34] that there are unique stars in [19:37] particular in the programming space and [19:39] in a particular time you know the time [19:41] matters to the timing of when that [19:43] person comes along and the a wife does [19:46] have to leave see like there's this [19:48] weird timing that happens that and then [19:50] all sudden something beautiful is [19:51] created I mean how does it make you feel [19:53] that there's a system I was created in [19:56] in three weeks or [19:58] maybe you can even say on a whim but not [20:01] really but of course quickly that is now [20:04] you could think of most of the computers [20:07] in the world run on a unix-like system [20:09] right well how do you ensure like if you [20:14] kind of zoom from the alien perspective [20:16] if you're just observing earth that all [20:18] sudden these computers took over the [20:20] world and they started from this little [20:22] initial seed of Unix [20:24] how does that make you feel it's quite [20:26] surprising and and and you asked earlier [20:29] but predictions the answer is no there's [20:31] no way you could predict that kind of [20:33] evolution and I don't know whether it [20:36] was inevitable or just a whole sequence [20:38] of blind luck I suspect more the latter [20:40] and so I look at it and think gee that's [20:44] kind of neat I think the real question [20:48] is what this can think about that [20:50] because he's the guy arguably from whom [20:53] it really came tremendous contributions [20:56] from Dennis Ritchie and then others [20:57] around in that Bell Labs environment but [21:00] you know if you had to pick a single [21:01] person that would be can see if written [21:05] in you book [21:06] UNIX a history and a memoir are there [21:08] some memorable human stories funny or [21:11] profound from that time they just kind [21:13] of stand out oh there's a lot of them in [21:15] a sense and again it's a question if can [21:16] you resurrect them this memory fails but [21:21] I think part of it was that Bell Labs at [21:24] the time was was a very special kind of [21:26] place to work because there were a lot [21:27] of interesting people and the [21:29] environment was very very open and free [21:31] it was a very cooperative environment [21:33] very from the environment and so if you [21:34] had an interesting problem you go and [21:36] talk to somebody and they might help you [21:37] with the solution and and it was a kind [21:42] of a fun environment to in which people [21:44] did strange things and often tweaking [21:49] the bureaucracy in one way or another [21:51] the rebellious and in some kinds of ways [21:54] in some ways yeah absolutely I think [21:56] most people didn't take too kindly to [21:58] the bureaucracy and I'm sure the [22:00] bureaucracy put up with an enormous that [22:03] they didn't really want to so maybe to [22:07] linger on it a little bit you have a [22:09] sense of what the philosophy that [22:11] characterized [22:12] unix's the design not just the initial [22:16] but just carry through the years just [22:18] being there being around what's the [22:21] fundamental philosophy behind the system [22:22] I think one aspect the fundamental [22:25] philosophy was to provide an environment [22:27] that made it easy to write her easier [22:29] productive to write program so as men as [22:32] a programmer environment it wasn't meant [22:34] specifically as something to do some [22:36] other kind of job for example it was [22:39] used extensively for word processing but [22:41] it wasn't designed as a word processing [22:43] system it was used extensively for lab [22:45] control but it wasn't designed for that [22:47] it was used extensively as a front end [22:49] for big other systems big dumb systems [22:52] but it wasn't designed for that it was [22:54] meant to be an environment where it was [22:56] really easy to write programs that so [22:58] the programmers could be highly [22:59] productive and part of that was to be a [23:02] community and there's some observation [23:04] from Dennis Ritchie I think at the end [23:06] of the book that says that and that from [23:08] his standpoint the real goal was to [23:10] create a community where people could [23:12] work as programmers on a system I think [23:17] in that sense certainly for many many [23:19] years it succeeded quite well at that [23:22] and part of that is the technical [23:24] aspects of because it made it really [23:26] easy to write programs people did write [23:28] interesting programs those programs [23:29] tended to be used by other programmers [23:31] and so it was kind of a virtuous circle [23:33] are of more and more stuff coming out [23:36] that was really good for programmers and [23:39] you're part of that community of [23:40] programmers so what was the like writing [23:42] programs on that early unix it was a [23:46] blast it really was you know I like to [23:50] program I'm not a terribly good [23:52] programmer but it was a lot of fun to [23:54] write code and in the early days there [23:56] was an enormous amount of what you would [23:57] today I suppose called low-hanging fruit [24:00] people hadn't done things before and [24:02] this was this new environment and the [24:04] the whole combination of nice tools and [24:07] very responsive system and tremendous [24:10] colleagues made it possible to write [24:12] code you could have an idea in the [24:15] morning you could do it and you know an [24:18] experiment with it you could have [24:19] something limping along that night or [24:21] the next day and people would react to [24:23] it and they would say oh that's [24:24] wonderful [24:25] but you're really screwed up here and [24:27] and the feedback Luke was then very very [24:30] short and tight and so a lot of things [24:32] got developed fairly quickly that in [24:37] many cases still exists today and I [24:40] think that was part of what made it fun [24:42] because programming itself is fun it's [24:44] puzzle solving in a variety of ways but [24:47] I think it's even more fun when you do [24:48] something that somebody else then uses [24:51] even if they whine about it not working [24:54] the fact that they used it is as part of [24:57] the reward mechanism and what was the [24:59] method of an interaction the [25:00] communication we need that feedback loop [25:02] I mean this is before the internet [25:04] certainly before the internet um it was [25:08] mostly physical right there you know [25:11] somebody would come into your office and [25:12] say something so these places are all [25:14] closed but like offices are nearby we're [25:16] really lively into interaction yeah yeah [25:19] no Bell Labs was fundamentally one giant [25:21] building and most of the people were [25:23] involved in this unique stuff we're in [25:24] two or three quarters and there was a [25:26] room [25:27] oh how big was it probably call it 50 [25:31] feet by 50 feet make up a number of that [25:34] and which had some access to computers [25:37] there as well as in offices and people [25:40] hung out there and had a coffee machine [25:42] and so that there was a it was mostly [25:45] very physical we did use email of course [25:47] and but it was fundamentally all for a [25:52] long time all on one machine so there [25:54] was no need for internet it's [25:56] fascinating to think about what [25:57] computing would be today without Bell [25:59] Labs it seems so many the people being [26:04] in the vicinity of each other it's sort [26:06] of getting that quick feedback working [26:08] together there's so many brilliant [26:09] people I don't know where else that [26:12] could have existed in the world I've [26:13] been given how that came together what [26:17] yeah well how does that make you feel [26:19] that that's a little element of history [26:22] well I think that's very nice but in a [26:25] sense it's survivor bias and if it [26:27] hadn't happened at Bell Labs there were [26:29] other places that we're doing really [26:31] interesting work as well Xerox PARC is [26:33] perhaps most obvious one Xerox PARC [26:35] contributed enormous amount of good [26:37] material and Men anything [26:39] we take for granted today in the same [26:40] way came from Xerox PARC experience I [26:43] don't think they capitalized in the long [26:45] run as much their parent company was [26:48] perhaps not as lucky in capitalizing on [26:51] this who knows but that would that's [26:53] certainly another place where there was [26:55] a tremendous amount of influence there [26:58] were a lot of good university activities [26:59] MIT was obviously no slouch in this kind [27:03] of thing and and others as well so Unix [27:07] turned out to be open source because of [27:11] the various ways that AT&T operated and [27:13] sort of they had to it was the focus was [27:16] on telephones so well I think that's a [27:19] mischaracterization in the sense it [27:21] absolutely was not open source [27:23] it was very definitely proprietary [27:26] licensed but it was licensed freely to [27:29] universities in source code form for [27:32] many years and because of that [27:34] generations of university students and [27:37] their faculty people grew up knowing [27:40] about Unix [27:41] and there was enough expertise in the [27:44] community that it then became possible [27:46] for people to kind of go off in their [27:47] own direction and build something that [27:48] looked unix like the berkeley version of [27:53] unix started with that licensed code and [27:56] gradually picked up enough of its own [27:59] code contributions notably from people [28:02] like Bill joy that eventually it was [28:06] able to become completely free of any [28:09] TMT code now there was an enormous [28:11] amount of legal jockeying around this [28:13] that in the late early to late 80s Early [28:17] 90s something like that and then not [28:22] something that I guess the open source [28:24] movement might have started when Richard [28:26] Stallman started to think about this in [28:28] the late 80s and by 1991 when Torvalds [28:32] decided he was going to do a unix-like [28:35] operating system there was enough [28:37] expertise that in the community that [28:40] first he had a target he could see what [28:43] to do because the kind of the UNIX [28:45] system call interface and the tools and [28:48] so on were there and so he was able to [28:51] build [28:52] an operating system that at this point [28:54] when you say UNIX in many cases what [28:57] you're really thinking is Linux Linux [28:58] yeah but it's it's funny that from my [29:01] distant perception I felt that UNIX was [29:03] open-source without actually knowing it [29:06] but what you're really saying it was [29:09] just freely licensed so it was freely [29:12] licensed it felt open-source in a sense [29:14] because universities are not trying to [29:16] make money so there it felt open-source [29:18] in a sense that you can get access if [29:20] you wanted right and a very very very [29:22] large number of universities had the [29:23] license and they were able to talk to [29:25] all the other universities who had the [29:26] license and so technically not open [29:30] technically belonging day T&T [29:31] pragmatically pretty open and so there's [29:35] a ripple effect that all the faculty and [29:37] the students then I'll grew up and then [29:39] they went throughout the world and [29:43] permeated in that kind of way so what [29:46] kind of features do you think made for a [29:50] good operating system if you take the [29:53] lessons of Unix you said like you know [29:56] make it easy for programmers like that [30:00] seems to be an important one but also [30:04] UNIX turned out to be exceptionally [30:06] robust and efficient right so is that an [30:09] accident when you focus on the [30:11] programmer or is that a natural outcome [30:14] I think part of the reason for [30:16] efficiency was that it began on [30:18] extremely modest hardware very very very [30:22] tiny and so you couldn't get carried [30:23] away you couldn't do a lot of [30:25] complicated things because you just [30:28] didn't have the resources either [30:30] processor speed or memory and so that [30:32] enforced a certain minimal 'ti of [30:36] mechanisms and maybe a search for [30:38] generalizations so that you would find [30:41] one mechanism that's served for a lot of [30:42] different things rather than having lots [30:44] of different special cases I think the [30:46] file system and UNIX is a good example [30:48] of that file system interface in its [30:50] fundamental form is extremely [30:52] straightforward and that means that you [30:54] can write code very very effectively [30:57] from for the file system and then one of [30:59] those ideas and one of those [31:01] generalizations is that gee that file [31:03] system interface works for all kinds of [31:05] other things as [31:06] well and so in particular the idea of [31:08] reading and writing to devices is the [31:10] same as reading and writing to a disk [31:12] that has a file system and then that [31:15] gets carried further in other parts of [31:17] the world processes become in effect [31:21] files in a file system and the plan 9 [31:24] operating system which came along I [31:26] guess in the late 80s or something like [31:28] that [31:28] took a lot of those ideas from the [31:30] original unix and tried to push the [31:33] generalization even further so that in [31:35] plan 9 a lot of different resources our [31:37] file systems they all share that [31:38] interface so that would be one example [31:41] we're finding the right model of how to [31:44] do something means that an awful lot of [31:46] things become simpler and it means [31:48] therefore that more people can do useful [31:50] interesting things with them without him [31:52] to think as hard about it so you said [31:54] you're not a very good programmer you're [31:58] the most modest human being ok but [32:01] you'll continue saying that I understand [32:03] how this works but you do radiate a sort [32:06] of love for programming so let me ask do [32:09] you think programming is more an art or [32:12] science there's a creativity or kind of [32:15] rigor I think it's some of each it's [32:18] some combination some of the art is [32:21] figuring out what it is that did you [32:22] really want to do what should that [32:24] program be what would make a good [32:26] program and that's some understanding of [32:29] what the task is what the people who [32:31] might use this program want and I think [32:33] that's that's art in many respects the [32:37] science part is trying to figure out how [32:39] to do it well and some of that is a real [32:43] computer science II stuff like what [32:45] algorithm should we use at some point [32:47] mostly in the sense of being careful to [32:51] use algorithms that will actually work [32:53] properly or scale properly avoiding [32:56] quadratic algorithms when a linear [32:58] algorithm should be the right thing that [33:01] got a more formal view of it [33:03] same thing for data structures but also [33:06] it's I think an engineering field as [33:10] well then engineering is not quite the [33:11] same as science because engineering [33:12] you're working with constraints you have [33:15] to figure out not only so what is a good [33:19] algorithm for the [33:20] kind of thing but what's the most [33:21] appropriate algorithm given the amount [33:23] of time we have to compute the amount of [33:26] time we have to program what's likely to [33:28] happen in the future with maintenance [33:30] who's gonna pick this up in the future [33:32] all of those kind of things that if [33:35] you're an engineer you get to worry [33:36] about whereas if you think of yourself [33:38] as a scientist well you can maybe push [33:40] them over their horizon in a way and if [33:42] you're an artist what's that so just on [33:46] your own personal level what's your [33:49] process like of writing a program say a [33:51] small and large sort of tinkering with [33:54] stuff you just start coding right away [33:57] and just kind of evolve iteratively with [34:00] a loose notion or do you plan and a [34:04] sheet of paper first and then kind of [34:06] design and this you know what they teach [34:08] you in the kind of software engineering [34:11] courses an undergrad or something like [34:13] that what's your process like it's [34:15] certainly much more the informal [34:16] incremental first I don't write big [34:18] programs at this point it's been a long [34:20] time since I wrote a program that weighs [34:21] more and then I call it a few hundred or [34:24] more lines something like that many of [34:27] the programs are right or experiments [34:29] for either something I'm curious about [34:31] or often for something that I want to [34:33] talk about in a class and so those [34:34] necessarily tend to be relatively small [34:37] a lot of the kind of code I write these [34:40] days tends to be for sort of exploratory [34:43] data analysis where I've got some [34:44] collection of data and I want to try and [34:46] figure out what on earth is going on in [34:48] it and for that those programs tend to [34:50] be very small sometimes you're not even [34:53] programming you're just using existing [34:55] tools like counting things or sometimes [34:58] you're writing awk scripts because two [35:01] or three lines will tell you something [35:02] about a piece of data and then when it [35:04] gets bigger well and I will probably [35:06] write something in Python because that [35:09] scales better up to call it a few [35:12] hundred lines or something like that and [35:14] it's been a long time since I wrote [35:15] programs that were much more than that [35:18] speaking of data exploration in awk [35:20] first what is awk so awk is a scripting [35:24] language that was done by myself el hijo [35:28] on Peter Weinberger we did that [35:30] originally in the late 70s it was a [35:32] language that was meant to make [35:34] really easy to do quick and dirty tasks [35:37] like counting things or selecting [35:40] interesting information from basically [35:43] all text files rearranging it in some [35:46] way or summarizing it runs the command [35:49] on each line of a file I mean there's uh [35:51] it's still exceptionally widely used [35:54] today oh absolutely yeah it's so simple [35:57] an elegant sort of the way to explore [36:00] data turns out you can just write a [36:02] script that does something seemingly [36:05] trivial on a single line and that giving [36:08] you that slice of the data somehow [36:10] reveals something fundamental about the [36:12] data you know that keeps that seems to [36:15] work [36:16] still yeah it's very good for that kind [36:18] of thing that's sort of what it was [36:20] meant for I think what we didn't [36:22] appreciate was that the model is [36:24] actually quite good for a lot of data [36:26] processing kinds of tasks and that it's [36:28] it's kept going as long as it has [36:30] because at this point it's over 40 years [36:32] old but it's still I think a useful tool [36:35] and well this is paternal interest I [36:38] guess but I think in terms of [36:39] programming languages you get the most [36:41] bang for the buck by learning awk and it [36:44] doesn't scale the big programs but it [36:46] does pretty pretty darn well on these [36:49] little things where you just want to see [36:51] all the something's in something so yeah [36:54] I find I probably write more awk than [36:56] anything so what what kind of stuff do [37:00] you love about arc like is there if you [37:02] can comment on sort of things that give [37:07] you joy when you can in a simple program [37:09] reveal something about it is there [37:11] something that stands out from [37:13] particular features I think it's mostly [37:16] the selection of default behaviors that [37:19] you sort of hinted at at a moment ago [37:21] what Octus is to read through a set of [37:23] files and then within each file it rich [37:26] through a each of the lines and then on [37:28] each of the lines it has a set of [37:30] patterns that it looks for that's your [37:33] arc program and if one of the patterns [37:36] matches there is a corresponding action [37:38] that you might perform and so it's kind [37:40] of a quadruply nested loop or something [37:43] like that um and that's all completely [37:46] automatic you don't have to say any [37:47] think about it you just write the [37:48] pattern in the action and then run the [37:51] data by it and and so that paradigm for [37:53] programming is very natural and [37:55] effective one and I think we captured [37:57] that reasonably well and lock and it [38:00] does other things for free as well it [38:02] splits the data into fields so that on [38:04] each line there feels separated by white [38:06] space or something and so it does that [38:08] for free you don't have to say anything [38:09] about it and it collects information it [38:13] goes along like what line are we on how [38:15] many fields are there on this line so [38:18] lots of things that just make it so that [38:20] a program which in another language [38:22] let's say Python would be 5 10 20 lines [38:25] in Arcis one or two lines and so because [38:28] it's one or two lines you can do it on [38:30] the shell you don't have to open up [38:32] another whole thing you can just do it [38:34] right there and the interaction with [38:36] Allah perfectly is there other shell [38:40] commands that you love over the years [38:44] like you really enjoy using don't major [38:49] does everything so grep is a kind of [38:52] what is it a simpler version of awk I [38:54] would say in some some sense yeah right [38:57] because what is grep so grep is it [38:59] basically searches the input for [39:02] particular patterns regular expressions [39:03] technically of a certain class and it [39:06] has that same paradigm that awk does [39:08] it's a pattern action thing it reads [39:10] through all the files and then all the [39:12] lines in each file but it has a single [39:14] pattern which is the regular expression [39:15] you're looking for and a single action [39:17] printed if it matches so it's a in that [39:21] sense it's a much simpler version and [39:22] you could write crap in Arcis as a [39:24] one-liner and I use grep probably more [39:29] than anything else at this point just [39:32] because it it's so convenient and [39:34] natural why do you think it's such a [39:36] powerful tool grab not why do you think [39:39] operating systems like Windows for [39:41] example don't have it sort of you can of [39:45] course I use which is amazing now [39:48] there's windows for linux like the which [39:51] you could basically use all the fun [39:54] stuff like all can graph and inside of [39:56] Windows but Windows naturally sort of in [39:59] the best part of the graphical interface [40:00] the simplicity [40:02] sort of searching through a bunch of [40:03] files and just popping up naturally [40:06] why don't you think that why do you [40:08] think that's unique to the UNIX and [40:09] Linux environment I don't know I it's [40:12] not strictly unique but it's certainly [40:15] focused there and I think some of its [40:17] the weight of history that Windows came [40:20] from ms-dos ms-dos was a pretty pathetic [40:23] operating system although common own and [40:25] you know unbounded lis large number of [40:27] machines but somewhere in roughly the [40:31] 90s windows became a graphical system [40:34] and I think Microsoft spent a lot of [40:36] their energy on making that graphical [40:39] interface what it is and that's a [40:42] different model of computing it's a [40:44] model of computing that where you point [40:46] and click and sort of experiment with [40:48] menus it's a model of computing worked [40:50] right rather well for people who are not [40:53] programmers just want to get something [40:55] done whereas teaching something like the [40:57] command line to non-programmers turns [41:00] out just sometimes be an uphill struggle [41:02] and so I think Microsoft probably was [41:04] right and what they did now you [41:06] mentioned whistle or whatever it's [41:08] called that winix I wonder what spinasse [41:10] wsl is but I've never actually [41:12] pronounced the whistle I like it I got [41:14] no idea but there have been things like [41:16] that for longest cygwin for example [41:18] which is a wonderful collection of take [41:21] all your favorite tools from UNIX and [41:22] Linux and just make them work perfectly [41:24] on Windows and so that's a something [41:26] that's been going on for at least 20 [41:28] years if not longer and I use that on my [41:31] one remaining Windows machine aw [41:34] routinely because it it's for if you're [41:37] doing something that is batch computing [41:38] command sudo for command-line that's the [41:42] right way to do it because the windows [41:43] equivalents are if nothing else not [41:45] familiar to me but I should I would [41:48] definitely recommend to people to if [41:50] they don't use cygwin to try whistle yes [41:52] I say I've been so excited that I could [41:55] use best ivy bash write scripts quickly [41:59] in in Windows it's changed my life [42:02] okay what's your perfect programming [42:05] setup what computer what operating [42:07] system want keyboard what editor yeah [42:10] perfect is too strong a word is way to [42:13] struggle read of what [42:15] by default I have a at this point a [42:18] 13-inch MacBook Air which I used because [42:22] it's kind of a reasonable balance of the [42:24] various things I need I can carry it [42:25] around it's got enough computing [42:27] horsepower screens big enough to [42:29] keyboards okay and so I basically do [42:32] most of my computing on that um I have a [42:35] big iMac in my office that I use from [42:37] time to time as well especially when I [42:40] need a big screen but otherwise none [42:41] tends not to be used as much editor I [42:47] use mostly Sam which is an editor that [42:51] Rob Pike wrote long ago at Bell Labs his [42:54] did that sorry to interrupt it does that [42:57] precede VI posts it post dates both VI [43:01] and Emacs it is derived from Rob's [43:06] experience with Edie and VI on D that's [43:12] the original UNIX editor o dated [43:16] probably before you were born so what's [43:20] actually what's the history of editors [43:23] can you can you briefly this is your fan [43:26] I used Emacs I'm sorry to say so I'm [43:28] sorry to come out with that but what's [43:31] what's the kind of interplay there yeah [43:35] so in ancient ancient times like call it [43:37] the first time sharing systems going [43:39] back to what we're talking about there [43:40] were editors there was an editor on C [43:43] TSS that I don't even remember what it [43:45] was called al it might have been edit [43:47] where you could type text program text [43:50] and it would do something or other [43:52] document text if it's saved then I'd [43:55] save it you could edit it you know the [43:57] usual thing that you would get in an [43:58] editor and Ken Thompson wrote an editor [44:01] called QED which was very very powerful [44:05] but these were all totally a command [44:08] based they were not most or cursor based [44:10] because it was before mice and even [44:12] before cursors because they were running [44:14] on terminals that printed on paper okay [44:17] no no CRT type displays let alone LEDs [44:20] and so then when UNIX came along Ken [44:24] took QED and stripped way way way way [44:27] down [44:28] and that became an editor that he called [44:30] needy it was very simple but it was a [44:32] line oriented editor and so you you [44:34] could load a file and then you could [44:36] talk about the lines one through the [44:38] last line and you could you know print [44:40] ranges of lines you could add text you [44:43] could delete text you could change text [44:44] or you could do a substitute command [44:46] that would change things within a line [44:47] or within groups of lines they can work [44:49] on a parts of a file essentially yeah [44:51] you could work on any part of it the [44:53] whole thing whatever but it was entirely [44:55] command line based and it was entirely [44:58] on paper okay paper and that meant that [45:02] you've changed yeah right real paper and [45:04] so if you changed the line you had to [45:06] print that line using up another line of [45:08] paper to see what changed cause okay [45:11] yeah [45:12] so when thing when CRT displays came [45:15] along yeah then you could start to use [45:18] cursor control and you could sort of [45:20] move where you where on the screen in [45:23] without reprinting printing and one of [45:28] there were a number of editors there the [45:29] one that I was most familiar with and [45:31] still use is VI which was done by bill [45:34] joy and so that dates from probably the [45:38] late 70s as a guess and it took at full [45:43] advantage of the cursor controls I [45:45] suspected Emacs was roughly at the same [45:48] time but I don't know I've never [45:49] internalized Emacs so so I use at this [45:53] point I stopped using IDI always can I [45:55] use VI sometimes and I use Sam when I [45:59] can and Sam is available on most systems [46:02] it was it is available you have to [46:04] download it yourself from typically the [46:06] plan line operating system distribution [46:08] it's been maintained by people there and [46:11] so I'll get home tonight I'll try it [46:14] that's cool it's a it's a sound sounds [46:17] fasting all though my love is with Lisp [46:19] and Emacs have went into that hippie [46:22] world of [46:24] I think it's likes what religion where [46:26] you brought up with yes sir that's right [46:29] most of the actual programming I do is C [46:32] C++ and Python but my weird sort of yeah [46:36] my religious upbringing is unless so can [46:39] you take on the impossible task and give [46:42] a brief history of programming languages [46:44] from your perspective so I guess you [46:47] could say programming languages started [46:48] probably in what the late 40s or [46:51] something like that people used to [46:52] program computers by basically putting [46:55] in zeros and ones using something like [46:56] switches on a console and then or maybe [47:01] holes and paper tapes something like [47:04] that so extremely tedious awful whatever [47:07] and so I think the first programming [47:09] languages were relatively crude assembly [47:13] languages where people would basically [47:17] write a program that would convert [47:19] mnemonics like add a DD into whatever [47:23] the bit pattern was it corresponding to [47:25] an add instruction and they'd do the [47:27] clerical work of figuring out where [47:29] things were so you could put a name on a [47:31] location in a program and the assembler [47:33] would figure out where that corresponded [47:35] to when the thing was all put together [47:37] and dropped into memory and they were [47:41] early on and this would be the late 40s [47:44] and very early 50s there were assemblers [47:47] written for the various machines that [47:50] people used you may have seen in the [47:51] paper just a couple days ago Tony [47:53] Burkert died he did this thing in [47:55] Manchester called the called auto code a [47:58] language for China knew only by name but [48:01] it sounds like it was a flavor of [48:02] assembly language sort of a little [48:05] higher in some ways um and a replaced on [48:07] language that Alan Turing wrote which [48:09] you put in zeros and ones but you put in [48:11] an in backwards order because that was a [48:13] Hardware worked very tense right yeah [48:15] yeah that's right backwards so assembly [48:18] languages learn let's call at the early [48:21] 1950s and so every different flavor of [48:23] computer has its own assembly language [48:25] so the EDSAC head hits in a manchester [48:27] head it and the IBM whatever 70 90 or [48:31] 704 or whatever had hits and so on so [48:34] everybody had their own assembly like [48:35] when assembly languages have a [48:37] few commands addition subtraction then [48:39] branching of some kind if then that the [48:41] situation right they have exactly in [48:44] their simplest form at least one [48:46] instruction per or one assembly language [48:49] instruction per instruction in the [48:51] machine's repertoire and so you have to [48:53] know the Machine intimately to be able [48:55] to write programs in it and if you write [48:57] an assembly language program for one [48:59] kind of machine and then you say jeez [49:00] it's nice I'd like a different machine [49:02] start over okay so very bad and so what [49:06] happened in the late 50s was people [49:09] realize you could play this game again [49:10] and you could move up a level in writing [49:14] or creating languages that were closer [49:16] to the way the real people might think [49:17] about how to write code and we're I [49:21] guess arguably three or four at that [49:24] time period there was Fortran which came [49:27] from IBM which was formula translation [49:29] and to make it easy to do scientific and [49:31] engineering computation is not that [49:33] formula translation that's what I stood [49:35] for yeah I where's COBOL which is the [49:36] common business oriented language that [49:38] Grace Hopper and others worked on which [49:41] was named business kinds of tasks there [49:44] was a well which was mostly meant to [49:46] describe algorithmic computations I [49:48] guess you could argue basic was in there [49:50] somewhere I think it's just a little [49:52] later and so all of those moved the [49:55] level up and so they were closer to what [49:58] you and I might think of as we were [50:00] trying to write a program and they were [50:03] focused on different domains Fortran for [50:06] formula translation engineering [50:08] computations let's say COBOL for [50:10] business that kind of thing still used [50:12] today [50:12] Fortran probably oh yeah COBOL too but [50:16] the deal was that once you moved up that [50:18] level then you let's call it Fortran you [50:21] had a language that was not tied to a [50:23] particular kind of hardware because a [50:25] different compiler would compile for [50:26] different kind of hardware and that [50:28] meant two things [50:29] it meant you only had to write the [50:31] program once which is very important and [50:33] it meant that you could in fact if you [50:36] were a random engineer physicist [50:37] whatever you could write that program [50:39] yourself you didn't have to hire a [50:40] programmer to do it for you might not be [50:43] as good as you'd get through a [50:44] programmer but it was pretty good and so [50:46] it democratized and made much more [50:48] broadly available the ability to write [50:50] code [50:50] so it puts the power of programming to [50:53] the hands of people like you yeah [50:54] anybody who wants to who under to invest [50:57] some time in learning a programming [50:58] language and is not then tied to a [51:00] particular kind of computer and then in [51:04] the 70s you get system programming [51:05] languages of which C is the survivor and [51:08] what what a system programming language [51:11] learning programs that programming [51:14] languages that would take on the kinds [51:16] of things that would necessary to write [51:17] so-called system programs things like [51:19] text editors or assemblers or compilers [51:22] or operating systems themselves those [51:25] kinds of things [51:25] and fortunately feature-rich they have [51:29] to be able to do a lot of stuff a lot of [51:31] memory management access processes and [51:33] all that kind of stuff they a little [51:35] processing it's a different flavor what [51:36] they're doing they're much more in touch [51:39] with the actual machine in a but in a [51:41] positive way that is you can talk about [51:43] memory in a more controlled way you can [51:46] talk about the different data types that [51:47] the Machine supports and underway there [51:50] and more ways to structure and organize [51:53] data and so the system programming [51:56] languages there was a lot of effort in [51:58] that and call it the late 60s early 70s [52:01] C is I think the only real survivor of [52:04] that and then what happens after that [52:08] you get things like object-oriented [52:10] programming languages because as you [52:12] write programs in a language like C at [52:14] some point scale gets to you and it's [52:16] too hard to keep track of the pieces and [52:18] there's no guardrails or training wheels [52:20] or something like that to prevent you [52:22] from doing bad things [52:23] so C++ comes out of that tradition it's [52:28] and then it took off from there I mean [52:29] there's also a parallel slightly [52:31] parallel track with a little bit of [52:32] functional stuff with Lisp and so on but [52:35] I guess from that point is just an [52:37] explosion of languages it was a Java [52:39] story there's the JavaScript there's all [52:42] the stuff that the cool kids these days [52:44] are doing with rust and all that they [52:46] don't so what's to use you're you wrote [52:50] a book C programming language what and C [52:53] is probably one of the most important [52:56] languages in the history of programming [52:57] languages if you kind of look at impact [53:00] what do you think is the most elegant or [53:04] powerful part of see why did it survive [53:07] what did it have such a long-lasting [53:09] impact I think it found a sweet spot [53:13] that in of expressiveness so you can [53:16] rewrite things in a pretty natural way [53:18] and efficiency which was particularly [53:21] important when computers were not nearly [53:23] as powerful as they are today [53:25] again put yourself back 50 years almost [53:29] in terms of what computers could do [53:31] that's you know roughly four or five [53:33] generations decades of Moore's law right [53:36] so expressiveness and efficiency and I [53:41] don't know perhaps the environment that [53:43] it came with as well which was Unix so [53:46] it meant if you wrote a program it could [53:48] be used on all those computers that ran [53:50] UNIX and that was all of those computers [53:51] because they were all written in C in [53:53] that way it was UNIX the operating [53:55] system itself was portable as where all [53:57] the tools so it all worked together [53:59] again and one of these things work [54:01] things fit on each other in a positive [54:04] cycle what did it take to write sort of [54:08] a definitive book probably the [54:10] definitive book on all of programs like [54:12] it's more definitive to a particular [54:14] language than any other book on any [54:15] other language and did two really [54:18] powerful things which is popularized the [54:21] language and at least from my [54:23] perspective maybe you can correct me and [54:25] second is created a standard of how you [54:29] know the how this language is supposed [54:31] to be used and applied so what did it [54:34] take did you have those kinds of [54:36] ambitions in mind when we're working on [54:38] that some kind of joke no of course not [54:41] of the knacks it's an accident of timing [54:45] skill and just luck a lot of it is [54:48] clearly I timing was good [54:51] now Denison I wrote the book in 1977 I [54:53] miss ritchi yeah right and at that point [54:57] UNIX was starting to spread I don't know [54:59] how many there were but it would be [55:00] dozens to hundreds of UNIX systems um [55:02] and C was also available on other kinds [55:06] of computers that had nothing to do with [55:07] UNIX and so the language had some [55:10] potential and there were no other books [55:15] on C and [55:18] Bell Labs was really the only source [55:19] Ford and Dennis of course was [55:21] authoritative because it was his [55:23] language and he had written the [55:25] reference manual which is a marvelous [55:27] example of how to write a reference [55:28] manual really really very very well done [55:31] so I twisted his arm until he agreed to [55:33] write a book and then we wrote a book [55:34] and the virtue our advantage at least I [55:38] guess if going first is that then other [55:40] people have to follow you if they're [55:42] gonna do anything and I think it worked [55:46] well because Dennis's superb writer I [55:50] mean he really really did and that the [55:52] reference manual in that book is his [55:54] period I had nothing to do with that at [55:56] all so just crystal-clear prose and very [56:00] very well expressed [56:01] um and then he and I I wrote most of the [56:05] expository material and then he and I [56:08] sort of did the usual ping-pong game [56:10] back and forth hum refining it but I [56:13] spend a lot of time trying to find [56:14] examples that would sort of hang [56:16] together and they would tell people what [56:18] they might need to know at about the [56:19] right time that they should be thinking [56:21] about needing it and I'm not sure it [56:24] completely succeeded but it mostly [56:26] worked out fairly well what do you think [56:28] is the power of example I mean you're [56:31] you're the creator at least one of the [56:35] first people to do the hello world [56:36] program just like the example if aliens [56:41] discover our civilization hundreds of [56:43] years from now they'll probably hello [56:45] what other programs just like a half [56:47] broken robot communicating with them [56:49] with the hello world so what and that's [56:52] a representative example so what what do [56:54] you find powerful about examples but I [56:57] think a good example will tell you how [57:00] to do something and it will be [57:02] representative of you might not want to [57:04] do exactly that but you will want to do [57:06] something that's at least in that same [57:08] general vein and so a lot of the [57:11] examples in the C book were picked for [57:14] these very very simple straightforward [57:15] text processing problems that were [57:17] typical of UNIX I want to read input and [57:22] write it again there's a copy command I [57:24] want to read input and do something to [57:26] it and write it out again there's a grep [57:28] and so that kind of fine things that are [57:32] representative of what people want to do [57:34] and spell those out so that they can [57:38] then take those and see the the core [57:41] parts and modify them to their taste and [57:45] I think that a lot of programming books [57:48] that I don't look at programming books a [57:51] tremendous amount these days but when I [57:52] do a lot of don't do that they don't [57:54] give you examples that are both [57:57] realistic and something you might want [58:00] to do some of them are pure syntax [58:03] here's how you add three numbers well [58:05] come on I could figure that I would tell [58:07] me how I would get those three numbers [58:09] into the computer and how he would do [58:11] something useful with them and then how [58:13] I put them back out again neatly [58:14] formatted and especially if you follow [58:16] that example there is something magical [58:17] of doing something that feels useful [58:20] yeah right and I think it's the attempt [58:23] and it's absolutely not perfect but the [58:26] attempt in all cases was to get [58:28] something that was going to be either [58:30] directly useful or would be very [58:33] representative of useful things that a [58:35] programmer might want to do but within [58:38] that vein of fundamentally text [58:40] processing reading text doing something [58:42] writing text so you've also written a [58:45] book on go language I'd have to admit so [58:49] I worked at Google for a while and I've [58:51] never used go not you miss something [58:54] well I know I missed something for sure [58:56] I mean yeah so go and rust the two [58:58] languages that I hear very [59:02] spoken very highly of night which I [59:05] would like to try well there's a lot of [59:06] them there's Julia there's there's all [59:08] these incredible modern languages but if [59:11] you can comment before or maybe comments [59:14] on what do you find where does go stood [59:17] in this broad spectrum of languages and [59:19] also how do you yourself feel about this [59:22] wide range of powerful interesting [59:25] languages that you may never even get to [59:28] try to explore of time so I think so go [59:33] um go first comes from that same Bell [59:36] Labs tradition in part not exclusively [59:39] but two of the three creators Ken [59:41] Thompson and Rob Michael literally the [59:43] people yeah the people [59:45] and then with this very very useful [59:47] influence from the European School in [59:50] particular the club spirit influence of [59:53] through Robert Griesemer it was I guess [59:56] a second generation down student at ETH [60:00] and so that's an interesting combination [60:02] of things and so some ways go captures [60:05] the good parts of see it looks sort of [60:09] like see it's sometimes characterized to [60:11] see for the 21st century on the surface [60:14] it looks very very much like see but at [60:17] the same time it has some interesting [60:19] data structuring capabilities and then I [60:22] think the part that I would say is [60:25] particularly useful and again I'm not a [60:28] go expert in spite of co-authoring the [60:31] book about 90% of the work was done by [60:33] Alan Donovan and my co-author who is a [60:35] go expert but go provides a very nice [60:40] model of concurrency it's basically the [60:43] cooperating communicating sequential [60:45] processes that Tony Hoare set forth I [60:49] don't know 40-plus years ago and go [60:52] routines are to my mind a very natural [60:55] way to talk about parallel computation [60:59] and in the few experiments I've done [61:01] with them they're easy to write and [61:02] typically it's going to work and very [61:05] efficient as well so I think that's one [61:08] place where it go stands out at that [61:10] model of parallel computation it's very [61:13] very easy and nice just to comment on [61:16] that do you think c4 saw or the early [61:20] unique States foresaw threads and [61:22] massively parallel computation I would [61:26] guess not really I mean maybe it was [61:28] seen but not at the level where it was [61:31] something you had to do anything about [61:33] for a long time processors got faster [61:37] and then processors stopped getting [61:40] faster because of things like power [61:42] consumption and heat generation and so [61:46] what happened instead was that instead [61:49] of processors getting faster there [61:50] started to be more of them and that's [61:52] where that parallel thread stuff comes [61:55] in so if you can comment on the [61:59] the other languages is it break your [62:02] heart that you'll never get to explore [62:03] them of course how do you feel a lot of [62:05] the full variety it's not break my heart [62:08] but but I would love to be able to try [62:11] more of these languages the closest I've [62:13] come is in class that I often teach in [62:15] the spring here it's a programming class [62:17] and I often give I have one sort of [62:22] small example that I will write in as [62:25] many languages as I possibly can I've [62:27] got it in 20 on languages at this point [62:29] and and that's so I do a minimal [62:33] experiment with on language just to say [62:35] okay I have this trivial task which I [62:37] understand the task and it should it [62:39] takes 15 lines in awk and not much more [62:42] in a variety of other languages so how [62:44] big is it how fast does it run and what [62:46] pain did I go through to learn how to do [62:49] it and that's a it's like an Akita right [62:55] it's a very very very narrowly like that [62:58] so yeah but still it's a little sample [63:01] because you get to I think the hardest [63:03] step of the programming language is [63:05] probably the first step right so there [63:07] you're taking the first step yeah and [63:09] from my experience um with some [63:12] languages is very positive [63:14] like Lua a scripting language I'd never [63:16] used and I took my Britain little [63:19] program the program is a trivial [63:20] formatter it just takes in lines of text [63:23] of varying lengths and it puts them out [63:25] in lines that have no more than 60 [63:27] characters on each line so think it was [63:29] just kind of the flow of process in a [63:32] browser or something so it's very short [63:35] program and um in Lua I downloaded Lua [63:39] and in an hour I had it working [63:40] never having written Lua in my life just [63:43] going with online documentation I did [63:45] the same thing in Scala which you can [63:46] think of as a flavor of Java equally [63:49] trivial I did it in Haskell it took me [63:52] several weeks but it did run like a [63:57] turtle and and I did it in Fortran 90 [64:03] and it painful but it worked and I tried [64:07] it in rust and it took me several days [64:08] to get it working because the model of [64:11] memory manage [64:11] it was just a little unfamiliar to me [64:13] and the problem I had with rust and it's [64:16] back to what we were just talking about [64:17] I couldn't find good consistent [64:20] documentation on rust now this was [64:21] several years ago and I'm sure things [64:23] have stabilized but at the time [64:24] everything in the rust world seemed to [64:26] be changing rapidly and so you would [64:28] find what looked like a working example [64:30] and it wouldn't work [64:31] with the version of the language that I [64:33] had so it took longer than it should [64:35] have rust is a language I would like to [64:38] get back to but probably won't I think [64:41] one of the issues you have to have [64:42] something you want to do if you don't [64:44] have something that is the right [64:46] combination if I want to do it and yet I [64:49] have enough disposable time whatever to [64:53] make it worse than learning a new [64:54] language at the same time it's never [64:56] going to happen so what do you think [64:58] about another language of JavaScript [65:01] that's this well let me just sort of [65:05] comment on what I said when I was [65:07] brought up sort of JavaScript pasina's [65:10] the probably like the ugliest language [65:14] possible and yet it's quite arguably [65:17] quite possibly taking over not just the [65:19] fun in the back end of the internet but [65:21] possibly in the future taking over [65:23] everything because they've now learned [65:25] to make it very efficient yeah so what [65:28] do you think about this yeah well I [65:30] think you've captured it in a lot of [65:31] ways when it first came out javascript [65:33] was deemed to be fairly irregular in an [65:35] ugly language and certainly in the [65:37] academy if you said you were working on [65:38] javascript people would ridicule you it [65:40] was just not fit for academics to work [65:42] on I think a lot of that has evolved the [65:45] language itself has evolved and [65:47] certainly the technology of compiling it [65:50] is fantastically better than it was and [65:53] so in that sense it's a absolutely a [65:56] viable solution upon backends as well [65:59] it's the front-end used well I think [66:02] it's a pretty good language I've written [66:03] a modest amount of it and I've played [66:07] with JavaScript translators and things [66:09] like that I'm not a real expert and it's [66:12] hard to keep up even there with the new [66:14] things that come along with it um so I [66:18] don't know whether it will ever take [66:20] over the world I think not but it it's [66:23] certainly an important [66:25] language and worth knowing more about [66:28] theirs [66:29] this may be to get your comment on [66:32] something which javascript and actually [66:34] most languages of Python such a big part [66:38] of the experience of programming with [66:40] those languages includes libraries sort [66:42] of using building on top of the code [66:44] that other people have built I think [66:46] that's probably different from the [66:47] experience that we just talked about [66:49] from UNIX and C days when you're [66:52] building stuff from scratch what do you [66:53] think about this world of essentially [66:56] leveraging building up libraries on top [66:57] of each other and leveraging them yeah [66:59] that's a very perceptive kind of [67:01] question one of the reasons programming [67:05] was fun in the old days was that you [67:07] were really building it all yourself the [67:09] number of libraries you had to deal with [67:10] was quite small maybe it was printf or [67:12] the standard library or something like [67:14] that and that is not the case today and [67:17] if you want to do something in you [67:20] mentioned Python and JavaScript and [67:22] those are the two finding examples you [67:24] have to typically download a boatload of [67:27] other stuff and you have no idea what [67:29] you're getting absolutely nothing [67:30] I've been doing some playing with [67:32] machine learning over the last couple of [67:34] days and G something doesn't work well [67:38] you pip install this okay and down comes [67:41] another gazillion megabytes of something [67:44] and you have no idea what it was and if [67:46] you're lucky it works and if it doesn't [67:48] work you have no recourse there's [67:51] absolutely no way you could figure out [67:52] which in these thousand different [67:54] packages and I think it's worse in the [67:57] MPM NPM environment for JavaScript I [68:00] think there's less discipline less [68:01] control there and there's aspects of not [68:05] just not understanding how it works but [68:06] there's security issues is there Busta's [68:08] issues so you don't want to run a [68:10] nuclear power plant using JavaScript [68:12] essentially oh probably not so it's [68:16] speaking to the variety of languages do [68:18] you think that variety is good or do you [68:20] hope think that over time we should [68:23] converge towards one two three [68:25] programming languages that's you [68:28] mentioned to the bailout days when [68:29] people could sort of the community of it [68:32] and the more languages you have the more [68:34] you separate the communities is the Ruby [68:37] there's the Python community there's C++ [68:41] community do you hope that there they'll [68:43] unite one day - just one or two [68:46] languages I certainly don't hope it I'd [68:48] not sure that that's right because I [68:50] honestly don't think there is one [68:51] language that will suffice for all the [68:53] programming needs of the world are there [68:55] too many at this point well arguably um [68:58] but I think if you look at the sort of [69:00] the distribution of how they are used [69:02] there's something called a dozen [69:05] languages that probably count for 95% of [69:09] all programming at this point and that [69:11] doesn't seem unreasonable and then [69:14] there's another well 2000 languages that [69:17] are still in use that nobody uses and or [69:20] at least don't use in any quantity but I [69:23] think new languages are a good idea in [69:25] many respects because they're often a [69:26] chance to explore an idea of how a [69:31] language might help I think that's one [69:33] of the positive things about functional [69:35] languages for example they're a [69:37] particularly good place where people [69:39] have explored ideas that at the time [69:43] didn't seem feasible but ultimately have [69:46] wound up as part of mainstream languages [69:49] as well let me just go back as early as [69:51] recursion Lisp and then follow forward [69:54] with functions as first-class citizens [69:56] and pattern based languages and gee I [70:00] don't know closures and just on and on [70:03] and on lambdas interesting ideas that [70:05] showed up first in let's call it broadly [70:08] the functional programming community and [70:10] then find their way into mainstream [70:12] languages yes it's a playground for [70:14] rebels yeah exactly and and so I think [70:18] the language is in the playground [70:20] themselves are probably not going to be [70:23] the mainstream at least for some welp [70:25] but the ideas that come from there are [70:27] invaluable so let's go to something that [70:31] when I found out recently so I known [70:34] that you've done a million things but [70:36] one of the things I wasn't aware of the [70:37] you had a role in ample and I before you [70:41] interrupt me by minimizing your role in [70:43] it but your hapless for minimizing [70:46] functions [70:46] yeah minimizing functions right exactly [70:48] I can't just say that the elegance and [70:52] abstraction power of an ample is [70:55] incredible all right when I first came [70:58] to it about ten years ago or so can you [71:01] describe what is the ample language sure [71:04] so ample is a language for mathematical [71:07] programming technical term think of it [71:09] as linear programming that is setting up [71:11] systems of linear equations that are [71:16] some sort of system of constraints so [71:18] that you have a bunch of things that [71:20] have to be less than this greater than [71:22] that or whatever and you're trying to [71:23] find a set of values for some decision [71:26] variables that will maximize or minimize [71:29] some objective function so it's it's a [71:33] way of solving a particular kind of [71:36] optimization problem a very formal sort [71:38] of optimization problem but one that's [71:40] exceptionally useful and it specifies so [71:43] there's objective function of [71:45] constraints and variables that become [71:47] separate from the data it operates on [71:49] right so the that kind of separation [71:53] allows you to you know put on different [71:57] hats won't put the Hat of an [71:59] optimization person and then put a [72:00] another hat of a data person and dance [72:03] back and forth and and also separate the [72:06] actual solvers the optimization systems [72:10] that do the solving then you can have [72:12] other people come to the table and then [72:14] build their solvers whether it's linear [72:16] or nonlinear [72:18] convex non convex that kind of stuff so [72:23] what is the do use may be in common how [72:28] you got into that world and what is a [72:31] beautiful or interesting idea to you [72:33] from the world of optimization sure so I [72:36] preface it by saying I'm absolutely not [72:39] an expert on this and most of the [72:41] important work in and [72:42] comes from my two partners in crime on [72:45] that Bob Fuhrer who was a professor of [72:47] and in the industrial engineering and [72:50] management science department at [72:51] Northwestern and my colleague at Bell [72:53] Labs Dave Gay who is a numerical [72:55] analysts an optimization person so the [72:59] deal is linear programming preface this [73:02] by saying linear program is the simplest [73:06] example of this so linear program is [73:08] taught in school is that you have a big [73:10] matrix which is always called a and you [73:12] say ax is less than or equal to B so B [73:15] is a set of constraints X is the [73:16] decision variables and a as to how the [73:19] decision variables are combined to set [73:23] up the various constraints so a as a [73:25] matrix and X and B your vectors and then [73:28] there's an objective function which is [73:30] just the sum of a bunch of X's and some [73:32] coefficients on them and yet that's the [73:34] thing you want to optimize the problem [73:37] is that in the real world that matrix a [73:40] is a very very very intricate very large [73:44] and very sparse matrix where the various [73:46] components of the model are distributed [73:49] among the coefficients in a way that is [73:51] totally on obvious to anybody and so [73:55] what you need is some way to express the [73:59] original model which you and I would [74:00] write you know we'd write mathematics on [74:02] the board and the sum of this is greater [74:04] than the sum of that kind of thing so [74:06] you need a language to write those kinds [74:09] of constraints and Bob for a long time [74:12] had been interested in modeling [74:13] languages languages that made it [74:15] possible to do this there was a modeling [74:17] language around called gams the general [74:19] algebraic modeling system but it looked [74:21] very much like Fortran was kind of [74:23] clunky [74:23] um and so Bob spent a sabbatical year at [74:26] Bell Labs in 1984 and he and wasn't in [74:31] the office across from me and it's [74:34] always geography and he and Dave Gay and [74:37] I started talking about this kind of [74:38] thing and he wanted to design a language [74:42] that would make it so that you could [74:44] take these algebraic specifications you [74:46] know summation signs over sets and that [74:49] you would write on the board and convert [74:51] them into basically this a matrix [74:55] and then pass that off to a solver which [74:59] is an entirely separate thing and so we [75:02] talked about the design if the language [75:05] I don't remember any of the details of [75:06] this now but it's kind of an obvious [75:08] thing you're just writing mathematical [75:10] expressions in a Fortran like sorry in [75:13] algebra but textual like language and I [75:17] wrote the first version of this ample [75:20] program my first C++ program and that's [75:26] written in C++ yep and so I did that [75:30] fairly quickly we wrote it was you know [75:32] 3,000 lines or something so it wasn't [75:33] very big but it just sort of showed the [75:35] feasibility of it that you could [75:36] actually do something that was easy for [75:38] people to specify models and convert it [75:42] into something that a solver could work [75:44] with at the same time as you say that [75:46] model and the data are separate thing so [75:47] one model would then work with all kinds [75:50] of different data in the same way lots [75:52] of programs do the same thing but with [75:53] different data so one of the really nice [75:55] things is the the specification of the [75:57] models human just kind of like as you [76:00] say is human readable like I literally [76:02] I'm ever on stuff I work I I would send [76:06] it to colleagues that I'm pretty sure [76:08] never programmed just just to understand [76:13] what the optimization problem is I think [76:15] how hard is it to convert that you said [76:18] you there's a first prototype in C++ to [76:20] convert that into something that could [76:22] actually be used by the solver it's not [76:24] too bad because most of the solvers have [76:26] some mechanism that lets them import a [76:28] model in AI form it might be as simple [76:31] as the matrix itself in just some [76:33] representation or if you're doing things [76:36] that are not linear programming and [76:38] there may be some mechanism that you [76:40] provide things like functions to be [76:42] called [76:42] or other constraints on the model so so [76:48] all ample does is to generate that kind [76:50] of thing and then solver deals with all [76:53] the hard work and then when the solver [76:54] comes back with numbers and Vil converts [76:58] those back into your original form so [77:00] you know how much of each thing you [77:01] should be buying or making or shipping [77:04] or what [77:05] so we did that in 84 and I haven't had a [77:10] lot to do with it since except that we [77:12] wrote a couple of versions of a book on [77:14] which is one of the greatest books ever [77:16] written I love that book I don't know [77:18] why it's an excellent book but for wrote [77:21] most of it and so it's really really [77:23] well done he must be a dynamite teacher [77:25] and typeset in late Dec no no no are you [77:28] kidding I really like in the typography [77:31] so I don't know we did it with tear off [77:33] I don't even know what that is yeah [77:35] exactly [77:36] you could go I think of tear off is as a [77:40] predecessor to the tech family of things [77:44] it's a formatter that was done at Bell [77:45] Labs in this same period of the very [77:47] early 70s [77:48] oh that predates tech and things like [77:52] that plate mmm 5 to 10 years it was [77:55] nevertheless they just I'm going by [77:57] memories it was I remember it being [77:58] beautiful yeah it was nice outside of [78:02] UNIX Iago laying all the things we [78:04] talked about all the amazing work you've [78:06] done you've also done working graph [78:09] theory [78:11] let me ask this this crazy out there [78:14] question if you had to make a bet and I [78:17] had to force you to make a bet do you [78:19] think P equals NP the answer is no [78:24] although I've told that somebody asked [78:25] Jeff Dean if that was the what [78:28] conditions B would equal NP and he said [78:30] either P is 0 or n is 1 or vice versa [78:34] I've forgotten so but your intuition is [78:41] I haven't no I have no intuition but [78:44] I've got a lot of colleagues who've got [78:46] intuition and their betting is no that's [78:48] the popular that's the popular bet okay [78:51] so what is computational complexity [78:54] theory and do you think these kinds of [78:57] complexity classes especially as you've [78:59] taught in this modern world there are [79:01] still a useful way to understand the [79:04] hardness of problems I don't do that [79:06] stuff the last time I touched anything [79:08] to do with that was before it was [79:11] invented because I it's literally true I [79:14] did my PhD thesis on good for big on on [79:18] tape [79:18] you know absolutely before I I did this [79:21] in 1968 and I worked on graph [79:25] partitioning which is this question [79:26] you've got a graph that is a nodes and [79:28] edges kind of graph and the edges have [79:31] weights and you just want to divide the [79:32] nodes into two piles of equal size so [79:35] that the number of edges that goes from [79:37] one side to the other is as small as [79:38] possible and we he developed so that [79:42] problem is hard well as it turns out I [79:47] work with Shen Lin at Bell Labs on this [79:49] and we were never able to come up with [79:52] anything that was guaranteed to give the [79:53] right answer we came up with heuristics [79:55] that worked pretty darn well and I [79:58] peeled off some special cases for my [80:00] thesis but it was just hard and that was [80:02] just about the time that Steve Cooke was [80:04] showing that there were classes of [80:06] problems that appeared to be really hard [80:07] of witchcraft partitioning was one but [80:10] this my expertise such as it was totally [80:14] predates that development Oh interesting [80:17] so the the heuristic which now you're [80:19] who cares the two of years names for the [80:22] Traveling Salesman problem at for the [80:24] graph partitioning that was like how did [80:26] you you weren't even thinking in terms [80:28] of classes you're just trying to was no [80:30] such idea a heuristic that kind of does [80:33] the job pretty well you were trying to [80:34] find a something that did the job and [80:36] there was no nothing that you would call [80:38] let's say a closed-form or algorithmic [80:41] thing that would give you a guaranteed [80:43] right answer I mean compare graph [80:45] partitioning to max-flow min-cut or [80:48] something like that that's the same [80:50] problem except there's no constraint on [80:52] the number of nodes on one side or the [80:54] other of the cut and that means it's an [80:57] easy problem at least as I understand it [80:59] whereas the constraint that says the two [81:01] have to be constrained in size makes it [81:03] a hard problem yes so the Robert Frost [81:06] has that poem where you choose two paths [81:09] so what why did you is there another [81:12] alternate universe in which you pursued [81:14] the Don Knuth path of you know algorithm [81:18] designs and of not smart enough that's [81:21] smart enough for you're infinitely [81:26] modest but so you proceed you're kind of [81:28] love of programming [81:31] I mean when you look back to those I [81:33] mean just looking into that world does [81:35] that just seem like a distant world of [81:38] theoretical computer science then is it [81:41] fundamentally different from the world [81:42] of programming I don't know I mean [81:45] certainly in all series and as I just [81:47] didn't have the talent for it I when I [81:49] got here is a grad student to Princeton [81:51] and I started to think about research at [81:53] the end of my first year or something [81:56] like that I work briefly with John [81:58] Hopkins absolutely you know he mentioned [82:01] during award-winner it said her a great [82:02] guy and it became crystal clear I was [82:05] not cut out for this stuff period okay [82:08] and so I moved into things where I was [82:11] more cut out for it and that tended to [82:15] be things like writing programs and [82:17] ultimately writing books you've said [82:21] that in Toronto as an undergrad you did [82:23] a senior thesis or literature survey on [82:26] artificial intelligence this was 1964 [82:30] correct what was the AI landscape ideas [82:34] dreams at that time I think that was one [82:38] of the well you've heard of AI winters [82:40] this is whatever the opposite was AI [82:41] summer or something there's one of these [82:44] things where people thought that boy we [82:47] could do anything with computers that [82:49] all these hard problems we could [82:51] computers will solve them they will do [82:53] machine translation they will play games [82:56] like chess that they will do mission you [83:00] know prove theorems in geometry there [83:02] are all kinds of examples like that [83:03] where people thought boy we could really [83:07] do those sorts of things um and you know [83:12] I I read the kool-aid in some times it's [83:15] a wonderful collection of papers called [83:17] computers and thought that was published [83:18] and about that era and people were very [83:21] optimistic and then of course it turned [83:23] out that what people thought was just a [83:25] few years down the pike was more than a [83:29] few years down the pike and some parts [83:32] of that are more or less now sort of [83:34] under control [83:35] I we finally do play games like go and [83:38] chess and so on better than then people [83:40] do but there are others on machine [83:42] translation is a lot better than it you [83:44] to be but that's 50 close to 60 years of [83:48] progress and a lot of evolution in [83:50] hardware and a tremendous amount more [83:52] data upon which you can build systems [83:56] that actually can learn from some of [83:58] that and and the the infrastructure to [84:01] support developers working together like [84:03] an open source moving the internet [84:06] period is also an empowering but what [84:09] lesson do you draw from that the [84:11] opposite of winter that optimism well I [84:15] guess the lesson is that in the short [84:18] run it's pretty easy to be too [84:22] pessimistic or maybe too optimistic and [84:24] in the long run you probably shouldn't [84:26] be too pessimist I'm not saying that [84:27] very well it reminds me of this remark [84:31] from Arthur Clarke science fiction [84:33] author who says you know when some [84:34] distinguished but elderly person says [84:36] that something is him is possible he's [84:40] probably right and if he says it's [84:41] impossible he's almost surely wrong but [84:44] you don't know what the time scale is at [84:45] time scale is good all right so what are [84:48] your thoughts on this new summer of AI [84:51] now in the work with machine learning in [84:54] your networks you've kind of mentioned [84:56] he started to try to explore and look [84:58] into this world that seems fundamentally [85:00] different from the world of heuristics [85:03] and algorithms like search that it's now [85:06] purely sort of trying to take huge [85:09] amounts of data and learn learn from [85:11] that data right programs from the data [85:13] no look I think it's it's very [85:15] interesting I am incredibly far from an [85:19] expert most of what I know I've learned [85:20] from my students and they're probably [85:23] disappointed in how little I've learned [85:25] from them but um I think it has [85:28] tremendous potential for certain kinds [85:30] of things in games is one where it [85:32] obviously has had an effect on some of [85:34] the others as well I think there's and [85:37] this is speaking from definitely not [85:40] expertise I think there are serious [85:41] problems in certain kinds of machine [85:44] learning learning at least because what [85:46] they're learning from is the data that [85:48] we give them and if the data we give [85:50] them has something wrong with it then [85:52] what they learn from it is probably [85:54] wrong too and the obvious thing is some [85:57] kind of bias in the [85:58] that the data has stuff in it like I [86:01] don't know women earned as good at men [86:03] as men at something okay that's just [86:05] flat wrong but if it's in the data [86:08] because of historical treatment then [86:11] that machine learning stuff will [86:13] propagate that and that is a serious [86:16] worry the the positive part of that is [86:20] what machine learning does is reveal the [86:23] bias in the data and puts a mirror to [86:25] our own society and in so doing helps us [86:28] remove the bite you know helps us work [86:32] on ourselves it's a mirror to ourselves [86:35] yeah that's an optimistic point of view [86:37] and if it works that way that would be [86:38] absolutely great and and what I don't [86:40] know is whether it does work that way or [86:42] whether the the you know the AI [86:45] mechanisms or machine learning [86:46] mechanisms reinforce and amplify things [86:50] that have been wrong in the past and I [86:52] don't know I but I think that's a [86:55] serious thing that we have to be [86:57] concerned about let me ask you another [86:59] question okay I know nobody knows but [87:02] what do you think it takes to build a [87:05] system of human level intelligence [87:06] that's been the dream from the 60s we [87:09] talk about games about language about [87:13] about image recognition but really the [87:15] dream is to create human level or [87:18] superhuman level intelligence what do [87:19] you think it takes to do that and are we [87:21] close [87:22] I haven't a clue and I don't know trying [87:27] to trick you into a hypothesis I mean [87:30] Turing talked about this in his paper on [87:32] machine intelligence back and she's in [87:35] early 50s or something like that and he [87:36] had the idea of the Turing test and I [87:38] don't know what the Turing test is I [87:42] don't know it's an interesting test at [87:43] least it's in some vague sense objective [87:45] whether you can read anything into the [87:47] conclusions is a different story [87:49] do you have worries concerns excitement [87:55] about the future of artificial [87:56] intelligence so there's a lot of people [87:57] for worried and you can speak broadly [88:00] than just artificial intelligence is [88:01] basically computing taking over the [88:05] world in various forms are you excited [88:07] by this future this possibility of [88:10] computing being everywhere [88:11] or are you worried it's some combination [88:15] of those I I think almost all [88:18] technologies over the long run are for [88:22] good but there's plenty of examples [88:24] where they haven't been good either over [88:27] a long run for some people or over a [88:29] short run um [88:30] and computing is one of those and AI [88:33] within it is gonna be one of those as [88:36] well but computing broadly I mean for [88:38] just a today example is privacy that um [88:42] the use of things like social media and [88:45] so on means that in the commercial [88:48] surveillance means that there's an [88:50] enormous amount more known about us by [88:52] people other you know businesses [88:55] government whatever then perhaps one [88:57] ought to feel comfortable with so that's [88:59] an example that's an example pause a [89:05] possible negative negative effect of [89:07] competing being everywhere it's a it's [89:10] an interesting one because it could also [89:12] be a positive leverage correctly there's [89:16] a big if there so I I you know I've I [89:21] have a deep interest in human psychology [89:22] and humans are seem to be very paranoid [89:24] about this data thing at a but that [89:29] varies depending on age group yes it [89:31] seems like the younger folks so it's [89:33] exciting to me to see what society looks [89:35] like fifty years from now that the [89:38] concerns of our privacy might be flipped [89:39] on their head based purely on human [89:42] psychology versus actual concerns or not [89:45] yeah what do you think about Moore's law [89:49] well you said a lot of stuff we've [89:51] talked you talked about what programming [89:53] languages in their design and their [89:55] ideas are come from the constraints and [89:58] the systems they operate and do you [90:00] think Moore's Law the the exponential [90:05] improvement of systems will continue [90:07] indefinitely there's there's mix of [90:10] opinions on that currently or do you [90:12] think do you think there will be do you [90:17] think there'll be a plateau [90:18] well the furball is answer there's no [90:20] exponential can go on forever you run [90:24] out of something [90:25] um just as we said timescale matters so [90:27] if it goes on long enough [90:29] that might be all I need yeah right [90:31] won't matter does uh so I don't know [90:33] we've seen places where Moore's law has [90:35] changed for example mentioned earlier [90:37] process processors don't get faster [90:40] anymore but you used that same growth of [90:44] you know building put more things in a [90:46] given area to grow them horizontally [90:49] instead of vertically as it were so you [90:51] can get more and more processors or [90:52] memory or whatever on the same chip is [90:55] that gonna run into a limitation [90:57] presumably because you know at some [91:00] point you get down to the individual [91:02] atoms and so you got to find some way [91:04] around that will we find some way around [91:06] that I don't know I just said that if I [91:09] say it I'll be wrong we will say I just [91:12] talked to Jim Keller and he says so he [91:15] actually describes he argues that the [91:17] Moore's law will continue for a long [91:18] long time because you mentioned the atom [91:21] we actually have I think a thousandfold [91:24] increase to a decrease in threaten [91:27] transistor size still possible before we [91:30] get to the quantum level so it's there's [91:32] still a lot of possibilities he thinks [91:35] he'll continue indefinitely which is an [91:36] interesting optimistic optimistic [91:39] viewpoint but how do you think the [91:42] programming languages will change for [91:44] this increase whether we hit a wall or [91:46] not what do you think do you think [91:50] there'll be a fundamental change in the [91:51] way programming languages are designed I [91:53] don't worry about that I think what will [91:56] happen is continuation of what we see in [92:01] some areas at least which is that more [92:03] programming will be done by programs [92:06] than by people and that more will be [92:10] done by sort of declarative rather than [92:13] procedural mechanisms where I say I want [92:16] this to happen you figure out how and [92:20] that is in many cases at this point [92:23] domain of specialized languages for [92:26] narrow domains but you can imagine that [92:30] broadening out and so I don't have to [92:32] say so much in so much detail some [92:36] collection of software let's call it [92:38] language [92:39] or programs or something we'll figure [92:41] out how to do what I want to do some [92:45] increased levels of abstraction yeah and [92:48] one day getting to the human level maybe [92:51] just use so you taught so teach of [92:56] course computers in our world here at [92:58] Princeton that introduces computing and [93:01] programming to non majors what just from [93:06] that experience what advice do you have [93:07] for people who don't know anything about [93:09] programming but I'm kind of curious [93:11] about this world or programming seems to [93:13] become more and more of a fundamental [93:15] skill that people need to be at least [93:17] the world yeah well I could recommend a [93:19] good book what's that for the course I [93:23] think this is one of these questions of [93:26] should everybody know how to program and [93:28] I think the answer is probably not but I [93:31] think everybody should at least [93:32] understand sort of what it is so that if [93:34] you say to somebody I'm a programmer [93:36] they have a notion of what that might be [93:37] or if you say this is a program or this [93:40] was decided by a computer running a [93:42] program that they have some vague [93:45] intuitive understanding and an accurate [93:48] understanding of what that might imply [93:51] so part of what I'm doing in this course [93:54] which is very definitely for [93:56] non-technical people I mean typical [93:58] person in it is a history or English [93:59] major try and explain how computers work [94:03] how they do their thing what programming [94:05] is how you write a program and how [94:09] computers talk to each other and what do [94:12] they do when they're talking to each [94:13] other and then I would say nobody very [94:18] rarely and does anybody in that course [94:21] go on to become a real serious [94:22] programmer but at least they've got a [94:25] somewhat better idea of what all this [94:27] stuff is about not just the programming [94:29] but the technology behind computers and [94:31] communications do they write up do they [94:33] try and write a program themselves oh [94:35] yeah yeah a very small amount I [94:38] introduced them to how machines work at [94:40] a level below high-level languages so we [94:43] have a kind of a toy machine and has a [94:45] very small repertoire dozen instructions [94:47] and they write trivial assembly language [94:50] program Wow that's okay [94:53] just if you were to give a flavor to [94:55] people of the programming world for the [94:57] competing world what what are the [95:00] examples it should go with so a little [95:02] bit of assembly to get a sense at the [95:04] lowest level of what the program is [95:06] really doing yeah there's I mean in some [95:10] sense there's no such thing as the [95:11] lowest level because you can keep going [95:13] down but that's the place where I drew [95:14] the line so the idea that computers have [95:17] a fairly small repertoire of very simple [95:20] instructions that they can do like add [95:22] and subtract and and branch and so on as [95:25] you mentioned earlier and that you can [95:29] write code at that level and it will get [95:32] things done and then you have the levels [95:34] of abstraction that we get with [95:36] higher-level languages like Fortran or C [95:38] or whatever and that makes it easier to [95:41] write the code and less dependent on [95:43] particular architectures and then we [95:46] talk about a lot of the different kinds [95:48] of programs that they use all the time [95:50] that they don't probably realize our [95:51] programs like they're running Mac OS on [95:55] their computers or maybe Windows and [95:59] they're downloading apps on their phones [96:00] and all of those things are programs [96:02] that are just what we just talked about [96:05] except at a grand scale it's easy to [96:08] forget that they're actual programs that [96:10] people program there's engineers they [96:12] wrote wrote those things yeah right and [96:14] so in a way I'm expecting them to make [96:19] an enormous conceptual leap from their 5 [96:21] or 10 line toy assembly language thing [96:24] that adds two or three numbers to you [96:27] know something that is a browser on [96:29] their phone or whatever but but it's [96:32] really the same thing if you look at the [96:35] broad and broad strokes at history what [96:38] do you think the world like how do you [96:40] think the world change because of [96:41] computers it's hard to sometimes see the [96:44] big picture when you're in it you know [96:46] but I guess I'm asking if there's [96:48] something you've noticed over the years [96:50] that like you were mentioned the [96:54] students are more distracted looking at [96:56] their now there's a device to look at [96:58] right well I think computing has changed [97:00] its rendus amount and obviously but I [97:02] think one aspect of that is the way that [97:04] people interact with each other [97:06] both locally and faraway and when I was [97:10] you know the age of those kids making a [97:12] phone call to somewhere was a big deal [97:14] because it cost serious money and this [97:17] was in the 60s right and today people [97:21] don't make phone calls they send texts [97:23] or something like that so it there's a [97:26] up and down and what people do people [97:29] think nothing of having correspondence [97:33] regular meetings video whatever with [97:36] friends or family or whatever in any [97:38] other part of the world and they don't [97:40] think about that at all they and so [97:43] that's just the communication aspect of [97:46] it and do you think that brings us [97:49] closer together or does it make us do [97:54] this does it take us away from the [97:57] closeness of human human contact I think [97:59] it depends a lot on all kinds of things [98:02] so I trade mail with my brother and [98:04] sister in Canada much more often than I [98:07] used to talk to them on the phone [98:08] so probably every 2 or 3 days I get [98:10] something or send something to them [98:13] whereas 20 years ago I probably wouldn't [98:18] have talked to them on the phone nearly [98:20] as much so in that sense I that's [98:21] brought my brother and sister and I [98:23] closer together that's a good thing um I [98:25] watch the kids on campus and they're [98:29] mostly walking around with their heads [98:30] down fooling with their phones to the [98:32] point where I have to duck them yeah I [98:34] don't know that that has brought them [98:37] closer together in some ways there's [98:41] sociological research that says people [98:43] are in fact not as close together as [98:45] they used to be I don't know whether [98:46] that's really true but but I can see [98:49] potential downsides and kids where you [98:52] think come on wake up and smell the [98:55] coffee or whatever that's right but if [98:57] you look at again nobody can predict the [98:59] future but are you excited kind of touch [99:03] this a little bit with with AI but are [99:06] you excited by the future in the next 10 [99:08] 20 years the computing will bring you [99:11] viewer there when there was no computers [99:14] really and now computers are everywhere [99:17] all over the world and [99:20] Africa and Asia and just every every [99:22] person almost every person the wall has [99:24] a device so are you hopeful optimistic [99:27] about that future I it's mixed if the [99:31] truth be told I mean I think there are [99:33] some things about that that are good I [99:34] think there's the potential for people [99:36] to improve their lives all over the [99:38] place and that's obviously good and at [99:41] the same time at least in the short time [99:43] short-run you can see lots and lots of [99:45] bad as people become more tribalistic [99:48] or parochial in their interests and it's [99:50] an enormous amount more us and them and [99:52] people are using computers in all kinds [99:55] of ways to mislead or misrepresented or [99:58] flat-out lie about what's going on and [100:00] that is affecting politics locally and I [100:02] think everywhere in the world [100:04] yeah the the long-term effect on [100:07] political systems and so on it's who [100:10] knows knows indeed the the the people [100:15] now have a voice which is a powerful [100:17] thing people who are press have a voice [100:20] but also everybody has a voice and the [100:24] chaos that emerges from that is [100:25] fascinating to watch yeah yeah it's kind [100:27] of scary if you can go back and relive a [100:31] moment in your life one that made you [100:34] truly happy outside of family or was [100:37] profoundly transformative is there a [100:40] moment or moments that jump out at you [100:44] from memory [100:44] I don't think specific moments I think [100:48] there were lots and lots and lots of [100:49] good times at Bell Labs where you would [100:51] build something and it it worked [100:54] hi Jase a work so the moments at war who [100:57] stood yeah and and somebody used it from [100:59] they said gee that's neat those kinds of [101:01] things happened quite often in that sort [101:05] of golden era and that the 70s when UNIX [101:08] was young and there was all this [101:10] low-hanging fruit and interesting things [101:12] to work on a group of people who kind of [101:15] we were all together in this and if you [101:17] did something they would try it out for [101:20] you and I think that was in some sense a [101:22] really really good time and Ock was a [101:25] was an example of that then you drilled [101:28] it and people use that yeah absolutely [101:29] and now millions of people use any and [101:32] all your stupid mistakes [101:33] right there for them to look at so it's [101:36] mixed [101:37] yeah it's terrifying vulnerable buds [101:39] beautiful because it does have a [101:40] positive impact on so so many people so [101:44] I think there's no better way to end it [101:47] Brian thank you so much for talking it [101:48] was an honor okay [101:49] likes it my pleasure good fun [101:53] thank you for listening to this [101:54] conversation with Brian Kernighan and [101:56] thank you to our sponsors 8:00 sleep [101:58] mattress and rake on earbuds please [102:02] consider supporting this podcast by [102:05] going to a sleep calm slash Lex and to [102:09] buy rake on comm slash Lex click the [102:12] links buy the stuff these both are [102:15] amazing products it really is the best [102:17] way to support this podcast and the [102:20] journey I'm on it's how they know I sent [102:22] you and increases the chance that [102:24] they'll actually support this podcast in [102:26] the future if you enjoy this thing [102:28] subscribe on youtube review it with fire [102:31] stars an apple podcast supported on [102:33] patreon or connect with me on Twitter at [102:35] Lex Freedman spelled somehow [102:38] miraculously without the letter e just [102:41] Fri D ma n because when we immigrated to [102:45] this country we were not so good at [102:47] spelling and now let me leave you with [102:50] some words from Brian Kernighan don't [102:53] comment bad code rewrite it [102:57] you for listening and hope to see you [102:59] next time [103:06] you