Hello, World!

The program which prints “Hello, World!” on the display. This is one of the simplest possible programs for most languages, and is a traditional start for any programming tutorial.

Example for versions Borland C++ Builder 6, g++ 3.4.5, Microsoft Visual C++ 6, Microsoft Visual C++ 9 (2008)

#include <iostream>

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

Example for versions Oracle 10g SQL, Oracle 11g SQL

‘Hello, World!’ string is selected from built-in table dual which is used for queries which don’t need data from real tables.

select 'Hello, World!'
  from dual;

Example for versions gcj 3.4.5, Groovy 1.7, Sun Java 6

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

Example for versions EsCo 0.511 (Brainfuck), Müller's Brainfuck 2.0

There are lots of ways to say “Hello, World!” in Brainfuck. Here is the simplest one: use only one memory cell, and change its value to ASCII-code of each letter in row. Each line of the example prints one letter.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
+++++++++++++++++++++++++++++.
+++++++.
.
+++.
-------------------------------------------------------------------.
------------.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++.
++++++++++++++++++++++++.
+++.
------.
--------.
-------------------------------------------------------------------.

Example for versions EsCo 0.511 (Brainfuck), Müller's Brainfuck 2.0

In this example we use three memory cells — first for uppercase letters ‘H’ and ‘W’, second for lowercase letters and third for special characters ‘,’, ‘ ‘ and ‘!’ — and three index cells to shorten the notation of ASCII-codes changes. The memory used looks like this:

(index cell 1) (uppercase letters cell) (index cell 2) (lowercase letters cell) (index cell 3) (special characters cell)

++++++[>++++++++++++<-]>.
>++++++++++[>++++++++++<-]>+.
+++++++.
.
+++.
>++++[>+++++++++++<-]>.
<+++[>----<-]>.
<<<<<+++[>+++++<-]>.
>>.
+++.
------.
--------.
>>+.

Example for versions Microsoft SQL Server 2005, Microsoft SQL Server 2008 R2, Microsoft SQL Server 2012, MySQL 3.23.57, PostgreSQL 9.1

select 'Hello, World!';

Example for versions clisp 2.47, Corman Common Lisp 3.0, gcl 2.6.6, SBCL 1.0.1, SBCL 1.0.29

When executed in interactive mode, program output looks as follows:

Hello, World!
NIL

First line contains standard output, second — the result of expression evaluation (in this case there is none).

(format t "Hello, World!~%")

Example for versions Squeak 3.10

This example would pop up an information box with “Hello, World!’ as text, and an “Okay” button.

self inform: 'Hello, World!'.

Example for versions Lua 5.0.3

print("Hello, World!")

Example for versions EsCo 0.511 (Brainfuck)

This example is Ook! translation of second Brainfuck example.

Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? 
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. 
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? 
Ook! Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. 
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. 
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. 
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook. Ook! Ook. Ook. Ook. Ook. Ook. 
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook! Ook. Ook. Ook. 
Ook. Ook. Ook. Ook. Ook! Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. 
Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. 
Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook! Ook! Ook? Ook! 
Ook. Ook? Ook! Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook. Ook? 
Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? 
Ook! Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. 
Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. 
Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook. Ook. Ook? Ook. Ook? Ook! Ook. 
Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! 
Ook! Ook! Ook! Ook! Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! 
Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook! Ook. 

Example for versions Microsoft Visual Basic 6

The intended use of Visual Basic is GUI applications development, so creating a simple console application is a non-trivial task itself. This example features:

  • importing required functions from standard library;
  • console creation;
  • getting the handle of console output stream;
  • writing the message to this stream and
  • deallocation of used objects.
Option Explicit

    Declare Function AllocConsole Lib "kernel32" () As Long
    Declare Function FreeConsole Lib "kernel32" () As Long
    Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
    Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" _
           (ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal _
           nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, _
           lpReserved As Any) As Long
    Declare Function Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) As Long

Private Sub Main()
    'create a console instance
    AllocConsole
    'get handle of console output
    Dim hOut As Long
    hOut = GetStdHandle(-11&)
    'output string to console output
    Dim s As String
    s = "Hello, World!" & vbCrLf
    WriteConsole hOut, ByVal s, Len(s), vbNull, vbNull
    'make a pause to look at the output
    Sleep 2000
    'close the handle and destroy the console
    CloseHandle hOut
    FreeConsole
End Sub

Example for versions bwBASIC 2.50, QBasic 1.1, QuickBASIC 4.5

PRINT "Hello, World!"

Example for versions EsCo 0.511 (Brainfuck)

This example is Spoon translation of second Brainfuck example. Note that the intended way of coding in Spoon allows writing commands without delimiters, but current version of EsCo requires that commands are space-separated.

1111110010001011111111111101100000110100010100101111111111001000101111111111011000001101
0100101011111110010100010101110010100101111001000101111111111101100000110100010100111110
0100010000000000000011000001101000101001101101101101111100100010111110110000011010001010
0100100010101110010100000000000000000000010100000000000000000000000000010100100101001010

Example for versions Visual Prolog 7.2

Visual Prolog provides automatic project creation, so you have to create a new project, choose “Console” as UI Strategy, navigate to file main.pro and replace its contents with the given code. The code differs from the standard one only in terms stdio::write (to write the message to the console) and programControl::sleep (to pause program execution).

implement main
    open core

constants
    className = "main".
    classVersion = "".

clauses
    classInfo(className, classVersion).

clauses
    run():-
        console::init(),
        stdio::write("Hello, World!"),
        programControl::sleep(1000),
        succeed().
