Interview
Brian Kernighan: UNIX, C, AWK, AMPL, and Go Programming | Lex Fridman Podcast #109
Unix Origins and History
- Unix development began in 1969 at Bell Labs following the abandonment of the Multics project by Bell Labs, MIT, and General Electric due to timeline delays and excessive cost.
- Ken Thompson developed the initial Unix operating system over a three-week period in 1969 on a little-used, 16KB memory Digital Equipment Corporation (DEC) PDP-7 mini-computer.
- The first Unix version was written in PDP-7 assembly language, which included an assembler, a text editor (derived from ED), and file system handling capabilities.
- The original Unix philosophy prioritized a "programmer environment" designed to maximize productivity, fostering a community where tools and code were easily shared and iterated upon.
- Bell Labs distributed source code freely to universities for many years; while legally proprietary and licensed by AT&T, this model created a pragmatic "open source" effect that seeded the modern Unix ecosystem.
- The Berkeley Software Distribution (BSD) evolved from licensed AT&T code, eventually becoming fully independent of AT&T through contributions from figures like Bill Joy, leading to significant legal disputes in the late 1980s and early 1990s.
- Linux, developed by Linus Torvalds in 1991, emerged directly from the expertise and interfaces established by the Unix community, effectively becoming the dominant modern iteration of the Unix model.
Core Design Philosophy and Technical Evolution
- Unix achieved efficiency and robustness partly due to constraints of early, low-memory hardware, which enforced minimal mechanisms and generalizations (e.g., "everything is a file").
- The "everything is a file" abstraction was further expanded in the Plan 9 operating system, where devices, processes, and network connections were treated as file system resources.
- Brian Kernighan distinguishes programming as a mix of art (defining the problem and user needs), science (selecting correct algorithms and data structures), and engineering (managing constraints like time and maintenance).
- Kernighan's personal coding process is highly incremental and informal, often involving small exploratory scripts written in Python or AWK rather than large, pre-designed systems.
- AWK, co-created by Kernighan, Al Aho, and Peter Weinberger in the late 1970s, remains a vital tool for text processing due to its automatic pattern-action execution and default behaviors for field splitting.
- Grep is identified as the most useful shell command, operating on a simpler pattern-matching model than AWK to quickly search text inputs for regular expressions.
Programming Language Landscape
- "The C Programming Language" (1977), co-authored by Kernighan and Dennis Ritchie, successfully popularized C and established a standard for its usage, leveraging Ritchie's clear prose and the language's portability within Unix.
- C survived and thrived by balancing expressiveness with the hardware efficiency required by computers 50 years ago, becoming the foundation for system programming.
- Go (Golang), created by Ken Thompson, Rob Pike, and Robert Griesmer, inherits the Bell Labs tradition and offers a modern concurrency model based on communicating sequential processes (Go routines).
- Kernighan views the proliferation of programming languages as beneficial, noting that while a dozen languages dominate 95% of usage, niche languages act as "playgrounds for rebels" to explore new ideas that eventually migrate to mainstream adoption.
- JavaScript is acknowledged as having evolved from an "ugly" academic outcast to a viable, efficient full-stack language, though its rapid evolution and fragmented library ecosystem pose significant maintenance and security challenges.
- The modern reliance on extensive external libraries (e.g., in Python or JavaScript) is contrasted with the early Unix era of building from scratch, with Kernighan noting increased risks regarding security, robustness, and lack of transparency in modern dependency chains.
Optimization and Modeling
- AMPL (A Mathematical Programming Language), co-designed by Kernighan, separates model specification from data and solvers, allowing users to define optimization problems algebraically while passing them to specialized solvers.
- AMPL was designed to convert human-readable algebraic models (summations over sets) into sparse matrices required by linear programming solvers, a process Kernighan implemented in C++.
- The language facilitates a separation of concerns where optimization experts can define models, data experts can manage inputs, and solver developers can provide algorithms.
Artificial Intelligence and Future Outlook
- Kernighan expresses caution regarding machine learning, highlighting the risk that AI systems will learn and propagate historical biases present in their training data (e.g., gender or racial biases).
- He suggests that while AI reveals societal biases, it is uncertain whether these mechanisms will ultimately amplify negative traits or help society correct them.
- He remains skeptical about the near-term feasibility of human-level artificial general intelligence (AGI), noting the significant challenges in defining intelligence and the limitations of current approaches.
- Concerns regarding computing's societal impact include the erosion of privacy, the rise of tribalism, and the use of technology to spread misinformation and disinformation in political systems.
- Moore's Law is expected to continue but through horizontal scaling (more processors) rather than vertical scaling (faster individual clocks) as physical limits approach atomic scales.
- The future of programming is predicted to involve higher levels of abstraction, with more logic generated by automated tools and declarative languages rather than explicit procedural coding by humans.
Education and Human Interaction
- Kernighan teaches a course for non-majors that introduces computing concepts through toy assembly languages to illustrate that high-level operations are built upon a small set of simple machine instructions.
- He advocates for general computer literacy so that non-programmers can understand how systems work, rather than requiring everyone to learn to code fluently.
- He observes that digital communication has brought family members closer together via email and text while simultaneously creating physical isolation in public spaces where individuals focus on screens.
- Kernighan recalls the "golden era" of the 1970s at Bell Labs as a particularly happy period characterized by a close-knit, cooperative environment where the feedback loop for new code was immediate and impactful.
- He concludes that while the rapid pace of technological change is often frightening, the potential for computing to improve lives globally remains a powerful, albeit mixed, force.