Hello World: The Universal First Program

Hello World: The Universal First Program

Verified Sources
Jul 12, 2026

The "Hello, World!" program is the most universally recognized computer program in history. It is typically the first program a student writes when learning a new programming language — a simple piece of code that outputs the message "Hello, World!" to the screen. Beyond its trivial function, it serves as a foundational pedagogical tool across computer science education and a cultural touchstone that unites programmers worldwide .

The tradition is widely attributed to Brian Kernighan, a computer scientist at Bell Labs, who first used the phrase in a 1972 tutorial for the B programming language and later popularized it in the 1978 book The C Programming Language, co-authored with Dennis Ritchie . The original program printed hello, world — with no capitalization and no exclamation mark .

Kernighan has recalled that the phrase was partly inspired by a cartoon of a chick hatching from an egg and saying Hello, World, though he also noted its practical utility as a quick sanity check for any new programming environment .

Why "Hello, World" Matters

The significance of this program extends far beyond its simplicity:

  1. Syntax Illustration — It introduces the basic structure of a language: entry points, function calls, string literals, and output mechanisms.
  2. Environment Sanity Check — It verifies that compilers, interpreters, and toolchains are correctly installed and configured .
  3. Pedagogical Gateway — It gives beginners an immediate, satisfying result — a psychological "first win" that encourages further learning.
  4. Cultural Ritual — "Hello, World" has become a shared experience across the global programming community, transcending language barriers .

Key terms in this section:

  • Toolchain
  • Syntax
  • Compiler

Footnotes

  1. Wikipedia: "Hello, world" — Overview of the Hello World program, its purpose, and historical context. 2

  2. HackerRank Blog: "The History of 'Hello, World'" — Ritika Trikha's account of the origins and cultural impact of Hello World.

  3. CodeInterview Blog: "The History of Hello World: A Brief Overview" — Detailed history including BCPL origins, Kernighan's B tutorial, and the C Programming Language book.

  4. Slate: "Why the first code a programmer writes is 'Hello, World'" — Article on Hello World as part of the cultural canon in software development, including Kernighan's interview.

  5. The Software Guild Blog: "The History of Hello World" — Discussion of Hello World as a pedagogical tool and toolchain verification method.

Hello World: The First Program Explained

The History of Hello World

BCPL Origins

1967

The Jargon File reports that a 'hello, world!' test message may have first appeared in the BCPL programming language, though this claim lacks formal attribution ."

Footnotes

  1. CodeInterview Blog: "The History of Hello World: A Brief Overview" — Detailed history including BCPL origins, Kernighan's B tutorial, and the C Programming Language book.

B Language Tutorial

1972

Brian Kernighan writes 'A Tutorial Introduction to the Language B' at Bell Labs, containing the first known published version of a Hello World-style program using external variables ."

Footnotes

  1. HackerRank Blog: "The History of 'Hello, World'" — Ritika Trikha's account of the origins and cultural impact of Hello World.

Programming in C: A Tutorial

1974

Kernighan's internal Bell Labs memorandum includes the first known C-language version: main( ) { printf("hello, world"); } ."

Footnotes

  1. CodeInterview Blog: "The History of Hello World: A Brief Overview" — Detailed history including BCPL origins, Kernighan's B tutorial, and the C Programming Language book.

The C Programming Language

1978

The landmark book by Brian Kernighan and Dennis Ritchie popularizes the Hello World program globally, cementing it as a tradition for all future programming instruction ."

Footnotes

  1. HackerRank Blog: "The History of 'Hello, World'" — Ritika Trikha's account of the origins and cultural impact of Hello World.

Universal Tradition

2000s–Present

Hello World becomes the standard first program in virtually every programming language tutorial, from Python and Java to Rust and Swift ."

Footnotes

  1. The Software Guild Blog: "The History of Hello World" — Discussion of Hello World as a pedagogical tool and toolchain verification method.

Analyzing What Hello World Teaches

Though deceptively simple, the "Hello, World!" program reveals critical structural information about a language's paradigm and syntax conventions. Here is what each language's version exposes:

LanguageLinesKey Concepts Revealed
Python1No required boilerplate; interpreted; function calls as statements
JavaScript1Console-based output; dynamic scripting environment
Java5Mandatory class structure; public static void main entry point; package-oriented
C5Preprocessor directives (#include); explicit main() function; return codes
C++5Namespaces (std); stream insertion operator (<<); header inclusion
Go5Package declaration; explicit imports; func keyword
Rust3Macros (println!); fn declaration; no semicolons on macro calls

The number of lines and the amount of boilerplate directly correlate with the language's complexity and design philosophy. For example, Java's requirement that all code reside inside a class makes even the simplest program verbose, while Python's interpreted nature allows a single function call .

Footnotes

  1. Medium: "Hello, World! in 20 Different Programming Languages" — Collection of Hello World implementations across 20 languages with syntax comparisons.

Hello World: Lines of Code by Language

Comparison of the minimum number of lines required to print 'Hello, World!' across popular languages

Writing Your First Hello World: A Beginner's Walkthrough

  1. 1
    Step 1

    Select a programming language to start with. Python and JavaScript are the most beginner-friendly due to minimal setup and one-line syntax. Consult a language's official documentation or an online IDE like Replit to get started .

    Footnotes

    1. Medium: "Hello, World! in 20 Different Programming Languages" — Collection of Hello World implementations across 20 languages with syntax comparisons.

  2. 2
    Step 2

    Install the language interpreter or compiler on your system, or use a cloud-based IDE. For Python, install from python.org. For JavaScript, any modern browser console suffices. For compiled languages like C or Java, install the respective compiler (GCC, JDK).

  3. 3
    Step 3

    Create a new source file with the appropriate extension (e.g., .py for Python, .c for C, .js for JavaScript). Type the Hello World code for your chosen language. For Python, simply write: print("Hello, World!").

  4. 4
    Step 4

    Execute the program using your environment's run command. For interpreted languages, run the file directly (e.g., python hello.py). For compiled languages, first compile (gcc hello.c -o hello), then run the binary (./hello). If you see 'Hello, World!' displayed, your toolchain is correctly configured .

    Footnotes

    1. Wikipedia: "Hello, world" — Overview of the Hello World program, its purpose, and historical context.

  5. 5
    Step 5

    Modify the output string, add variables, or try printing multiple lines. This builds intuition for string literals, escape characters (like \ for newline), and function parameters — all fundamental concepts unlocked through the simple act of saying hello.

Hello World: Trivia & Edge Cases

Pro Tip: Hello World as a Diagnostic Tool

Beyond being a learning exercise, experienced developers use Hello World when setting up new machines, CI/CD pipelines, or Docker containers. If Hello World runs correctly, your entire toolchain — compiler, runtime, environment variables, and output routing — is verified. It's the fastest possible end-to-end system test.

Common Pitfall: Punctuation and Encoding

When writing Hello World in compiled languages like C, forgetting the newline character (\ ) or mismatching quotes will cause compile errors or unexpected output. Always verify your string literals are enclosed in the correct quotation marks for your language (single quotes in some, double in others) and that special characters are properly escaped.

Hello World Essential Knowledge

1 / 5
Question · Term

Who is credited with creating the first 'Hello, World!' program?

Click to reveal
Answer · Definition

Brian Kernighan, a computer scientist at Bell Labs. He first used the phrase in a 1972 tutorial for the B language and later in the 1978 book The C Programming Language with Dennis Ritchie.

Knowledge Check

Question 1 of 5
Q1Single choice

Who is credited with originating the 'Hello, World!' program tradition?