end implement main

goal
    mainExe::run(main::run).

Example for versions B-Prolog 7.4 #3, gprolog 1.3.0, Poplog 15.5 (Prolog), swipl 5.6.x

This example doesn’t need any facts or rules to be evaluated. The query is executed in interactive mode, and results in the following output:

Hello, World!
yes

First line is the actual output of write predicate, and second line is the result of query evaluation.

Note that replacing single-quotes with double-quotes makes Prolog output the string as an array of ASCII-codes of individual characters:

| ?- write("Hello, World!").
[72,101,108,108,111,44,32,87,111,114,108,100,33]

yes

write('Hello, World!'), nl.

Example for versions Python 2.5.2

print "Hello, World!"

Example for versions Free Pascal 2.0.4, Free Pascal 2.2.0, gpc 20070904, Turbo Pascal 1.0, Turbo Pascal 2.0, Turbo Pascal 3.0, Turbo Pascal 4.0, Turbo Pascal 5.0, Turbo Pascal 5.5, Turbo Pascal 6.0, Turbo Pascal 7.0

program helloworld;

begin
    writeln('Hello, World!');
end.

Example for versions ARIBAS 1.53

writeln("Hello, World!");

Example for versions perl 5.8.8, rakudo-2010.08

print "Hello, world!\n";

Example for versions Microsoft Visual Basic .NET 9 (2008), vbnc 2.4.2

Module Module1
    Sub Main()
        Console.WriteLine("Hello, World!")
    End Sub
End Module

Example for versions E-on-Java 0.9.3

println("Hello, World!")

Example for versions Borland C++ Builder 6, g++ 3.4.5, gcc 3.4.5, gcc 3.4.5 (Objective-C), gcc 4.2.4, tcc 0.9.25, Turbo C++ 1.01

#include <stdio.h>

int main()
{
    printf("Hello, World!\n");
    return 0;
}

Example for versions gmcs 2.0.1, Microsoft Visual C# 2008

using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");
    }
}

Example for versions gnuplot 4.2.2

#!/usr/bin/env gnuplot
print 'Hello, World!'

Example for versions PHP 5.2.4, PHP 5.3.2

<?php
echo "Hello, World!\n";
?>

Example for versions Poplog 15.5 (POP-11)

=> is output operator.

'Hello, World!' =>

Example for versions OCaml 3.11

print_endline is a built-in function defined with the following type:

string -> unit = <func>

This means that it takes 1 string as a parameter, and returns the unit type, ().

let () = print_endline "Hello World";;

Example for versions D1, D2, gdc 0.24

writef() and writefln() writes to standard output and interpret the first argument as a format string. They are roughly analogous to C’s printf(). writefln() automatically appends a newline. D2 adds write() and writeln() which do not interpret the first argument as a format string. However, they are not available in D1.

module hello;

import std.stdio;

int main()
{
	writefln( "Hello, World!" );
	return 0;
}

Example for versions rakudo-2010.08

say command is available only in Perl 6. The semicolon at the end is optional.

say 'Hello, World!';

Example for versions Euphoria v3.1.1, Euphoria v4

The routine puts() writes the second argument (a string) to the device identified by the first argument. There are three predefined devices: 0 is STDIN, 1 is STDOUT, and 2 is STDERR.

puts(1, "Hello, World!\n")

Example for versions Oracle 10g SQL, Oracle 11g SQL

This example accomplishes the task by means of anonymous PL/SQL block, which uses standard package dbms_output to print the message to standard output.

begin
    dbms_output.put_line('Hello, World!');
end;

Example for versions j602

1!:2 is the dyadic foreign conjunction for writing text, the left argument is the string to be written and the right argument specifies the file number, a file number 2 indicates that the text is to be written to the screen.

Alternatively we can use currying to convert the dyadic write conjunction into a monadic conjunction using the bond (&) operator and assign it to a named print function.

The printf library may also be used to print text to the screen.

'Hello, World!' 1!:2]2

print=: 1!:2&2
print 'Hello, World!'

load 'printf'
'' printf 'Hello, World!\n'

Example for versions Regina 3.3, REXX

say 'Hello, World!'

Example for versions Adobe Flex 3.4

While the constructor Main() is called first, it contains a small routine that causes initialization to occurr only if it is created on a stage or when it is added to a stage.

“Hello World” is created via a TextField object.

package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.display.MovieClip;
	import flash.text.TextField;
	
	public class Main extends Sprite 
	{
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);

			// entry point		
			var tf:TextField = new TextField();
			tf.text = "Hello World!";
			tf.x = 200;
			tf.y = 20;
			this.addChild(tf);
		}
	}
}

Example for versions Algol68g-1.18.0

Note the use of printf with the formatting being described between dollars. eg $gl$ — meaning “g”eneral pattern, then new “l”ine.

( 
  printf(($gl$,"Hello, world!"))
)

Example for versions gfortran 4.5.0, Intel Visual Fortran 11.1

program HelloWorld

print *, 'Hello, World!'

end program HelloWorld

Example for versions Rhino 1.6, SpiderMonkey 1.7

JavaScript uses different commands to output messages depending on what environment is it used in:

  • print: for interpreters with command-line interface prints the message to standard output stream, but when used in web-browser, calls print dialog instead;
  • document.write: when used in web-browser, prints the message to the current document (web-page);
  • console.log: a command for Firebug plugin which prints the message to debug console of the plugin;
  • alert: when used in web-browser, creates a pop-up information window with the message.

