"Hello, World!" program facts for kids
A "Hello, World!" program is a very simple computer program. It usually doesn't take any information from you. Instead, it just shows a message like "Hello, World!" on the screen. These small programs are often the first thing students learn when they start coding in a new programming language. They also help check if a computer's software for running code is set up correctly.
Contents
The Story of "Hello, World!"
People have used small test programs for a long time. But the idea of using "Hello, World!" as a test message became popular because of a famous book. This book, called The C Programming Language, came out in 1978. It had an example program that printed "hello, world".
Early Examples of "Hello, World!"
The example in the C programming book came from a paper written by Brian Kernighan in 1974. This paper was called Programming in C: A Tutorial. Here is how the program looked:
main( ) {
printf("hello, world");
}
In this example, the main( ) part tells the program where to begin. The program then uses a special command called printf. This command means "print formatted." It makes the program show whatever text is inside the parentheses, like "hello, world".
Before the C language version, Brian Kernighan also wrote a tutorial in 1972 for a language called B. This tutorial had an even earlier version of the "Hello, World!" program:
main( ) {
extern a, b, c;
putchar(a); putchar(b); putchar(c); putchar('!*n');
}
a 'hell';
b 'o, w';
c 'orld';
This program printed hello, world! on the screen. The phrase was split into different parts because the B language could only handle four ASCII characters at a time. The idea was to show a slightly longer greeting than a simple "hi!".
Some people say that "hello, world" actually started with a language called BCPL in 1967. The phrase "Hello, World!" was also a popular saying for a radio DJ named William B. Williams in the 1950s.
Different Ways to Say "Hello, World!"
"Hello, World!" programs can be simple or more complex depending on the programming language.
Simple vs. Complex Code
In some languages, especially scripting languages, you can write "Hello, World!" with just one line of code. For example, in Python, you simply write: print("Hello, World!")
.
But in other languages, like C++, you need more lines. You have to include special tools for input and output. You also need to tell the program exactly where to start and send the message to the screen.
Changing the Message
The phrase "Hello, World!" can also change a bit. Sometimes the 'H' and 'W' are capitalized, or there might be no comma or exclamation mark. Some devices can only show capital letters, so the message might be all in caps.
Some very unusual programming languages might even print a slightly different message. For example, the first program in a language called Malbolge printed "Hello world" (without the comma or exclamation mark).
"Hello, World!" in Other Forms
Sometimes, "Hello, World!" programs do more than just print text.

- Functional Programming: In languages like Lisp or Haskell, a "Hello, World!" program might calculate something like a factorial instead of printing text. This is because these languages focus on math-like functions rather than showing things on a screen.
- Embedded Systems: For small devices like microcontrollers (tiny computers in everyday objects), printing text can be hard. So, a "Hello, World!" program might just make an LED light blink. This shows that the device is working.
- Graphical Output: Some "Hello, World!" programs create pictures instead of text. For example, a Java program might show a scalable image, or an XL program might show a spinning Earth in 3D.
The Debian and Ubuntu Linux distributions even have a "Hello, World!" program you can install. You just type hello to run it. It's a simple way to check if your software is working.
Time to "Hello, World!"
"Time to Hello World" (TTHW) is a way to measure how easy a programming language is to learn. It's the time it takes for someone new to that language to write their first "Hello, World!" program. If it takes a long time, the language might be harder for beginners. This idea is also used for APIs, which are tools that help different software talk to each other. A shorter TTHW means the API is easier for new developers to use.
Examples of "Hello, World!" Programs
Ada
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line ("Hello, World!");
end Hello;
ALGOL 60
BEGIN DISPLAY("Hello, World!") END.
BASIC
10 PRINT "Hello, World!"
C
#include <stdio.h>
int main(void)
{
printf("Hello, World!\n");
}
C++
#include <iostream>
int main()
{
std::cout << "Hello, World!" << std::endl;
}
C++23
Also allowed in C++23:
import std;
int main()
{
std::print("Hello world!\n");
}
C#
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, World!");
}
}
or, using top-level statements (starting in C# 9):
using System;
Console.WriteLine("Hello, World!");
COBOL
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello, World!'.
STOP RUN.
Forth
." Hello, World!" CR
Fortran
program Hello
print *, "Hello, World!"
end program Hello
JavaScript
For browser console/JavaScript runtime (such as Node.js):
console.log("Hello, World!");
For HTML document:
document.write("Hello, World!");
or
alert("Hello, World!");
Pascal
program hello(output);
begin
writeln('Hello, World!');
end.
Prolog
main() :- write("Hello, World!"), nl.
Python
print("Hello, World!")
Ruby
puts "Hello, World!"
Rust
fn main() {
println!("Hello, World!");
}
Scala
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
See also
- "99 Bottles of Beer" as used in computer science
- "Hello, World!" program § Notes (graphic equivalent to "Hello, World!" for old hardware)
- "Hello, World!" program § Notes
- Foobar
- Java Pet Store
- Just another Perl hacker
- Outline of computer science
- TPK algorithm