Programming

“Hello, world”: where it came from and what it means

The traditional first program: where "hello, world" came from, what it means, why it is still the first test of a new language, and the program in 21 languages.

"Hello, world" Way too much information

“Hello, world” is the traditional first program in a new programming language: a few lines that make the computer print those two words. It began at Bell Labs in the early 1970s, in a tutorial by Brian Kernighan, and it is still the standard first test of a new language, compiler or computer. This page covers where it came from, what it means, why programmers still write it, and the program in 21 languages, from Python to Commodore 64 BASIC and assembly.

What “hello world” means

A hello world program does one thing: it prints the words hello, world. FOLDOC, the free online dictionary of computing, calls it the “canonical, minimal, first program” in a new language or system.

The point is not the words. A program this small can hardly go wrong, so if it runs, everything around it works: the compiler or interpreter is installed, you know how to build and run a program, and you know where its output appears. Wikipedia calls it a sanity check. Once hello world runs, any later problem is in your own code, not in the set-up.

The phrase is also used outside programming for the simplest first project that proves a set-up works. In electronics, Adafruit and SparkFun both describe blinking an LED as the hello world, and TensorFlow’s tutorials call the MNIST set of handwritten digits the hello world of machine learning for computer vision.

Where it came from

1973: a tutorial for the B language

The earliest known hello world is in “A Tutorial Introduction to the Language B” by Brian Kernighan of Bell Labs. B was the language that came just before C, and the tutorial described it on Bell Labs’ Honeywell 6070 computer. It was issued in a Bell Labs technical report dated January 1973. Some sources, including Kernighan’s own 1974 reference to the report, give the year as 1972.

main( ) {
  extrn a, b, c;
  putchar(a); putchar(b); putchar(c); putchar('!*n');
}

a 'hell';
b 'o, w';
c 'orld';

In B, a character constant held at most four characters, so the words are split into ‘hell’, ‘o, w’ and ‘orld’. The last call prints an exclamation mark and a new line (*n in B is \n in C). So the first version printed hello, world!, with an exclamation mark. The example was there to teach external variables, which sit outside any function and, unlike local variables, can be given a value before the program starts.

1974: the first C version

Kernighan’s next tutorial, “Programming in C: A Tutorial”, has no date, but it is usually dated 1974 from the documents it refers to. It opens with the same idea in C:

main( ) {
	printf("hello, world");
}

1978: The C Programming Language

The program became famous through The C Programming Language by Brian Kernighan and Dennis Ritchie, published by Prentice-Hall in 1978 and known as K&R. Its section 1.1, “Getting Started”, says that the only way to learn a new language is to write programs in it, and that the first program is the same for every language: print the words hello, world.

main()
{
	printf("hello, world\n");
}

The book explains that the first hurdle is not the language but the mechanics: writing the program text, compiling it, loading it, running it and finding out where the output went. With those mastered, it says, “everything else is comparatively easy”. The 1988 second edition added #include <stdio.h> at the top and kept the rest.

In all three Bell Labs versions the words are in lower case, with a comma. Only the B version has an exclamation mark. The capitals in “Hello, World!” came later, and today’s guides spell it several ways: the Rust book uses “Hello, world!” and Oracle’s Java tutorial uses “Hello World!”.

Why those words? A chick and an egg

Kernighan does not remember exactly. Asked by Forbes India in 2011 why he chose the words, he said “Memory is dim now” and recalled a cartoon of an egg and a chick, with the chick saying “Hello, world”. He told the writer Clive Thompson the same story in 2019. Neither account names the cartoon.

The greeting was in use long before Kernighan: the New York disc jockey William B. Williams opened his WNEW radio shows with “Hello, world”. No source links him to Kernighan’s choice.

Two claims that do not hold up

  • “It started with BCPL in 1967.” The Jargon File says BCPL, the language that led to B, had the original hello world, but it gives no evidence, and the 1974 BCPL manual contains no such program. The earliest BCPL hello world that Wikipedia cites is from a 1980 book, two years after K&R.
  • “It was coined in 1978.” MIT’s computer science laboratory said so on Twitter in 2021, and the listing for Kernighan’s handwritten hello world at a 2015 auction said the same. The Bell Labs tutorials from 1973 and 1974 are earlier.