Note that three last commands won’t work in non-browser-based environment, since they use objects (document and console) which are not defined in command-line interfaces.

The example itself works in a smart universal way: since it can be executed in multiple environments with various objects defined, it checks each object in turn, and uses the first available writing method.

if (typeof console === 'object') {
    console.log('Hello, World!');
} else if (typeof document === 'object') {
    document.write('Hello, World!');
} else {
    print('Hello, World!');
}

Example for versions GHC 6.10.4

module Main where

main = do
    putStrLn "Hello, World!"

Example for versions Furry Paws

~x is constant-value function (denoted with % in Interactive FP). emit is a function which writes its argument to stdout. main is a function which is the first to be invoked when the program is executed.

main = emit.(return ~"Hello, World!\n")

Example for versions gnat 3.4.5, gnat 4.3.2

with Ada.Text_IO; 
 
procedure HelloWorld is
begin
  Ada.Text_IO.Put_Line("Hello, World!");
end HelloWorld;

Example for versions Scratch 1.4

Since it’s a graphical language, there is no actual source text, see the print-screen instead. The bat is the sprite of the example, and the script which is associated with it has only one block which makes the sprite “say” the required phrase.

say Hello, World!

"Hello, World!" example in Scratch
"Hello, World!" example in Scratch

Example for versions UCBLogo 6.0

print [Hello, World!]

Example for versions gc-2010-07-14

package main
import "fmt"

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

Example for versions Scala 2.7.7-final, Scala 2.8.0-final

object Main {
    def main(args: Array[String]) {
        println("Hello, World!")
    }
}

Example for versions gawk 3.1.6, Jawk 1.02, mawk 1.3.3

The printing is done with BEGIN pattern, i.e., before processing the input.

BEGIN { print "Hello, World!" }

Example for versions Ruby 1.8.5

puts "Hello, World!"

Example for versions S-lang 2.2.2

This example should be executed in slsh interpreter.

message ("Hello, World!");

Example for versions Hanoi Love

This example is a translation of Brainfuck example. All stacks are empty, and all calculations are done in the register. Stack A is used as a source of constant 1: since it’s empty, pop operation on it returns 1. This way, ; and ` operations become “increment register by 1” and “decrement register by 1”, i.e., they are equivalent to + and - Brainfuck commands. "' pushes the contents of the register to standard out, i.e., is equivalent to . in Brainfuck.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; "'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; "'
;;;;;;; "'
"'
;;; "'
``````````````````````````````````````````````````````````````````` "'
```````````` "'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; "'
;;;;;;;;;;;;;;;;;;;;;;;; "'
;;; "'
`````` "'
```````` "'
``````````````````````````````````````````````````````````````````` "'

Example for versions Sanscript 2.2

Sanscript is a fully visual programming language, so no source code is available. See screenshot instead.

The flowgram (Sanscript equivalent of program) for this example consists of two functions: constant “Hello, World!” and function “Display Message”. Once the flowgram runs, the constant function produces the message on its outlet. An arrow link connects this outlet to inlet of “Display Message” function, so it creates a pop-up window with this message.

"Hello, World!" example in Sanscript
"Hello, World!" example in Sanscript

Example for versions Müller's Brainfuck 2.0

This example is a Brainloller translation of this example. Since Brainloller is a fully graphical language, no source code is available, see screenshots instead.

"Hello, World!" example in Brainloller
"Hello, World!" example in Brainloller

"Hello, World!" example in Brainloller (10x scale)
"Hello, World!" example in Brainloller (10x scale)

Example for versions Müller's Brainfuck 2.0

This example is a translation of this example into Unary. The program itself is too large, so it is given in shortened way.

A string of 
708184005756841022918598670049178934705323143517361395031673227349803938380
119378597780037353721967636097362645175347036417214959141923667629285233360
306016978751166690464736541968556 zeroes (approximately 7*10^182).

Example for versions MLton, Moscow ML 2, SML/NJ 110

print is a built-in function defined with the following type:

string -> unit

This means that it takes 1 string as a parameter, and returns the unit type, ().

print "Hello World\n";

Example for versions Ellsässer's HQ9+ 0.8

In this language any code which contains H command and doesn’t contain Q or 9 commands outputs “Hello, World!”.

H

Example for versions Simply Scala

In Simply Scala you can evaluate expressions without framing them as objects.

println("Hello, World!")

Example for versions Roco 20071014

This code uses only main coroutine; it outputs the message character by character, using their ASCII codes, and stops.

cout 72
cout 101
cout 108
cout 108
cout 111
cout 44
cout 32
cout 87
cout 111
cout 114
cout 108
cout 100
cout 33
ac

Example for versions Bash 3.0

This example demonstrates script declaration line, comment, variables and difference between single and double quotes. This is likely enough for Hello. As it should be in bash, message can be configured through parameters.

# Prints "Hello world" message in Bash, Unix shell.

MESSAGE='hello'
TARGET='world'

echo "$MESSAGE $TARGET"

Example for versions LabVIEW 10.0

G/LabVIEW is a fully visual programming language, so no source code is available. See screenshot instead.

The block diagram (LabVIEW equivalent of program) for this example consists of only one node — “Display Message to User”, with pre-set message “Hello, World!”.

To create this example, create a new project and a new VI within it. Switch to Block Diagram of the new VI. Navigate to Functions -> Programming -> “Dialog and User Interface”, choose “Display Message To User” control and place it onto the Block Diagram area. Once it’s placed, a configuration dialog will appear; enter “Hello, World!” as the message to display. Save the project and press “Run” to get a pop-up message box. The screenshot shows both the block diagram and the result of its execution.

"Hello, World!" example in G/LabVIEW
"Hello, World!" example in G/LabVIEW

Example for versions fsharp 2.0.0

printfn "Hello, World!"

Example for versions Whitespacers (Ruby)

This code is commented to simplify understanding it: letter means that next piece of whitespace pushes on the stack ASCII-code of this letter, and print means invoking the command of printing topmost element of the stack. The numbers that correspond to ASCII-codes are contained within brackets (except for the delimiting newline which is outside of the brackets for readability).

H  { 	  	   }
print	
  e  { 		  	 	}
print	
  l  { 		 		  }
print	
  l  { 		 		  }
print	
  o  { 		 				}
print	
  ,  { 	 		  }
print	
  space  { 	     }
print	
  W  { 	 	 			}
print	
  o  { 		 				}
print	
  r  { 			  	 }
print	
  l  { 		 		  }
print	
  d  { 		  	  }
print	
  !  { 	    	}
print	
  \n  { 	 	 }
print	
  


end

Example for versions Bash 4.0.35

This example uses dc (Desktop Calculator), which is a popular non-standard tool that allows processing arbitrary-precision numbers. | dc means that dc has to be applied to the command.

P command (the last character before | dc) outputs the last element of the stack. The huge number before P when written in hexadecimal looks as 0x48656C6C6F2C20576F726C64210A; pairs of adjacent digits form ASCII-codes of characters of “Hello, World!”: 0x48 = H, 0x65 = e, 0x6c = l etc. Thus, when printed, this number is processed as a string.

echo 1468369091346906859060166438166794P | dc

Example for versions ActiveTcl 8.5, JTcl 2.1.0, Tcl 8.4, Tcl 8.5.7

puts "Hello, World!"

Example for versions Onyx 5.1.2

#!/usr/bin/onyx

`Hello world!\n' print

