'C' Programming Language - Brian Kernighan - Computerphile

The Book on UNIX: A Reflection on the Evolution of High-Level Programming Languages

As I gaze at the book sitting beside me, I am reminded of the importance of documentation and sharing knowledge with others. The book, now on its 24th printing, is a testament to the power of high-level programming languages in making complex concepts more accessible to developers.

The UNIX operating system was born out of the collaboration between researchers at MIT, Bell Labs, and General Electric. The project aimed to create a computing utility for programmers that would provide a reliable and efficient platform for developing software. The work on MULTICS, an earlier timesharing system, laid the groundwork for UNIX. Ken Thompson and Dennis Ritchie, two pioneers in the field of high-level programming languages, played a crucial role in shaping the UNIX operating system.

Thompson's contribution to B, a language that served as the precursor to C, was instrumental in developing a high-level language that could efficiently run on various architectures. However, B had its limitations, and Ritchie set out to create a better language that would overcome these challenges. He designed a version of B that supported different data types, including char and int, which became the foundation for C. With this compiler, they rewrote the UNIX operating system in high-level languages, paving the way for a more portable and efficient platform.

The concept of using high-level languages to write software is not new, but the idea of compiling it down to machine code that can be executed by processors is still a fundamental aspect of programming. The challenge lies in translating this process into multiple architectures, which requires a deep understanding of the underlying system. Ritchie's experience with bootstrapping the C compiler from C code to generate a working program serves as a metaphor for the complexity involved in writing an operating system.

The UNIX book, written by Prof. Brailsford and Dennis Ritchie, is a culmination of their efforts to explain high-level programming languages to others. The book takes its cue from Thompson's tutorial document on B, which was essential for learning the language. With Ritchie's reference manual as a cornerstone, they expanded on the material to provide a comprehensive guide to C. The publication process involved using various document preparation tools, including mathematical expressions and tables, which added depth to the book.

The UNIX operating system has come a long way since its inception in 1977. From its early days to the present, it has been influenced by other languages and technologies, such as Yacc, created by Steve Johnson. The collaboration between researchers and developers has led to the development of powerful tools and programming languages that continue to shape the industry.

The UNIX book is more than just a collection of knowledge; it represents a legacy of innovation and sharing among developers. By documenting their experiences and ideas, Prof. Brailsford and Dennis Ritchie have created a resource that continues to inspire new generations of programmers. As I reflect on the evolution of high-level programming languages, I am reminded of the importance of collaboration, documentation, and sharing knowledge with others.