Why programmers still write it

  • It tests the set-up, not the language. If hello world runs, the tools are installed and working, and you know how to build and run a program in that language.
  • It shows the smallest complete program. Python needs one line; classic Java needs a class and a main method. Hello world shows the minimum each language asks for.
  • It is a fair comparison. Every language can do it, so it is used to compare languages and tools, and “time to hello world” is sometimes used as a measure of how quickly a beginner can get started.

Some tools now write it for you: Rust’s cargo new command creates a project whose only code prints “Hello, world!”. Java 25, released in September 2025, made Java’s version much shorter (see below).

The hello world of electronics

For microcontrollers such as the Arduino, the first program usually flashes an LED instead of printing text. Arduino’s own first example, Blink, turns the board’s built-in LED on and off every second:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

Without a microcontroller, the equivalent is lighting an LED from a battery: see make a simple LED circuit on a breadboard, then make it flash with a 555 timer.

Hello, world in 21 languages

Every example below except the two Commodore 64 ones was run on Linux on 27 October 2026, and each printed Hello, world! The Commodore 64 assembly version was assembled and checked on a 6502 emulator. The line under each example shows how to run it.

Python

print("Hello, world!")

Run it: python3 hello.py. Python 3 needs the brackets, because print became a function; old Python 2 examples without them no longer run.

JavaScript

console.log("Hello, world!");

Run it: node hello.js, or paste the line into your web browser’s developer console.

Java

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Run it: javac HelloWorld.java, then java HelloWorld. From Java 25, this shorter version also works, run with java Hello.java:

void main() {
    IO.println("Hello, world!");
}

C

#include <stdio.h>

int main(void)
{
    printf("Hello, world!\n");
    return 0;
}

Run it: gcc hello.c -o hello, then ./hello. This is K&R’s program written for today’s C standards, with int main(void) and a return value.

C++

#include <iostream>

int main()
{
    std::cout << "Hello, world!\n";
}

Run it: g++ hello.cpp -o hello, then ./hello.

Rust

fn main() {
    println!("Hello, world!");
}

Run it: rustc hello.rs, then ./hello.

Go

package main

import "fmt"

func main() {
    fmt.Println("Hello, world!")
}

Run it: go run hello.go.

Ruby

puts "Hello, world!"

Run it: ruby hello.rb.

PHP

<?php
echo "Hello, world!\n";

Run it: php hello.php.

Perl

print "Hello, world!\n";

Run it: perl hello.pl.

Lua

print("Hello, world!")

Run it: lua hello.lua.

Bash

echo "Hello, world!"

Run it: bash hello.sh, or type the line straight into a terminal.

Fortran

program hello
  print *, 'Hello, world!'
end program hello

Run it: gfortran hello.f90 -o hello, then ./hello. The output starts with a space, which is normal for print *.

COBOL

       IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO.
       PROCEDURE DIVISION.
           DISPLAY 'Hello, world!'.
           STOP RUN.

Run it: cobc -x hello.cob, then ./hello. The spaces at the start of each line matter: in traditional COBOL, code starts at column 8 or later.

Pascal

program Hello;
begin
  writeln('Hello, world!');
end.

Run it: fpc hello.pas (Free Pascal), then ./hello.

Common Lisp

(format t "Hello, world!~%")

Run it: sbcl --script hello.lisp.

Ada

with Ada.Text_IO;

procedure Hello_World is
begin
   Ada.Text_IO.Put_Line ("Hello, world!");
end Hello_World;

Run it: gnatmake hello_world.adb, then ./hello_world.

Prolog

main :- write('Hello, world!'), nl.

Run it: swipl -g main -t halt hello.pl (SWI-Prolog).

Assembly (x86-64 Linux)

section .data
    msg db "Hello, world!", 10
    len equ $ - msg

section .text
    global _start

_start:
    mov rax, 1          ; write
    mov rdi, 1          ; to standard output
    mov rsi, msg
    mov rdx, len
    syscall
    mov rax, 60         ; exit
    xor rdi, rdi
    syscall

Run it: nasm -f elf64 hello.asm, then ld hello.o -o hello and ./hello. It asks Linux directly to write the 14 bytes (the text and a new line) and then to exit.

