Home / Definitions / Hello World

Hello World is a simple program that displays the message “Hello, World!” on a screen. It’s usually the first program people write when learning a new programming language, because it shows the language’s most basic syntax and proves the setup works. In Python, the whole program is a single line: print(“Hello, World!”).

The tradition started at Bell Labs in the early 1970s and has outlived almost every machine it was first written for. Below, we explain what the phrase means, what a Hello World program actually tests, how to write and run your first one, where it came from, and what it looks like in 25 programming languages.

What Does “Hello, World!” Mean?

Literally, it’s a new program greeting the world. The message has no technical meaning. It’s a convention, and a deliberately friendly one: the first output of a new program is its first sign of life, so a greeting fits.

The exact wording has drifted over the years. The original examples from Bell Labs used lowercase “hello, world” with no exclamation mark. Most tutorials now print “Hello, World!”, and plenty drop the comma. None of these differences matter to the computer, because the program just prints whatever text it’s given.

Developers also use “hello world” as shorthand for the simplest working version of anything. A “hello world app” is a bare-bones app that runs but does almost nothing, and a “hello world” for a new API or tool is the smallest request that returns a result. In both cases, the point is the same: confirm that the basics work before building anything real.

What a Hello World Program Actually Tests

Printing one line of text looks trivial, but a Hello World program quietly checks every link in the chain between writing code and seeing it run. If the message appears, each of these steps worked:

  • The file itself: You’ve written source code in a plain-text editor and saved it with the right file extension, such as .py for Python or .c for C.
  • The toolchain: The language’s tools are installed, and your system can find them. A “command not found” error at this stage usually means the tool isn’t installed or isn’t on your system’s PATH.
  • The syntax: A compiler or interpreter has read your code and accepted it. A missing quote, bracket, or semicolon fails here with a syntax error.
  • The libraries: The code that actually handles printing, such as C’s standard input/output library, has been found and linked in. In compiled languages, a broken setup often shows up as a linker error at this step.
  • The runtime: The operating system has loaded the program and run it. Problems here appear as a runtime error or a crash rather than a message about your code.
  • The output: The program has written text to the standard output stream, and your terminal or console has displayed it.

This is why experienced developers still write Hello World on a new machine or with a new tool. When something breaks later in a bigger project, you already know the foundation is sound, and the error message tells you which link failed.

How to Write and Run Your First Hello World Program

Python is the easiest place to start because the program is a single line and there’s nothing to compile. These steps work on Windows, macOS, and Linux:

  1. Install Python: Download it from the official Python website. On Windows, tick the option to add Python to your PATH during installation.
  2. Check the installation: Open a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS) and type python –version. On macOS and Linux, you may need python3 –version. A version number means it’s ready.
  3. Create the file: Open any plain-text editor, such as Notepad, TextEdit in plain-text mode, or a code editor like VS Code, and type print(“Hello, World!”).
  4. Save it: Save the file as hello.py somewhere easy to find, such as your desktop.
  5. Go to the folder: In the terminal, use cd to move to that folder, for example, cd Desktop.
  6. Run it: Type python hello.py (or python3 hello.py) and press Enter. “Hello, World!” appears on the next line.

Compiled languages add one step. In C, for example, you save the code as hello.c, compile it with a command such as gcc hello.c -o hello, and then run the resulting program with ./hello. If you’d rather not install anything, open your web browser’s developer console (F12 in most browsers), type console.log(“Hello, World!”) and press Enter. That’s a working JavaScript Hello World.

What Is Hello World Used For?

Hello World has a handful of practical jobs beyond being a beginner’s first program.

Learning a New Programming Language

It’s the standard first lesson in almost every programming language tutorial and textbook. In a few lines, it shows how a language structures a program, where code starts running, how it handles text, and how it produces output. Experienced programmers use it the same way when picking up a second or third language: it’s a quick way to see how much ceremony a language needs before it does anything.

Sanity Testing a Development Environment

A sanity test is a quick check that something basic works before you rely on it. Running Hello World after setting up a new computer, installing a compiler, or configuring a code editor confirms that the tools are installed, connected, and able to build and run code. If Hello World fails, there’s no point testing anything more complex yet.

