7 works · 1 room
hello, world in seven languages
Seven programs that print the same twelve characters, and no two of them agree about what a program is.
That is the whole of the Hall of First Words, and it is a better exhibition than it sounds, because the output is held fixed. Normally when you compare two languages you are comparing two different programs solving the same problem, and most of what you notice is the programmer. Here there is nothing to solve. Every one of these produces hello, world and stops. Whatever differs between them is therefore not craft, not cleverness and not the problem domain — it is the language, standing exposed, with nothing to hide behind.
What differs turns out to be one thing, asked seven ways: how much of the machine does this language insist you acknowledge before it will say anything at all? The answers run from *nothing* to *everything*, and the order below walks that scale from the middle out to both ends.
A word on the phrase itself. It is Brian Kernighan's, from a 1972 tutorial for the language B, and it reappeared in *The C Programming Language* in 1978 in the form that made it universal. The original is lowercase, with a comma and no exclamation mark. The shouted Hello, World! that everyone remembers is a mutation spread by tutorials copying each other rather than the source, and the museum shows the quiet version throughout.
Walking it takes you into the rooms, one work at a time. Everything below is the same tour, read here.
Hall of First Words
hello, world in CC · 1978
Start at the version everybody means when they say the phrase, and count what a beginner is handed in the first five minutes.
There is a preprocessor directive, a return type, a parameter list that means *no arguments* rather than *unspecified*, a newline written as an escape, and an exit status. Not one of those is about greeting anybody. Every one is a real concept the language will insist on later, arranged here as a kind of table of contents.
This is the middle of the scale, and it is worth naming why. C asks you to acknowledge that a program is a function the operating system calls, that it returns a number, and that printing is something a library does rather than something the language does. Three facts about the machine, stated before you are allowed to speak. Everything that follows either removes some of those or adds more.
hello, world in PythonPython · 1991
The same idea with all three of those facts withdrawn.
There is no entry point, because a Python file *is* the program. There is no return value, because nothing is asking for one. There is no include, because
printis simply there. What remains is the sentence you wanted to write in the first place, which is precisely what the language was designed to leave you with.The parentheses have a history worth pausing on. For most of Python's life this was
print "hello, world"— a statement rather than a function call — and turning it into a function was among the changes that split the language into Python 2 and Python 3 for the better part of a decade. Of all the incompatibilities in that migration it was the smallest and by far the most visible, because it broke the first line of every tutorial ever written. Two characters, and they date you.hello, world in LuaLua · 1993
Shorter still, and for a reason that has nothing to do with wanting to be short.
Lua drops even the parentheses, and the note beside it explains what that economy is really about: the language was built to be embedded inside other programs, so the entire implementation had to stay small enough to carry around. One data structure serves as array, dictionary and object. There are a handful of types and no classes at all. The reference implementation is about thirty thousand lines of very plain C and fits in the corner of a game engine, a router or a database.
So the brevity here is a consequence rather than a goal, which is the more interesting kind. Standing between this and the Python you are looking at two programs that are nearly character-for-character identical, written in languages that could hardly be less alike — and at this size, the design of a language is very nearly invisible. Everything that separates them begins on line two.
hello, world in RustRust · 2010
Three lines, and the interesting character is the exclamation mark.
println!is not a function. The!marks a macro, and it is a macro rather than a function because Rust checks format strings at compile time: give it a placeholder with no argument to fill it and the program does not build. A function could not do that, because by the time an ordinary function runs the format string is only a string.This is why Rust belongs here rather than beside the Lua, despite being nearly as short. The line is doing work you cannot see — the same length as a greeting, with a compile-time check hidden inside the punctuation. And note what is absent from a language famous for difficulty: no lifetimes, no borrows, no
unsafe, no types written down at all. The machinery is machinery you meet when you need it.hello, world in COBOLCOBOL · 1959
Now the other end of the scale. Ten lines to print twelve characters, eight of them the program explaining who it is before it is permitted to do anything.
The four divisions are not ceremony for its own sake, and reading them as bureaucracy misses what happened. COBOL was designed in 1959 to be read by people who had not written it — auditors, managers, the next programmer — and the divisions are a filing system: who I am, what machine I expect, what data I touch, what I do. Two are empty here and are still written out, because the shape is the point.
Set this beside the Lua and the comparison stops being about verbosity. One language decided the reader was another program, and made itself small enough to fit inside one. The other decided the reader was a human being who would arrive years later without context, and made itself say so out loud. Both were right about their reader. Only one of them is still running the world's payrolls.
hello, world in x86-64 assemblyx86-64 assembly · 2003
The floor. The only greeting in the hall with no library underneath it at all.
The C version's single line of output is several thousand instructions of libc once you follow it down. Here there is no
printf, no runtime, nomain— the fourmovinstructions before eachsyscallare a form being filled in, because the kernel reads its arguments from named registers, always the same ones in the same order. Loading them calls nothing. It arranges the machine so that one instruction can hand over control and find everything where the kernel will look.This is the scale's far end: a language that insists you acknowledge everything, because it is not really a language so much as a transcription of what the processor was going to do anyway. Every other program in this hall is this program, with more and more of it hidden. That is not a criticism of the others. It is what all of computing has been doing since 1954, and the hall is a picture of how far it has got.
hello, world in BrainfuckBrainfuck · 1993
And then the one that is not on the scale at all, because it refuses the premise.
Eight instructions — move left, move right, add one, subtract one, read a byte, write a byte, and brackets that loop while the current cell is not zero. That is the entire language, and it is Turing complete. Nothing in the program mentions a letter. The opening run is arithmetic that counts eight down to zero while adding thirteen to one cell and four to the next: eight thirteens is 104, which is
h.So the program keeps two fingers in the ASCII table, one among the lowercase letters and one down in the punctuation, and hops between them.
---walkshback toe. Read that way it is not spelling a message at all — it is a route, and the message is the order in which it visits the letters.End here, because it puts the question the hall has been asking in its sharpest form. Six of these programs differ in how much machine they make you acknowledge. This one asks whether a language needs to contain any human concept whatsoever in order to be a language, and answers no, and then prints
hello, worldanyway.