Example for versions Miller's Hack VM (JavaScript), Miller's Hack VM (Python)

This program works in a rather evident way — ASCII-codes of characters of the message are calculated one-by-one and printed out. The only bit of hack used is processing of ‘l’ character — once its ASCII-code is calculated, it is tripled in the stack (using 0^ command), and printed twice immediately and once later.

89*P 45*99*+P 39*99*+0^0^PP 56*99*+P 29+4*P 48*P 92+8*1-P 56*99*+0^P 3+P P 25*0^*P 56*3+P

Example for versions erl 5.7.3

First line notes that this module must be placed in file called prog.erl. Second line exports function main, of arity 0 (takes no parameters). Third line defines the function: all it does is output “Hello, World!”.

-module(prog).
 
-export([main/0]).
 
main() -> io:format("Hello, World!~n").

Example for versions bc 1.06

print "Hello, World!\n";

Example for versions boo 0.8.2

print("Hello, World!")

Example for versions agda 2.2.6

Just writing strings is not a natural task for Agda, so it needs some extra installations.

This example should be saved in file “helloworld.agda”. You’ll have to install agda standard library (agda-stdlib); this was tested with agda 2.2.6 and agda-stdlib 0.3. To compile the example, use agda -i [library path] -i . -c helloworld.agda, where [library path] is a path to where you installed agda-stdlib. This compiles Agda source code into Haskell code, and then converts it into an executable.

module helloworld where

open import IO.Primitive using (IO; putStrLn)
open import Data.String using (toCostring; String)
open import Data.Char using (Char)
open import Foreign.Haskell using (fromColist; Colist; Unit)
open import Data.Function

fromString = fromColist . toCostring

main : IO Unit
main = putStrLn (fromString "Hello, World!")

Example for versions gforth 0.7.0

Word ." reads a double-quotes-delimited string and outputs it. The space character that separates ." and Hello doesn’t count as part of the string, it’s necessary to recognize ." as a word.

cr outputs a new line character and is an equivalent of nl in Prolog and endl in C++.

." Hello, World!" cr

Example for versions c-intercal 28.0, J-INTERCAL 0.11, J-INTERCAL 0.12

INTERCAL is one of the languages in which even writing “Hello, World!” is a torture. The trick is, C-INTERCAL’s command READ OUT implements character output on Turing Tape method. To use it, the output argument must be an array, which we have stored in ,1 (, means that the variable is an array of 16-bit integers). The values of the array produce output one by one, from left to right. To figure out what character to output based on i-th element of the array, the compiler performs the following actions:

  1. Bit-reverse ASCII-code of previous printed character (assuming it’s 8-bit) to get rev(i-1). When outputting first element of the array, this is assumed to be 0.
  2. Get the i-th element of the array array(i).
  3. Subtract array(i) from rev(i-1) to get rev(i).
  4. Bit-reverse rev(i) to get ASCII-code of the character to be printed i-th.

Another thing to note is the usage of PLEASE modifier. This program must contain 4 or 5 PLEASE, the lines where they are located don’t really matter. 3 or less PLEASE result in “ICL079I PROGRAMMER IS INSUFFICIENTLY POLITE” error, while 6 or more yield “ICL099I PROGRAMMER IS OVERLY POLITE” error.

Other commands and expressions are trivial (at least compared to previous ones): # is a constant prefix, <- is assignment, SUB is subscript of an array. The first line of the example states that ,1 is an array of 16-bit integers, and it will have 13 elements.