Proof of Concept

Before committing to a new platform, framework, or device, developers often build a Hello World version first. It proves that code can be written, deployed, and run in that environment at all, which surfaces configuration and compatibility problems early, when they’re still cheap to fix.

Debugging and Checking Changes

When code changes don’t seem to take effect, a simple printed message is a fast way to check what’s going on. Adding a Hello World style line confirms that the program is actually being rebuilt and reloaded, and that execution reaches the part of the code you expect. It’s one of the most basic debugging techniques, and still one of the most used.

Comparing Languages and Toolchains

Because every language can produce the same output, Hello World makes a fair, if rough, basis for comparison. Developers use it to compare how much code each language needs, how large the compiled program is, and how much supporting software is required to run it. A Hello World written in C or machine language can be tiny, while the same output from a language that runs on a large runtime or virtual machine pulls in far more behind the scenes.

History of Hello World

Small test programs existed long before “Hello, World!”, but the phrase itself traces back to Brian Kernighan at Bell Labs.

The earliest known version appears in Kernighan’s internal guide, A Tutorial Introduction to the Language B, written around 1972. B was the predecessor of C and could only store a few characters in each variable, so the example splits the message into pieces: one variable holds “hell”, another “o, w,” and a third “orld”, and the program prints them in sequence. Kernighan then reused the greeting in his 1974 memo, Programming in C: A Tutorial, where a single printf(“hello, world”); line did the job.

The example reached a mass audience in 1978, when Kernighan and Dennis Ritchie published The C Programming Language. Hello World is the book’s first program, and the book became the standard way programmers learned C. As C and the Unix operating system spread from Bell Labs to universities and companies, much of it running on Digital Equipment Corporation’s PDP-11 minicomputer, the habit of starting with Hello World spread with them.

Brian Kernighan's handwritten hello, world program in C
Brian Kernighan’s handwritten ‘hello, world’ program in C.

As for why he chose those words, Kernighan has said his memory is dim. In an interview with Forbes India, he recalled seeing a cartoon of a chick hatching from an egg and saying “Hello, World”, which may have planted the idea.

Later language designers adopted the convention almost without exception. Today practically every language’s official tutorial opens with it, and enthusiasts maintain collections of Hello World programs covering hundreds of languages, from mainstream ones like Python to deliberately obscure joke languages.

Time to Hello World (TTHW)

Time to Hello World is the time it takes a newcomer to go from nothing to a working Hello World program in a given language or tool. It’s an informal measure of how approachable something is. A short TTHW means less setup, less boilerplate, and fewer chances to get stuck before seeing a result.

The idea is easiest to see in the code itself. Python needs one line. A traditional Java Hello World needs a class, a main method with a specific signature and a print statement, so a beginner meets several concepts at once before anything appears on screen. Language designers have noticed: C# added top-level statements in 2020 so a program can be a single line, and recent Java releases have reduced the boilerplate needed for simple programs.

The concept has also spread well beyond programming languages. Companies that sell APIs, software development kits (SDKs) and developer platforms track TTHW as a developer experience metric, measuring how quickly a new user can sign up, authenticate and make a first successful request. A long TTHW is a common reason developers abandon a tool before they’ve seen what it can do.

Hello World Beyond Programming Languages

The Hello World idea now applies to almost any technology where you need to prove the basics work.

  • Containers: Docker ships an official hello-world image. Running docker run hello-world prints a message confirming the installation works and explaining the steps Docker just took: contacting the Docker service, downloading the image, creating a container and streaming its output to your terminal.
  • Hardware and electronics: Microcontrollers often have no screen to print to, so the equivalent first program blinks an LED on and off. On Arduino boards, the built-in “Blink” example plays exactly this role.
  • Web frameworks and servers: The first step with a new software framework is usually a page or endpoint that returns “Hello, World!” in the browser, which confirms that routing, the server, and the response all work.
  • APIs and cloud services: A Hello World for an API is the simplest authenticated request that returns a result, and cloud platforms commonly use a Hello World function as their first deployment tutorial.
  • Databases: Running a query such as SELECT ‘Hello, World!’; in SQL confirms that a database connection works before any real data is involved.

