This video is a brilliant piece of digital archaeology that celebrates the minimalist elegance of computing's foundations. It serves as a humbling reminder that the most influential tools are often born from the simplest constraints.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Original Hello World in "B" Programming Language - ComputerphileAdded:
C is one of the best known uh programming languages probably became famous due to Unix. But B is sort of an obscure historic detail that people don't really know about and that is because the compiler has probably been lost as least that doesn't seem to be around anymore. Um, so, uh, I wanted to play with this language, um, because the first hello world program was written in B in Brian Kernian's tutorial on the B language and I was very frustrated that the that there was no way to execute B code. So, yeah, I fixed that.
>> Was there an A?
>> There was no A. No, B was actually uh probably called B because it was a simplified version of BCPL, which was an earlier language. Um, and somebody u maybe Dennis Richie uh said that B was like BCPL filtered through Ken Thompson's brain. Um, and also it had to run on a PDP7 at the time, which was a very small machine and it was very constrained. Um, but this is about the PDP11 version that I uh wrote, but it's actually fairly um portable language.
So, it it runs on a number of systems.
Um um and we're going to see a little bit of that. So, let's just boot uh the PDP11 first in this emulator here. Uh this is version 4 Unix, which uh was found uh just last year, so 2025.
and it's been read and uh I got it to boot and uh I made B run on it. So we boot from the arcade disc and type the kernel name Unix and I will log in as myself and here we are. Let's see. I have some files here and hello B is a little hello world program that I wrote. Unfortunately, not the same as Brian Kernian's tutorial hello world program because that was written for an for a different machine that had a different word length and um unfortunately it was dependent on that.
So I I wrote my own version but to just highlight uh how B is different from C uh I wrote this put string function here so we can see the differences a little bit. This looks just like early C main put string and a string. we have the asterisk for for an escape character in B still um but that's just cosmetics.
One interesting feature of B is that it only has a single data type just the machine word and that is the only machine dependent part of the language really everything else is really portable because it's uh compiled to a to an interpreted code or a threaded code which people may be familiar from the fourth programming language. Um uh and the reason was is that the compiler is very short uh because it had to fit into a small memory uh amount of memory and it just couldn't be very intelligent and just generating this uh this code for a stack machine uh was the was the reasonable thing to do and that also makes it very portable. If we start here, uh, auto people know this from C++ nowadays because they repurposed the keyword, but originally it came from B and it just declares variables on the stack uh, automatic variables. There's no int, no car, uh, no pointers because we just have memory uh, we just have machine words to work with. We just declare two two variables I and C. I is our counter that goes through the string and C is the character that we want to print out. You will notice that I have used the while loop because B didn't have four yet. So we have to use while and because there is no uh character or byte data type uh in B there is actually a function called car which extracts one character out of a string. So it's just the the base address of the string and the index like just goes character by character. So we get that uh compare against the uh end of a string marker and uh until that is the case we just uh print the character on screen. So to see that in action uh let's call the b command and give it hello. This is just a shell script actually calls two programs and now we get an a out uh executable and there we go hello world.
a little bit about the implementation uh how this works the threaded code uh it's two programs actually the B compiler which takes uh B source code and produces an intermediate code that intermediate code is an invention by me because I don't know the format of the original intermediate code there was intermediate code but I don't know exactly what it was >> you need to be in Ken Thompson's brain for that >> yeah uh I I did ask Ken about it but the details he didn't remember So uh this is what the intermediate code looks like.
And if we now run the assembler the B assembler on it hello, hello. S uh that now produces something that can be assembled by the Unix assembler. So this is what it what the program comes out to be. And you will notice that this is not machine code. this one is, but most of it is just the the threaded code that the compiler generates and it's doing just a very straightforward thing. And yeah, there you can see the way that B used to work on the PDP11. The compiler does generate the original code from the binaries that have survived. So there are a few B binaries. uh we have a standard library in B and the the threaded code implementation but no compiler no large amounts of source code. Um so the biggest uh that that we probably have is I hope I have this here. Yep. Is probably the the B compiler itself. So you can see D uh this is what B looks like. It's based on the earliest C compiler that has survived and it's kind of morphed backwards in time again to to generate B code and so on. I'm going to >> So what do you do there? You take that early C compiler and you go right okay let me go through that and edit it so it works with B or >> it's not I didn't really edit it. It was more for inspiration like I took the structure variable names like where it made sense to retain it. The compiler is set up is constructed a bit differently from the C compiler, but you can still see that it used to be a B compiler. So you can see that uh the B compiler is just isn't even a thousand lines of code of B and the B assembler is even shorter. So yeah, you can write a compiler in in like about thousand lines of B code that compiles itself.
>> Yeah. And did and did you do that from looking at B programs that you had code for? Um yeah so the the things that were left over that that had survived were um yeah like object code that you would link into B programs like for instance print f and print n they are in the standard library um and that had survived and there was source code for those functions in the documentation so you kind of can match what the original source code should generate and yeah that way I was able to uh reason my way through how the compiler must have worked and yeah again it produces the original code for all the code I've tried on it and one of the uh early bigger B programs uh was yak the compiler compiler uh yet another compiler compiler from Steve Johnson uh that early B version has not survived uh there is some early C code but um yeah so yeah that's uh that's kind of what I can say about B >> and are the are some of this stuff on GitHub could people go and have look at it and play with it. And >> yes, I actually have a a guide for uh how to install it on these old Unix machines. It's a bit chaotic right now still. Uh I have a bunch of ports uh to like to risk five even to MIPS and uh x86 uh PDP11 PDP 10 even on its uh so it is portable and it it yeah it's a it's a very fun tiny language. you can write a compiler probably in something like a or any simple language uh like it's a fun project you can do uh and yeah it's a very sweet short language we're a loosely organized group of computer hobbyists we kind of met each other at vintage computer festivals and all of us were sucked into the rabbit hole of pre micro microprocessor computing And we consider themselves them them not to be um replicas but more like
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 viewsβ’2026-05-28
How agent o11y differs from traditional o11y β Phil Hetzel, Braintrust
aiDotEngineer
450 viewsβ’2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanationπ―β
LearnwithSahera
1K viewsβ’2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 viewsβ’2026-05-29
Search Algorithms Explained in 60 Seconds! π€π¨
samarthtuliofficial
218 viewsβ’2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 viewsβ’2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 viewsβ’2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 viewsβ’2026-06-01