DO ,1 <- #13
PLEASE DO ,1 SUB #1 <- #238
DO ,1 SUB #2 <- #108
DO ,1 SUB #3 <- #112
DO ,1 SUB #4 <- #0
DO ,1 SUB #5 <- #64
DO ,1 SUB #6 <- #194
PLEASE DO ,1 SUB #7 <- #48
DO ,1 SUB #8 <- #26
DO ,1 SUB #9 <- #244
PLEASE DO ,1 SUB #10 <- #168
DO ,1 SUB #11 <- #24
DO ,1 SUB #12 <- #16
DO ,1 SUB #13 <- #162
PLEASE READ OUT ,1
PLEASE GIVE UP

Example for versions CLC-INTERCAL 1.-94.-2

CLC-INTERCAL Baudot-based text I/O mechanism differs from C-INTERCAL’s, but is not much more convenient. Baudot is a 5-bit character encoding, in which each character consists of two codes — shift state and the actual character code. Shift state can be 1..4, and switching between shift states takes special codes 31 (switch from 1|2 to 2 or from 3|4 to 1) and 27 (switch from 1|2 to 3 or from 3|4 to 4). Thus, an array which has to be printed is interpreted as a sequence of codes, each of them being either switch code or print-character code. The array is usually longer than the message, since switch codes are added.

In this example, the message starts with H, which corresponds to Baudot code “1 0x14” (shift state = 1, code = 20). Initially shift state is set to 1, no need to change it, and so the first element of the array is print-character code 20. Next character is e, Baudot “2 0x01”, we have to switch to state 2 (code 31) and print the character (code 1). Next is l, Baudot “2 0x13”, no shift state switching, only print character (code 19), etc.

Note that CLC-INTERCAL doesn’t really care about programmer’s politeness; the example contains much less PLEASE than C-INTERCAL would have required.

DO ,1 <- #18

DO ,1 SUB #1 <- #20
DO ,1 SUB #2 <- #31
DO ,1 SUB #3 <- #1
DO ,1 SUB #4 <- #19
DO ,1 SUB #5 <- #19
DO ,1 SUB #6 <- #24
DO ,1 SUB #7 <- #27
DO ,1 SUB #8 <- #12
DO ,1 SUB #9 <- #4
DO ,1 SUB #10 <- #31
DO ,1 SUB #11 <- #18
DO ,1 SUB #12 <- #31
DO ,1 SUB #13 <- #24
DO ,1 SUB #14 <- #10
DO ,1 SUB #15 <- #19
DO ,1 SUB #16 <- #9
DO ,1 SUB #17 <- #27
DO ,1 SUB #18 <- #13

PLEASE READ OUT ,1
PLEASE GIVE UP

Example for versions Mozart 1.4.0

functor
import
   Application
   System
 
define
   {System.showInfo 'Hello, World!'}
   {Application.exit 0}
 
end

Example for versions gst 3.1

'Hello, World!' printNl.

Example for versions Groovy 1.7

println "Hello, World!"

Example for versions Müller's Brainfuck 2.0

This example is Pi translation of this one.

3.141592653589793238462623382272502824197169299275107820904924592337816406386238
99262833482534311206728234808621328230264709314460935058223872535941812844111745
00841022019385311055296426229289549302819244388109726652334471204756422337867231
65221231909345628566933460342610454226248213391607264249148273720587036656315582
17288153092396282225439171532436789559536003133023024882044652108412695192151163
94330573703656595909530921261173839326137921051125420742623799227495273538857227
24892227938133011749109833675362442656243086321294946795024737130702479860343702
77453921711629317375838467480846766440513202056822724526351082178577132275778260
91736271767204684409312229532301462492853110307922896892089235450199501120290219
65862034218129813624774731309964518707241349993993372978039951049734732816036348
59504445345544690330263252250825304468003522193158817101

Example for versions ncc 0.9.3

This example is written in C# style; a more compact version would be just

System.Console.WriteLine ("Hello, World!");
class Hello {
  static Main () : void {
    System.Console.WriteLine ("Hello, World!");
  }
}

Example for versions Web2c 2009

Hello, World!
\bye

Example for versions Factor 0.94

The first line imports io dictionary (print word). The second line pushes the message string on the stack and then calls print which prints the top element of the stack.

USE: io 

"Hello, World!" print

Example for versions EsCo 0.511 (Brainfuck)

Example for dialect Boolfuck.

H ;;;+;+;;+;+;
e +;+;+;+;;+;;+;
l ;;+;;+;+;;+;
l ;;+;;+;+;;+;
o +;;;;+;+;;+;
comma ;;+;;+;+;+;;
space ;;;;;+;+;;
W +;;;+;+;+;+;+;
o +;;;;+;+;;+;
r ;+;+;;+;;;+;
l ;;+;;+;+;;+;
d ;;+;+;;+;;+;
! +;+;;;;+;+;;
\n ;+;+;+; 

Example for versions EsCo 0.511 (Brainfuck)

This example is written in pbrain. First line defines a procedure identified with 0 which copies the contents of previous cell to the current one and adds 10 to it. Second line fills first 14 cells with values 0..130 with step 10. Finally, the values of some cells are modified to represent ASCII-codes of required characters.

(++++++++++<[>+>+<<-]>>[<<+>>-])
>::::::::::::::
<<<<<<<--------.>>>---------.+++++++..>---------.<<<<<<
<------.<--------.>>>>>---.>>>.+++.<.--------.<<<<<<<+.

Example for versions Baltie 3

This example consists of two icons: first one is literal and contains the message to be printed, while the second one is read key or mouse button (wait for pressing) and basically just pauses the execution until any key is pressed.

"Hello, World!" in Baltie 3
"Hello, World!" in Baltie 3