The examples below show Hello World in 25 languages, starting with the most widely used today. Notice how the amount of code changes. Scripting languages like Python, Ruby, and Bash usually need a single statement, because they run code from top to bottom with no setup. Languages built for larger applications or tighter control over the machine, such as Java, C, and assembly, require more structure to achieve the same output. As a rule, the closer a language sits to the hardware, the more code Hello World takes.

Python

The shortest mainstream Hello World and the reason Python is a common first language.

print(“Hello, World!”)

JavaScript

Runs in any web browser’s console or in Node.js.

console.log(“Hello, World!”);

Java

The classic form, with the class and main method every Java program traditionally needs.

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

C

A modern version of the program from Kernighan and Ritchie’s book.

#include <stdio.h>

int main(void) {
printf(“Hello, World!n”);
return 0;
}

C++

Uses the iostream library instead of C’s printf.

#include <iostream>

int main() {
std::cout << “Hello, World!” << std::endl;
return 0;
}

C#

The traditional form is below. Since C# 9, the single-line Console.WriteLine(“Hello, World!”); also works on its own.

using System;

class Program {
static void Main() {
Console.WriteLine(“Hello, World!”);
}
}

Go

Every Go program starts with a package declaration and imports what it uses.

package main

import “fmt”

func main() {
fmt.Println(“Hello, World!”)
}

Rust

The exclamation mark in println! marks it as a macro rather than a function.

fn main() {
println!(“Hello, World!”);
}

Kotlin

Runs on the Java Virtual Machine but needs far less boilerplate than Java.

fun main() {
println(“Hello, World!”)
}

Swift

Apple’s language matches Python’s one-line approach.

print(“Hello, World!”)

PHP

Usually embedded in web pages, so code sits inside PHP tags.

<?php
echo “Hello, World!”;

Ruby

puts prints the text and adds a new line.

puts “Hello, World!”

Perl

The n adds the line break that print leaves out.

print “Hello, World!n”;

Bash

The shell scripting language built into Linux and macOS terminals.

echo “Hello, World!”

SQL and PL/SQL

Standard SQL can simply select the text. Oracle’s PL/SQL uses a built-in output package.

SELECT ‘Hello, World!’;

BEGIN
DBMS_OUTPUT.PUT_LINE(‘Hello, World!’);
END;
/

Visual Basic

The Visual Basic .NET console version.

Module HelloWorld
Sub Main()
Console.WriteLine(“Hello, World!”)
End Sub
End Module

Scala

A classic Scala program wraps main in a singleton object.

object HelloWorld {
def main(args: Array[String]): Unit = {
println(“Hello, World!”)
}
}

Haskell

A functional language in which the whole program is a single definition.

main = putStrLn “Hello, World!”

Common Lisp

The ~% directive adds a new line.

(format t “Hello, World!~%”)

Ada

A language designed for safety-critical systems, with verbose, explicit structure.

with Ada.Text_IO; use Ada.Text_IO;

procedure Hello is
begin
Put_Line (“Hello, World!”);
end Hello;

Pascal

A long-time teaching language with a clear begin and end structure.

program HelloWorld;
begin
writeln(‘Hello, World!’);
end.

Fortran

One of the oldest programming languages still in use, mainly for scientific computing.

program hello
print *, ‘Hello, World!’
end program hello

COBOL

COBOL organizes every program into named divisions, a legacy of its business computing roots.

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY ‘Hello, World!’.
STOP RUN.

ASP (Classic)

Microsoft’s original server-side scripting for web pages.

<% Response.Write(“Hello, World!”) %>

Assembly (x86-64 Linux)

Without a language doing the work, the program has to ask the operating system directly to write the text and then exit.

section .data
msg db “Hello, World!”, 10
len equ $ – msg

section .text
global _start

_start:
mov rax, 1          ; system call: write
mov rdi, 1          ; file descriptor 1: standard output
mov rsi, msg        ; address of the message
mov rdx, len        ; length of the message
syscall

mov rax, 60         ; system call: exit
xor rdi, rdi        ; exit code 0
syscall

Was this Article helpful? Yes No
Thank you for your feedback. 53% 47%