Commodore 64 BASIC

10 PRINT "HELLO, WORLD"
20 GOTO 10

Type it in, then type RUN. Line 20 makes it print the words again and again until you press RUN/STOP; leave it out to print them once. The C64 starts up in capitals, which is why the text is upper case. The Commodore 64 User’s Guide’s first PRINT and GOTO program works the same way, with the words COMMODORE 64. You can try it in the Commodore 64 emulator.

Commodore 64 assembly

        * = $0801               ; BASIC programs start here
        .word end, 10           ; link to the next line, and line number 10
        .null $9e, "2061"       ; SYS 2061 (the token for SYS, then the address)
end     .word 0                 ; no more BASIC lines

start   ldx #0                  ; this is address 2061
loop    lda message,x           ; next character
        beq done                ; a zero byte ends the text
        jsr $ffd2               ; KERNAL CHROUT prints the character in A
        inx
        bne loop
done    rts                     ; back to BASIC

message .text "HELLO, WORLD", 13, 0

Assemble it with the free 64tass assembler: 64tass --cbm-prg -o hello.prg hello.asm. Then load hello.prg into a C64 emulator such as VICE and type RUN, or drop the file onto the screen of the Commodore 64 emulator.

The first four lines set up a one-line BASIC program, 10 SYS 2061, so the machine code loads and runs like a BASIC program; SYS 2061 then jumps to the code. The loop passes each character to CHROUT, the routine in the C64’s KERNAL ROM at $FFD2 that prints the character in the accumulator, until it reaches the zero byte at the end of the text. The 13 is a RETURN, which moves the cursor to the next line.

Questions people ask

Who wrote the first hello world program?

Brian Kernighan at Bell Labs, in a tutorial for the B language issued in January 1973 (often dated 1972). It became famous through the 1978 book The C Programming Language, which he wrote with Dennis Ritchie.

Why is it called hello world?

Kernighan does not remember for certain. He has said he recalls a cartoon of a chick hatching from an egg and saying “Hello, world”.

Is it “hello, world” or “Hello, World!”?

The C versions from 1974 and 1978 print “hello, world”: lower case, with a comma and no exclamation mark. The 1973 B version had an exclamation mark as well. Any spelling works; the program only has to print something.

Why is hello world the first program?

Because it is the smallest program that proves the whole chain works: writing the code, building it, running it and seeing the result. After that, problems are in the code you write, not in the set-up.

Sources: A Tutorial Introduction to the Language B (Brian Kernighan, on Dennis Ritchie’s Bell Labs pages); The Programming Language B (the report’s date, January 1973); Programming in C: A Tutorial (Brian Kernighan, scan); The C Programming Language (Kernighan and Ritchie, 1978 and 1988; Kernighan’s page for the book); Forbes India interview, 2011; Clive Thompson, “Hello, ‘Hello, World'”, 2019; FOLDOC: hello world; “Hello, World!” program (Wikipedia); The Jargon File: BCPL; The BCPL Programming Manual, 1974; Daring Fireball on MIT CSAIL’s 2021 post; Artsy: Kernighan’s “Hello World” at the Algorithm Auction; Radio Hall of Fame: William B. Williams; Adafruit: Arduino blink; SparkFun: Blink an LED; TensorFlow: basic classification; Arduino: Blink; The Rust book: Hello, Cargo!; JetBrains on Java 25; PEP 3105: print as a function; Commodore 64 User’s Guide, chapter 3; C64-Wiki: CHROUT; 64tass. The examples were run with Python 3.13, Node.js 22, OpenJDK 21 and 25, GCC 13 (C, C++, Fortran and Ada), Rust 1.97, Go 1.24, Ruby 3.3, PHP 8.3, Perl 5.38, Lua 5.4, Bash 5.2, GnuCOBOL 3.1, Free Pascal 3.2, SBCL 2.2, SWI-Prolog 9.0 and NASM 2.16; the Commodore 64 assembly was assembled with 64tass 1.59 and checked on the py65 6502 emulator.

Get new Braindumps guides by email

One email a week with new guides, the best free 3D prints, LEGO news and tools. Unsubscribe at any time.

No spam. Read our privacy policy.