Example for versions Io-2008-01-07

This program creates a symbol “Hello, World!” (a symbol is an immutable sequence) and sends it a println message (similar to calling println method in other languages).

"Hello, World!" println

Example for versions npiet 1.2

This example uses only 2 commands — push and out (char). To print one character, one has to create a block of any color; the number of pixels in it should be equal to ASCII-code of this character. After this, one should create a block of color one shade darker of arbitrary size immediately to the right of that block (this will perform push command). Finally, a block of color one hue to the left of the original one of arbitrary size will perform out(char) command. After this, this sequence repeats for the next character.

To end program execution, we use a loop — a single-color block surrounded with black pixels. When the instruction pointer gets inside this block, it can’t leave in any direction.

The decorative version of the example shows that blocks can have any shape, even with pixels of other colors inside.

"Hello, World!" in Piet (basic)
"Hello, World!" in Piet (basic)

"Hello, World!" in Piet (basic, 5x scale)
"Hello, World!" in Piet (basic, 5x scale)

"Hello, World!" in Piet (decorative)
"Hello, World!" in Piet (decorative)

"Hello, World!" in Piet (decorative, 5x scale)
"Hello, World!" in Piet (decorative, 5x scale)

Example for versions Online Cat 1.3

First line of the example pushes a string “Hello, World!” on the top of the stack. Second line pops the top element from the stack and prints it, followed by a newline.

"Hello, World!"
writeln

Example for versions 64-bit BCPL Cintcode System (1 Nov 2006)

$( ... $) is another form of delimiting a block. *n prints a newline.

GET "libhdr"

LET start() = VALOF
$( writes("Hello, World!*n")
   RESULTIS 0
$)

Example for versions befungee 0.2.0

First part of the example pushes the required values on the stack. 25* puts 10 on the stack (ASCII-code of new line), then " toggles string mode, in which each character of the program pushes its ASCII-code on the stack, and finally second " toggles string mode off.

Second part of the example is a loop which prints all values in the stack, starting from the topmost ones. > makes the instruction pointer move right (after the end of iteration). : duplicates the topmost element of the stack (i.e., the current character); due to usage of the bridge # this command is executed only when the instruction pointer moves to the right. , prints the topmost element of the stack; due to the bridge it is executed only when the IP moves to the left. _ allows the IP to pass to @ if the topmost element of the stack is 0 (or the stack is empty) and mirrors it back to moving left otherwise. The order of events within one iteration is:

  • duplicate the topmost element of the stack.
  • check, whether it’s equal to 0; if it is, break the loop. During this check the topmost element is always deleted.
  • print the topmost element of the stack.
25*"!dlroW ,olleH" >:#,_@

Example for versions befungee 0.2.0

This example handles the task in a more straightforward way — puts ASCII-codes of characters on the stack one-by-one and prints them immediately after they get on the stack.

89*,45*99*+,39*99*+::,,56*99*+,29+4*,48*,92+8*1-,56*99*+:,3+,,25*:*,56*3+,25*,@

Example for versions Acme-Chef-1.01

Each ingredient holds ASCII-code of one message character; for convenience their names start with the letters they hold. The codes are placed in the bowl in reverse-printing order. Then Liquify (old spelling of the command is used to make the program run in the interpreter) makes all elements of the bowl liquid (i.e. states that they should be printed as characters). Finally, the contents of the bowl is moved to the baking dish, and Serves 1 prints its contents.

Lobsters with Fruit and Nuts.

This recipe prints "Hello, World!" in a most delicious way.

Ingredients.
72 g hazelnuts
101 eggs
108 g lobsters
111 ml orange juice
44 g cashews
32 g sugar
87 ml water
114 g rice
100 g durian
33 passion fruit
10 ml lemon juice

Method.
Put lemon juice into the mixing bowl.
Put passion fruit into the mixing bowl.
Put durian into the mixing bowl.
Put lobsters into the mixing bowl.
Put rice into the mixing bowl.
Put orange juice  into the mixing bowl.
Put water into the mixing bowl.
Put sugar into the mixing bowl.
Put cashews into the mixing bowl.
Put orange juice into the mixing bowl.
Put lobsters into the mixing bowl.
Put lobsters into the mixing bowl.
Put eggs into the mixing bowl.
Put hazelnuts into the mixing bowl.
Liquify contents of the mixing bowl.
Pour contents of the mixing bowl into the baking dish.

Serves 1.

Example for versions OpenCOBOL 1.0, TinyCOBOL 0.65.9

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

Example for versions Inferno Limbo 20100115

implement Hello;
include "sys.m";
	sys: Sys;
include "draw.m";

Hello: module {
	init: fn(nil: ref Draw->Context, argv: list of string);
};

init(nil: ref Draw->Context, argv: list of string)
{
	sys = load Sys Sys->PATH;
	sys->print("Hello, World!\n");
}

Example for versions Pike 7.8

void main() 
{
    write("Hello, World!\n");
}

Example for versions Progopedia Grocery List

This example uses v, n, c, w and p commands. The rest of list items are skipped, since they are used as arguments for v command.

Hello, World! supermarket

Vanilla Ice Cream
Honey & Mint Ice Cream
pizza, mushroom and salami
vinegar
eggs, 10
pie with any berries, see what kinds there are
vegetable frozen mix
lamb leg
chicken if no lamb
cod
plaice if no cod
pork steak if you want it
veggie soup
onions
carrots
peas
no more mustard, please! got plenty of it!!!
pair of socks
noodles, I think, with meat, ok?
pasta
Venetian cake
Wax Polish
potato
pumpkin juice
violet onion
rice
popcorn
pudding
watermelon
poultry
Nescafe to take to the office x10
pumpkin

