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:
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 AH, 4CH
INT 21H
END
PRINT "Hello world!"
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]
<.>+++++++++++[<++++++++>-]<-.- - - - - - - -.+++.- - - - - - . - - - - - - - -
.[-]>++++++++[<++++>-]<+.[-]++++++++++.
#include <stdio.h>
int main(void)
{
printf("Hello world!\n");
return 0;
}
#include <iostream>
int main()
{
std::cout << "Hello world!" << std::endl;
return 0;
}
(format t "Hello world!~%")
." Hello world!" 10 EMIT
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!");
}
}
Java 2 using swing:
// builds a Java window and prints "Hello, world" using Swing JFrame components...
import java.awt.*; import javax.swing.*; import java.awt.event.*;
public class xapp extends JFrame
{
jpanel j;
public xapp()
{
super ("Hello World Application");
Container contentPane = getContentPane(); j = new jpanel(); contentPane.add(j); }
public static void main(String args[])
{
final JFrame f = new xapp();
f.setBounds(100, 100, 300, 300);
f.setVisible(true);
f.setDefaultCloseOperation(EXIT_ON_CLOSE); //tidy up...
}
}
class jpanel extends JPanel
{
jpanel()
{
setBackground(Color.white);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.drawString("Hello world!",0, 65);
}
}
program Hello;
begin
writeln('Hello world!');
end.
print "Hello world!\n"
<?php
echo "Hello world!\n";
?>
Test: procedure options(main);
declare My_String char(20) varying initialize('Hello, world!');
put skip list(My_String);
end Test;
print "Hello world!"
Transcript show: 'Hello world!'
SELECT 'Hello world!' FROM DUAL;
put "Hello world!"
Many more examples can be found at [Hello, World Page!].