AHello world program is the name of a program that simply prints out "Hello world!".
This is a traditional first program to write when learning a new programming language, and can be a useful sanity test to make sure that a language's development environment and run-time environment are correctly installed.
While minimal test programs such as this existed since the development of programmable computers, the tradition of using "Hello world!" as the test message was probably started by its use as an example program in the book The C Programming Language, by Brian Kernighan and Dennis Ritchie.
Here are some examples in different languages:
with Ada.Text_Io; use Ada.Text_Io; procedure Hello is begin Put_Line ("Hello world!"); end Hello;
MODEL SMALL IDEAL STACK 100H
DATASEG HW DB 'Hello, World!$'
CODESEG MOV AX, @data MOV DS, AX MOV DX, OFFSET HW MOV AH, 09H INT 21H MOV AX, 4C00H INT 21H END
PRINT "Hello world!"
GET "LIBHDR"
LET START () BE $( WRITES ("Hello World!*N") $)
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<< +++++++++++++++.>.+++.------.--------.>+.>.
#include <stdio.h> int main(void) { printf("Hello world!"); return 0; }
#include <iostream> int main() { std::cout << "Hello world!" << std::endl; return 0; }
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION. DISPLAY "Hello, World". STOP RUN.
(format t "Hello world!~%")
class HELLO_WORLD
creation make feature make is local io:BASIC_IO do !!io io.put_string("%N Hello World!!!!") end -- make end -- class HELLO_WORLD
.( Hello world!)
PLEASE DO ,1 <- #13 DO ,1 SUB #1 <- #238 DO ,1 SUB #2 <- #112 DO ,1 SUB #3 <- #112 DO ,1 SUB #4 <- #0 DO ,1 SUB #5 <- #64 DO ,1 SUB #6 <- #238 DO ,1 SUB #7 <- #26 DO ,1 SUB #8 <- #248 DO ,1 SUB #9 <- #168 DO ,1 SUB #10 <- #24 DO ,1 SUB #11 <- #16 DO ,1 SUB #12 <- #158 DO ,1 SUB #13 <- #52 PLEASE READ OUT ,1 PLEASE GIVE UP
public class Hello { public static void main(String[] args) { System.out.println("Hello world!"); } }
import java.applet.*; import java.awt.*;
public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString("Hello, world!", 20, 20); } }
program Hello; begin writeln('Hello world!'); end.
print "Hello world!";
<?php echo "Hello world!"; ?>
Test: procedure options(main);
declare My_String char(20) varying initialize('Hello, world!');
put skip list(My_String);
end Test;
print "Hello world!"
print "Hello world!"
Transcript show: 'Hello world!'
SELECT 'Hello world!' FROM DUAL;
put "Hello world!"
MsgBox "Hello, world!"
Libraries and APIs are also frequently tested by means of "Hello, world" programs. For example, a GUI library can be tested by a program that draws a window with the text "Hello, world." Here is an example of a standalone Java application that does this (which is necessarily more complex than an applet or simple text application):
import java.awt.*; import java.awt.event.*;
public class HelloFrame extends Frame {
HelloFrame(String title) {
super(title);
}
public void paint(Graphics g) {
super.paint(g);
java.awt.Insets ins = this.getInsets();
g.drawString("Hello, World!", ins.left + 25, ins.top + 25);
}
public static void main(String args [])
{
HelloFrame fr = new HelloFrame("Hello");
fr.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit( 0 ); } } ); fr.setResizable(true); fr.setSize(500, 100); fr.setVisible(true); } }
Many more examples can be found at Hello, World Page!.
See also: Just another Perl hacker