Example for versions Objeck 2.0.3

bundle Default {
	class Hello {
		function : Main(args : String[]) ~ Nil {
			"Hello, World!"->PrintLine();
		}
	}
}

Example for versions Morphett's FALSE, Wouter's FALSE 1.2.CF

A string is equivalent to a command which simply prints it. There’s no way to put the string on the stack, except for as a part of a function.

"Hello, World!"

Example for versions Lingua::Shakespeare 1.00

The message is printed in a simplest way: ASCII-code of each character is calculated anew as a sum of powers of two present in its binary notation.

use Lingua::Shakespeare;

Shakespeare-style Encoded Message.

Desdemona, the talker.
Pericles, a shut-pan with notable patience.

Act I: Message output.

Scene I: Letter by letter.

[Enter Desdemona and Pericles]

Desdemona:
  You honest reddest gentle loving sweet brave rose!
  You are as bottomless as the sum of yourself and a rural red purple hamster!
  Speak your mind!

  You bold cunning peaceful proud good sweetest hero!
  You are as pretty as the sum of thyself and a warm cunning cute fine delicious kingdom!
  You are as bottomless as the sum of yourself and a rural white morning!
  You are as small as the sum of yourself and a grandfather!
  Speak your mind!

  You sweetest proud happy prompt cunning loving joy!
  You are as embroidered as the sum of yourself and a reddest loving beautiful cunning handsome happiness!
  You are as reddest as the sum of yourself and a peaceful cunning beautiful pony!
  You are as rural as the sum of yourself and a white tiny sky!
  Speak your mind!
  Speak your mind!

  You healthy amazing loving clearest trustworthy good happiness!
  You are as brave as the sum of yourself and a cunning golden loving peaceful mighty pony!
  You are as delicious as the sum of thyself and a mighty rich gentle plum!
  You are as embroidered as the sum of yourself and a fine bold hero!
  You are as old as the sum of yourself and a tiny cat!
  You are as green as the sum of thyself and a stone wall!
  Speak your mind!

  You bottomless big blue purple huge horse!
  You are as lovely as the sum of thyself and a gentle prompt delicious Heaven!
  You are as red as the sum of yourself and a bottomless big moon!
  Speak your mind!

  You tiny red furry rural bottomless sky!
  Speak your mind!

  You rural bluest large bottomless little purple cow!
  You are as sweet as the sum of yourself and a embroidered cute trustworthy rich rose!
  You are as bottomless as the sum of yourself and a green normal cow!
  You are as proud as the sum of thyself and a handsome summer's day!
  You are as happy as the sum of thyself and a flower!
  Speak your mind!

  You tiny bluest large huge hard normal uncle!
  You are as warm as the sum of yourself and a pretty rich charming reddest mighty Heaven!
  You are as small as the sum of yourself and a huge green little morning!
  You are as sweetest as the sum of yourself and a beautiful sweet kingdom!
  You are as warm as the sum of yourself and a proud happiness!
  You are as hard as the sum of yourself and a roman!
  Speak your mind!

  You warm cute happy pretty golden loving Lord!
  You are as huge as the sum of thyself and a little furry small green yellow brother!
  You are as peaceful as the sum of thyself and a honest brave happy fine flower!
  You are as small as the sum of yourself and a yellow purse!
  Speak your mind!

  You normal purple rural old white big morning!
  You are as blossoming as the sum of yourself and a charming cunning gentle lovely amazing happiness!
  You are as normal as the sum of thyself and a large red big animal!
  You are as charming as the sum of yourself and a healthy delicious hero!
  Speak your mind!

  You large old bluest green red rural lantern!
  You are as sweet as the sum of yourself and a beautiful loving sunny mighty reddest summer's day!
  You are as lovely as the sum of yourself and a bold clearest happiness!
  Speak your mind!

  You golden loving fair charming lovely King!
  You are as rural as the sum of thyself and a squirrel!
  Speak your mind!

[Exeunt]

Example for versions npiet 1.2

This example was generated using a translator by Sergei Lewis. It provides two tools — a translator from a simple C-like language into an assembler and from the assembler into the Piet image. In this case the original program looked like this:

main()
{
asm{ @"Hello, World!\r\n" }
}

Hello, World! in Piet (autogenerated)
Hello, World! in Piet (autogenerated)

Hello, World! in Piet (autogenerated, 5x scale)
Hello, World! in Piet (autogenerated, 5x scale)

Example for versions Whirl

This program was written by Kang Seonghoon.

110011100111000001111100000001000011111000011111100000000010
000011001111100001100010000010011111000100000000000001001111
100000111110001000000000000000001000111110010000001100001111
100011000000000100111110011100111000111000001000111000001111
100000111110010000011111000110011111100001111000001111000001
110011111100001111000110011100000111000100011111000001111100
100000110000000111000001110001111100011111000111000001000001
000011000111110001000001000000011100000111001000111110001111
000001111000011111100001111110000011110000000000000000011110
000011100111000011110011111000111110001111100000100000000000
000000000000111110001110000001110000011100011100111110001000
100000000011100001111100110000000010011111000111100000111100
111100010011100000111110000011111001100111100010001111000000
000001000111110010000010011110011001110001000111110001100000
100011111000011110011100111111000111100000111100011111000000
011110000011100100001111000100011111001100011111000111100000
111001110001100111100100000000000000011111000001111100010010
000011100001111100100000100011100000111000110011110001001111
110001100000111100011111000111100000111001000011110001001111
100000111110000000011110000011110000000000000000111000001110
000011000001100000111000111000001100111110000111111001001110
000011111000001100011000001001111110000011100110011111000000
000111000001110000111100001100
 