"WEBVTTKind: captionsLanguage: enThere's a book just over your shoulder that's carefully been placed there, can you pick the book up and tell me about it? Right! Great book, you shouldbuy the newer version of this.Brief commercial announcement yeah sure I think I mentioned at some point in ourconversation the fact that the peopleworking on MULTICS, well MULTICS was sort of thesecond version of timesharing that wasdone at MIT with collaboration of BellLabs and General Electric very bigsystem for providing in effect a computingutility for programmers.Multex was actually being written in high-level languages ah they started with PL1which was not a good choice and thenthey moved to BCPLlanguage which developed in fact byMartin Richards of Cambridge.The people doing that who are at Bell Labs inparticular Ken Thompson and DennisRitchie had gotten used to the idea thatyou could write really interestingoperating system kind of software andtools that supported it in high-levellanguages so you weren't writingassembly language and so when theystarted working on UNIX this very smallstripped-down version that was done atBell Labs they were at the same timeexploring the use of high-levellanguages and there were a variety ofthese there was a language called Bwhich was the first attempt it was doneby Ken Thompson a very simple languageand I suppose you could say it was sortof like a stripped down version of BCPLA weak naming convention there andso you could do interesting things withB but it wasn't quite powerful enoughand in particular it was an interpreternot a compiler and that meant it didn'tgenerate machine code for the particularmachine was running on it was just aprogram thatinterpreted what it was trying to sayso it meant it ran relatively slowly.The other thing is that the language did not support the architecture of newermachines that were showing up inparticular that PDP 11 newer machinesinstead of having everything in themachine be a single size of in effect integerlet's say 16 bits or something like that they had different sizes that were, themachine would efficiently and naturallymanipulate 8bit, 16bit maybe thirtytwo-bit & the language B didn't reflectthat and so Dennis Ritchie undertookto design what amounted to a version ofB that was richer and had mechanismsin the language to say this is an 8-bitquantity this is a 16 bit quantitybasically the char and int types that you see in the early versions of C and so hewrotea compiler for that and then with thecompiler in hand they started to rewritethe operating system itself in Cand this took a while but something in theorder of six months to get that workingand at that point then you've got theoperating system of course all kinds ofother critical core software written ina high-level language rather than inassembly language and that's importantfor all kinds of reasons one is meansthat it's just a lot easier for lots ofpeople to see what the code does youneed so much expertise because it's ahigh-level language and the other thingis that it's portable in the sense thatif somebody makes a C compiler for adifferent kind of machine differentarchitecture then you can recompilewhatever your program is for that newarchitecture inthat way you can move your program to adifferent machine of this always beenthe advantage of high-level languagesbut now you could do it for the operatingsystem and that meant that UNIX, theoperating system no longer was only PDP11 but could run on a variety of othermachines as wellI think the concept of having a high-level language Iget right, you compile it down to hexes, machine code that tells the processors to do stuff. and if you have a different compiler for a different machineit just changes what those Hexes are -right that's exactly rightso so it should be really simple to understand how you write an OS in a high level language, but is it a bit like, making a sharp tool and using that sharp tool to make a sharper tool?Yeah, right, I think in fact, the complication is in building in writingof operating system and high-levellanguage in translating it into let'ssay multiple different architectures isthere's a lot of detail to get rightthere in there are some things which thehigh-level language just doesn't supportSo you need a little tiny bit of assemblylanguage assist for any given operatingsystem the one that's more like that theconceptual problem that you wereexplaining well is how does the compileritself get started because of course theC compiler is written in C so there is thehow do you get it started and your ideaof the sharper tool making yet a sharpertool and so onis metaphorically the right idea becausewhat you do is you say I wrote some codein C on paper let me mechanicallytranslate that into something that willprocess a bit more of C code andbootstrap myself up from that so it's abootstrapping process and I've neverdone it so take me with a grain of salton that but that's the basic idea so. - OK, so tell me about this book, how did this come about?that's the first edition (is it autographed?) this one isn't actually no dear oh dear this however isthe 24th printing so. (I'll just point out that Prof Brailsford brought in a pen for the autograph there.) OK I will autograph it...somewhere early on in this process ofpeople building interesting languages Igot intrigued by the idea of how do youexplain those languages to other peopleand so I wrote tutorial documents I wrote a tutorial document on B so thatpeople could learn B because Ken Thompsonand to a lesser degree Dennis didn'twrite tremendous amount of documentationlet's say it was a spare and there wasnot much tutorial stuff so I wrote atutorial document on B that was usefulwhen C came along then I wrote atutorial document on C and at some pointI had already written I guess couplebooks at that point and it seemed likethe market, the market!? That there mightbe a market for a C book and so Itwisted Dennis Ritchies arm intowriting the book with me and that is thesmartest thing I ever did in my wholelife no ambiguity so we took my tutorialdocument as kind of a piece of it, wetook his reference manual which is aexcellent reference manual as a bigpiece of it took that verbatim and thenwe filled in material in the middle to explain the various parts of the language at length, and wepublished that, we wrote it in 1977published at the beginning of 78 and ofcourse it was done with all of thedocument preparation tools that we hadbeen working on over the years and so ithadmathematical expressions in it using EQNit had tables of things likeoperators using Mike Lesk's TBL programitthe first edition predates pic thepicture drawing language the secondedition has pic pictures so on so isthis incestuous or is this building onwhat people have done I don't know butthat's how it came about and I remembertalking to the editor this is publishedby Prentice Hall with Karl Karlstrom theeditor there and I remember discussionwith him about how many copies do youthink this will sell no idea well maybefive thousanddone better than that which is just as wellthere never an A because B was based on? There was a language SteveJohnson who was all part of this thecreator of Yacc, Steve Johnson spent a sabbaticalat University of Waterloo in Ontario andhe came back with a link I don'tsomebody else had done that the languagethey're called \"A\" but it was spelled \"EH\"- Bit of Canadian humor I guess...\n"