Example for versions GNU Octave 3.2.3

The first function is identical to the C one. The second one is Octave-specific.

printf("Hello, World!\n");

disp("Hello, World!");

Example for versions Alef (Plan 9, edition 2)

This example illustrates the usage of channels and processes. The main process creates a channel which transmits string addresses. After this it starts a child process with channel argument, feeds message address to the channel and terminates. The second process waits for the message, prints it and terminates as well.

#include	<alef.h>

void
receive(chan(byte*) c)
{
	byte *s;
	s = <-c;
	print("%s\n", s);
	terminate(nil);
}

void
main(void)
{
	chan(byte*) c;
	alloc c;
	proc receive(c);
	c <-= "Hello, World!";
	terminate(nil);
}

Example for versions guile 1.8.5, JScheme 7.2, MIT/GNU Scheme 7.7.9

Printing a message is a side effect of this command. Depending on the chosen implementation, the command will return either the message printed, or Unspecified return value.

(write "Hello, World!")

Example for versions Clojure 1.0.0, Clojure 1.1.0

(printf "Hello, World!")

Example for versions Seed7 2012-01-01

$ include "seed7_05.s7i";

const proc: main is func
begin
    writeln("Hello, World!");
end func;

Example for versions Falcon 0.9.6.6

printl('Hello, World!')

Example for versions Gwydion Dylan 2.4.0

The first line is a header; it defines the module this file belongs to.

module: hello-world

format-out("Hello, World!\n");

Example for versions iconc 9.4

procedure main ()
   write ("Hello, world!")
end

Example for versions Rust 0.1

use std;
import std::io;

fn main() {
    io::println("Hello, World!");
}

Example for versions Ceylon M1

Let’s say we want this code to belong to helloworld.progopedia.com module. Then it has to be placed in a file /source/com/progopedia/helloworld.ceylon (the path is relative to the main directory of the program). Besides, a file named /source/com/progopedia/module.ceylon has to contain module description, for example, this one:

Module module {
 name = 'com.progopedia.helloworld';
 version = '1.0.0';
 by = {"Mariia Mykhailova"};
 dependencies = {};
 doc = "Hello, World!";
 license = 'Public domain';
}

Once the files are filled out, the program can be compiled with command ceylonc com.progopedia.helloworld and executed with ceylon com.progopedia.helloworld/1.0.0 (noting the version explicitly is a must).

void run() {
    print("Hello, World!");
}

Example for versions Mercury 10.04

 :- module hello.
 :- interface.
 :- import_module io.
 :- pred main(io::di, io::uo) is det.

 :- implementation.
 main(!IO) :-
 	io.write_string("Hello, World!\n", !IO).

Example for versions loljs 1.1

HAI
  CAN HAS STDIO?
  VISIBLE "Hello, World!"
KTHXBYE

Example for versions H6070 B

An example from “A tutorial introduction to the language B” by Kernigan. Shows usage and initialization of global variables.

main( ) {
  extrn a, b, c;
  putchar(a);
  putchar(b);
  putchar(c);
  putchar('!*n');
}

a 'Hell';
b 'o, W';
c 'orld';

Example for versions Mathics 0.5, Wolfram Mathematica 8.0.4

Evaluation of this expression results in a string “Hello, World!” itself; since it is not followed by a semicolon, it will be printed as a separate Out, which is not always convenient.

"Hello, World!"

Example for versions Mathics 0.5, Wolfram Mathematica 8.0.4

Print function outputs its argument(s) to the main output stream. Streams can nest, so for convenience it’s recommended to to use a single stream for all output throughout the program.

Print["Hello, World!"];

Example for versions CPL

Generally Write outputs a list of elements, but in this case it prints a string literal.

Write("Hello, World!")

Example for versions Dyalog APL 13.1

'Hello, World!'

Example for versions A+ 4.18

String literals can be enclosed both in single quotes and in double quotes.

"Hello, World!"
'Hello, World!'

Example for versions Nimrod 0.8.8

echo "Hello, World!"

Example for versions VBScript 5.7, VBScript 5.8

The program outputs the message into console, and thus should be executed using cscript.exe.

WScript.Echo("Hello, World!")

Example for versions A++ Interpreter

The program output looks as follows:

-->Hello, World!  
void
(print "Hello, World!")

Example for versions GAP 4.4.12

To run as a script use gap -q < filename.gap

Print("Hello, Wolrd!\n");

Example for versions Dart 1.1.1

The “fat arrow” ( => expr; ) syntax is a shorthand for { return expr; }.

main() => print("Hello, World!");

Example for versions Picat 0.7

main =>
     print("Hello, World!\n").

Example for versions Picat 0.7

main =>
     println("Hello, World!").

Example for versions Snap! 4.0

Unlike Scratch, in Snap! each script must start with a “hat” block defining the condition upon which the script runs. “When green flag clicked” hat runs the script upon presentation start.

Hello, World! in Snap!
Hello, World! in Snap!

Example for versions Windows PowerShell 5.0

Echo "Hello, World!"

Example for versions W 1.1.0

REF "Runtime.IO"
Type("Hello, World!")

Example for versions NetChains 2

!Console::WriteLine('"Hello, World"')