List of Hello world program examples
The Hello world program is a simple computer program that prints (or displays) the string "Hello, world!" or some variant thereof. It is typically one of the simplest programs possible in almost all computer languages, and often used as first program to demonstrate a programming language. As such it can be used to quickly compare syntax differences between various programming languages. The following is a list of canonical hello world programs in 109 programming languages.
A[edit]
ABAP[edit]
REPORT ZHELLOWORLD. WRITE 'Hello, world!'.
ActionScript 3.0[edit]
trace ("Hello, world!");
or (if you want it to show on the stage)
package com.example { import flash.text.TextField; import flash.display.Sprite; public class Greeter extends Sprite { public function Greeter() { var txtHello:TextField = new TextField(); txtHello.text = "Hello, world!"; addChild(txtHello); } } }
Ada[edit]
with Ada.Text_IO; procedure Hello_World is use Ada.Text_IO; begin Put_Line("Hello, world!"); end;
Adventure Game Studio Script[edit]
Display("Hello, world!");
or (if you want to draw it to the background surface)
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground(); surface.DrawString(0, 100, Game.NormalFont, "Hello, world!"); surface.Release();
ALGOL[edit]
BEGIN DISPLAY ("Hello, world!"); END.
ALGOL 68[edit]
print("Hello, world!")
Amiga E[edit]
PROC main() WriteF('Hello, world!') ENDPROC
APL[edit]
'Hello, world!'
AppleScript[edit]
display dialog "Hello, world!"
or if you want a button to trigger the dialog:
on helloWorld() display dialog "Hello, world!" end helloWorld helloWorld()
Assembly language — MOS Technology 6502, Apple II (II+, IIe, IIC)[edit]
; Uses S-C Assembler variant. ; .or is origin ; .as is ASCII String ; .hs is Hex String .or $300 main ldy #$00 .1 lda str,y beq .2 jsr $fded ; ROM routine, COUT, y is preserved iny bne .1 .2 rts str .as "HELLO WORLD" .hs 0D00
Assembly language — MOS Technology 6502, Acorn MOS[edit]
100 REM Hello World using a mix of BBC Basic and 6502 assembler 110 $&A200 = "!dlrow olleH" 115 code% = &A100 120 str = &A200 130 oswrch = &FFEE 140 FOR pass%=0 TO 3 STEP 3 150 P% = code% 160 [ 170 OPT pass% 180 .START LDY 11 190 CLC 200 .LOOP 210 LDA str,Y 220 JSR oswrch 230 DEY 240 BCC LOOP 250 LDA 13 260 JSR oswrch 270 RTS 280 ] 290 NEXT 300 CALL code%
Assembly language — ARM, BBC BASIC inline assembler[edit]
1000 REM Hello World using a mix of BBC Basic and ARM assembler 1010 DIM org 100 1020 OS_Write0 = &2 1030 FOR pass=0 TO 3 STEP 3 1040 PROCasm(pass,org) 1050 NEXT pass 1060 CALL org 1070 END 1080 2000 DEF PROCasm(pass,org) 2010 P%=org 2020 [ OPT pass 2030 ADR R0, message 2040 SWI OS_Write0 2050 MOV PC, R14 2060 .message 2070 EQUS "Hello, World!" + CHR$(0) 2080 ALIGN 2090 ] 2100 ENDPROC
Assembly language — MOS Technology 6502, CBM KERNAL[edit]
A_CR = $0D ;carriage return BSOUT = $FFD2 ;kernel ROM sub, write to current output device ; LDX #$00 ;starting index in .X register ; LOOP LDA MSG,X ;read message text BEQ LOOPEND ;end of text ; JSR BSOUT ;output char INX BNE LOOP ;repeat ; LOOPEND RTS ;return from subroutine ; MSG .BYT 'Hello, world!',A_CR,$00
Assembly language — x86 DOS[edit]
; The output file is 22 bytes. ; 14 bytes are taken by "Hello, world!$ ; ; Written by Stewart Moss - May 2006 ; This is a .COM file so the CS and DS are in the same segment ; ; I assembled and linked using TASM ; ; tasm /m3 /zn /q hello.asm ; tlink /t hello.obj .model tiny .code org 100h main proc mov ah,9 ; Display String Service mov dx,offset hello_message ; Offset of message (Segment DS is the right segment in .COM files) int 21h ; call DOS int 21h service to display message at ptr ds:dx retn ; returns to address 0000 off the stack ; which points to bytes which make int 20h (exit program) hello_message db 'Hello, world!$' main endp end main
Assembly language — x86 Windows[edit]
; This program displays "Hello, World!" in a windows messagebox and then quits. ; ; Written by Stewart Moss - May 2006 ; ; Assemble using TASM 5.0 and TLINK32 ; ; The output EXE is standard 4096 bytes long. ; It is possible to produce really small windows PE exe files, but that ; is outside of the scope of this demo. .486p .model flat,STDCALL include win32.inc extrn MessageBoxA:PROC extrn ExitProcess:PROC .data HelloWorld db "Hello, world!",0 msgTitle db "Hello world program",0 .code Start: push MB_ICONQUESTION + MB_APPLMODAL + MB_OK push offset msgTitle push offset HelloWorld push 0 call MessageBoxA push 0 call ExitProcess ends end Start
Assembly language — x86-64 Linux, AT&T syntax[edit]
.section .rodata string: .ascii "Hello, world!\n" length: .quad . -string #Dot = 'here' .section .text .globl _start #Make entry point visible to linker _start: movq $4, %rax #4=write movq $1, %rbx #1=stdout movq $string, %rcx movq length, %rdx int $0x80 #Call Operating System movq %rax, %rbx #Make program return syscall exit status movq $1, %rax #1=exit int $0x80 #Call System Again
Assembly language — Z80[edit]
CR EQU $0D ; carriage return PROUT EQU $xxxx ; character output routine ; LD HL,MSG ; Point to message ; PRLOOP LD A,(HL) ; read byte from message AND A ; set zero flag from byte read RET Z ; end of text if zero CALL PROUT ; output char INC HL ; point to next char JR PRLOOP ; repeat ; MSG DB "Hello, world!",CR,0 ;
For TI 83, TI 83+, TI 83+SE, TI 84+, and TI 84+SE calculators:
.NOLIST #include "ti83plus.inc" .LIST .org $9D93 .db $BB,$6D ld a,0 ; load the value 0 to register a, the ''accumulator'' ld ($844C),a ; assign the contents of register a to memory address (CURCOL) in the RAM ld ($844B),a ; assign the contents of register a to memory address (CURROW) in the RAM ld hl,text ; load the data in label "text" to register hl rst $28 .dw $450A ; calls a function in ti83plus.inc to print text rst $28 .dw $452E ; calls a function in ti83plus.inc to insert a lnbreak (for legibility) ret ; returns from the program to the calc's OS text: .db "Hello, World",0 .end end
And in pure hex:
219F9D EF0A45 EF2E45 C9 48692100
AutoHotkey[edit]
Msgbox, Hello, world!
Traytip,, Hello, world!
AutoIt[edit]
Msgbox(64, "", "Hello, world!")
AWK[edit]
BEGIN { print "Hello, world!" }
B[edit]
BASIC[edit]
PRINT "Hello, world!"
Batch File[edit]
@echo Hello, world!
BCPL[edit]
GET "LIBHDR" LET START() BE $( WRITES("Hello, world!*N") $)
BennuGD[edit]
import "mod_say" Process Main() Begin say("Hello World!"); End
Befunge[edit]
>25*"!dlrow ,olleH":v v:,_@ > ^
brainfuck[edit]
+++++ +++++ initialize counter (cell #0) to 10 [ use loop to set the next four cells to 70/100/30/10/40 > +++++ ++ add 7 to cell #1 > +++++ +++++ add 10 to cell #2 > +++ add 3 to cell #3 > + add 1 to cell #4 > ++++ add 4 to cell #5 <<<<< - decrement counter (cell #0) ] > ++ . print 'H' > + . print 'e' +++++ ++ . print 'l' . print 'l' +++ . print 'o' >>> ++++ . print ',' << ++ . print ' ' < +++++ +++ . print 'w' ----- --- . print 'o' +++ . print 'r' ----- - . print 'l' ----- --- . print 'd' > + . print '!' > . print '\n'
C[edit]
C[edit]
#include <stdio.h> int main(void) { printf("Hello, world!\n"); return 0; }
C++[edit]
#include <iostream> int main() { std::cout << "Hello, world!" << std::endl; return 0; }
or
#include <iostream> int main() { std::cout << "Hello, world!" << std::endl; }
or
#include <iostream> using namespace std; void main() { cout << "Hello, world!" << endl; }
C++/CLI[edit]
using namespace System; int main(array<System::String ^> ^args) { Console::WriteLine(L"Hello World"); return 0; }
C++/CX[edit]
#include "stdafx.h" #using <Platform.winmd> using namespace Platform; [MTAThread] int main(Array<String^>^ args) { String^ message("Hello World!"); Details::Console::WriteLine(message);}
C#[edit]
using System; class Program { public static void Main() { Console.WriteLine("Hello, world!"); } }
Casio BASIC[edit]
"HELLO, WORLD!"
Ceylon[edit]
void hello() { print("Hello, World!"); }
CoffeeScript[edit]
To display an alert dialog box:
alert 'Hello, world!'
To write to a console/debugging log:
console.log 'Hello, world!'
COMAL-80[edit]
10 PRINT "Hello, world!"
Common Intermediate Language[edit]
.assembly Hello {} .assembly extern mscorlib {} .method static void Main() { .entrypoint .maxstack 1 ldstr "Hello, world!" call void [mscorlib]System.Console::WriteLine(string) call string[mscorlib]System.Console::ReadKey(true) pop ret }
ColdFusion Markup Language (CFML)[edit]
CF Script:
<cfscript> variables.greeting = "Hello, world!"; WriteOutput( variables.greeting ); </cfscript>
CFML Tags:
<cfset variables.greeting = "Hello, world!"> <cfoutput>#variables.greeting#</cfoutput>
Clojure[edit]
Console version:
(println "Hello, world!")
GUI version:
(javax.swing.JOptionPane/showMessageDialog nil "Hello, world!")
COBOL[edit]
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. PROCEDURE DIVISION. DISPLAY 'Hello, world!'. STOP RUN.
D[edit]
D[edit]
import std.stdio; void main() { writeln("Hello, world!"); }
Dart[edit]
main() { print('Hello, world!'); }
DCL[edit]
WRITE SYS$OUTPUT "Hello, world!"
Delphi[edit]
{$APPTYPE CONSOLE} begin Writeln('Hello, world!'); end.
E[edit]
E[edit]
This section does not cite any references or sources. (March 2014) |
<' extend sys { run() is also { out("Hello, World!"); }; }; '>
Emacs Lisp[edit]
(message "Hello, World!")
Euphoria[edit]
puts(1,"Hello World")
Erlang[edit]
io:format("~s~n", ["Hello, world!"])
F[edit]
F#[edit]
printfn "Hello, world!"
Falcon[edit]
printl( "Hello, world!" )
or
> "Hello, world!"
Forth[edit]
." Hello, world! "
Fortran[edit]
Fortran 90 and later:
program hello write(*,*) 'Hello, world!' end program hello
OR
program hello print *, 'Hello, world!' end program hello
FORTRAN 77 and prior; also accepted in Fortran 90 and later:
PROGRAM HELLO WRITE(*,*) 'Hello, world!' END
OR
PROGRAM HELLO PRINT *, 'Hello, world!' END
Frost[edit]
import "io.frost"; main:args { [print string:"Hello, world!\n" format:{}]; }
G[edit]
Go[edit]
package main import "fmt" func main() { fmt.Println("Hello, world!") }
Groovy[edit]
println "Hello, world!"
H[edit]
Haskell[edit]
main = putStrLn "Hello, world!"
Haxe[edit]
class Main { static function main() { trace("Hello, world!"); } }
HOP[edit]
(define-service (hello-world) (<HTML> (<HEAD> (<TITLE> "Hello, world!")) (<BODY> "Hello, world!")))
I[edit]
IDL[edit]
print, "Hello, world!"
end
INTERCAL[edit]
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 DO ,1 SUB #7 <- #48 PLEASE DO ,1 SUB #8 <- #22 DO ,1 SUB #9 <- #248 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
Io[edit]
"Hello, world!" println
ISLISP[edit]
(format (standard-output) "Hello, world!")
J[edit]
J[edit]
'Hello, world!'
Java[edit]
In console:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } }
or in window with Swing:
import javax.swing.JFrame; //Importing class JFrame import javax.swing.JLabel; //Importing class JLabel public class HelloWorld { public static void main(String[] args) { JFrame frame = new JFrame(); //Creating frame frame.setTitle("Hi!"); //Setting title frame frame.add(new JLabel("Hello, world!"));//Adding text to frame frame.pack(); //Setting size to smallest frame.setLocationRelativeTo(null); //Centering frame frame.setVisible(true); //Showing frame } }
or in dialog:
import javax.swing.JOptionPane; public class HelloWorld { public static void main(String[] args) { JOptionPane.showMessageDialog(null, "Hello, world!"); } }
JavaScript[edit]
To write to a console/debugging log:
console.log('Hello, world!');
To display an alert dialog box:
alert('Hello, world!');
To write to an HTML document:
document.write('Hello, world!');
Using Mozilla's Rhino:
print('Hello, world!');
Julia[edit]
println("Hello world!")
L[edit]
Linden Scripting Language[edit]
default { state_entry() { llSay(0, "Hello, world!"); } }
Lisp[edit]
(princ "Hello, world!")
Logo[edit]
print [Hello, world!]
LOLCODE[edit]
HAI CAN HAS STDIO? VISIBLE "HAI WORLD!" KTHXBYE
Lua[edit]
print("Hello, world!")
M[edit]
M4[edit]
Hello, world!
Malbolge[edit]
('&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>}=<M:9wv6WsU2T|nm-,jcL(I&%$#" `CB]V?Tx<uVtT`Rpo3NlF.Jh++FdbCBA@?]!~|4XzyTT43Qsqq(Lnmkj"Fhg${z@>
Mathematica[edit]
Print["Hello, world!"]
Maple[edit]
print(`Hello, world!`);
MATLAB[edit]
disp('Hello, world!')
Miranda[edit]
mira helloWorld.m || Start the editor /edit || Type the following text output = "Hello, world!\n" || Save and quit the Editor e.g. <Esc>:x || then enter at the "Miranda" prompt: output /quit
mIRC Script[edit]
echo -a Hello, world!
MUMPS[edit]
w "Hello, world!"
O[edit]
Oberon[edit]
MODULE Hello; IMPORT Out; BEGIN Out.String("Hello, world!"); Out.Ln END Hello.
Obix[edit]
system.console.write_line ( "Hello, world!" )
Objective-C[edit]
#import <stdio.h> int main(void) { NSLog(@"Hello, world!\n"); return 0; }
Otherwise (by gcc on pre-OpenStep/Apple Object based runtime):
#import <stdio.h> #import <objc/Object.h> @interface Hello: Object - (void) say; @end @implementation Hello - (void) say { printf("Hello, world!\n"); } @end int main() { Hello *hello = [Hello new]; [hello say]; [hello free]; return 0; }
Pre-Modern (post-1994 OpenStep based Foundation APIs:
@interface Hello:NSObject - (void) say; @end @implementation Hello - (void) say { NSLog(@"Hello, world!"); } @end int main(int argc, char *argv[]) { NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init]; Hello *hello = [Hello new]; [hello say]; [hello release]; [p release]; return 0; }
Modern (llvm, ARC memory management):
@interface Hello:NSObject - (void) say; @end @implementation Hello - (void) say { NSLog(@"Hello, world!"); } @end int main(int argc, char *argv[]) { @autoreleasepool {; [[Hello new] say]; } return 0; }
OCaml[edit]
print_endline "Hello, world!"
Opa[edit]
A "hello world" web server:
Server.start(Server.http, { title: "Hello, world!", page: function() { <>Hello, world!</> } })
Oriel[edit]
MessageBox(OK, 1, INFORMATION, "Hello, world!", "Oriel Says Hello", ResponseValue)
Oz[edit]
{Show 'Hello World'}
P[edit]
Pascal[edit]
begin WriteLn('Hello, world!'); end.
Pawn[edit]
main() { print("Hello, world!"); }
Perl 5[edit]
print "Hello, world!";
Or
use v5.10; say 'Hello, world!';
PHP[edit]
<?php echo 'Hello, world!'; ?>
or
<?php print ('Hello, world!'); ?>
or
<?= 'Hello, world!'; ?>
PL/SQL[edit]
SET SERVEROUTPUT ON; BEGIN DBMS_OUTPUT.PUT_LINE('Hello, world!'); END;
PostScript[edit]
%!PS /Courier 72 selectfont 20 20 moveto (Hello World!) show showpage
PowerShell[edit]
"Hello, world!"
Processing[edit]
void setup(){ println("Hello, world!"); }
Prolog[edit]
main :- write('Hello, world!'), nl.
Python[edit]
Python 2:
print "Hello, world!"
Python 3:
print("Hello, world!")
R[edit]
R[edit]
cat('Hello, world!\n')
Racket[edit]
Trivial "hello world" program:
"Hello, world!"
Running this program produces "Hello, world!"
. More direct version:
#lang racket (display "Hello, world!")
A "hello world" web server using Racket's web-server/insta
language:
#lang web-server/insta (define (start request) (response/xexpr '(html (body "Hello, world"))))
In Scribble, Racket's documentation language:
Hello, world!
Red[edit]
Red [ Title: "Simple hello world script" ] print "Hello World!"
REXX[edit]
say Hello, world!
RPL[edit]
<< "Hello, world!" MSGBOX >>
RTL/2[edit]
TITLE Hello, world!; LET NL=10; EXT PROC(REF ARRAY BYTE) TWRT; ENT PROC INT RRJOB(); TWRT("Hello, world!#NL#"); RETURN(1); ENDPROC;
Ruby[edit]
puts "Hello, world!"
Rust[edit]
fn main() { println("Hello, world!"); }
S[edit]
Scala[edit]
object HelloWorld extends App { println("Hello, world!") }
Scheme[edit]
(display "Hello, world!")
Scratch[edit]
Sed[edit]
# convert input text stream to "Hello, world!" s/.*/Hello, world!/ q
Shell[edit]
echo Hello, world!
SimpleC[edit]
OUT<"Hello, world!"
Simula[edit]
Begin OutText ("Hello, world!"); Outimage; End;
Small Basic[edit]
TextWindow.WriteLine("Hello, World!")
Smalltalk[edit]
Transcript show: 'Hello, world!'.
SmileBASIC[edit]
?"Hello, world!
or
PRINT "Hello, world!"
SNOBOL[edit]
OUTPUT = 'Hello, world!' END
Speakeasy[edit]
As an interactive statement :
"Hello, world!"
As a program :
program hello "Hello, world!" end
SQL[edit]
SELECT 'Hello, world!' FROM DUMMY; -- DUMMY is a standard table in SAP HANA. SELECT 'Hello, world!' FROM DUAL; -- DUAL is a standard table in Oracle. SELECT 'Hello, world!' -- Works for SQL Server, Microsoft Access, PostgreSQL and MySQL.
Stata[edit]
display "Hello, world!"
Supernova[edit]
I want window and the window title is hello world.
T[edit]
Tcl[edit]
puts "Hello, world!"
Test-Driven Development with Java[edit]
Best-practice coding now involves writing the automated test before the code. The test is coded, the test may be demonstrated to fail, code is then added and corrected until the test passes.
import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import org.junit.Test; public class HelloWorldTest { @Test public void sayHelloWorld() { ByteArrayOutputStream outContent = captureSystemOut(); HelloWorld.say(); assertEquals("Hello, World!", outContent.toString()); } ByteArrayOutputStream captureSystemOut() { ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); return outContent; } }
Then the simplest program to make the test pass is written.
public class HelloWorld { public static void say() { System.out.print("Hello, World!"); } }
TI-BASIC[edit]
PROGRAM:HELLOWLD :ClrHome :Disp "HELLO, WORLD!"
or
PROGRAM:HELLOWLD :ClrDraw :Output(1,1,"HELLO, WORLD!") :DispGraph
For m68k calculators:
hellowld() :Prgm : ClrIO : Disp "HELLO, WORLD!" :EndPrgm
For Ti Nspire/CAS:
text"HELLO, WORLD!"
For Ti Nspire CX:
text "HELLO, WORLD!"
or
Disp "HELLO, WORLD"
Turing[edit]
put "Hello World!"
U[edit]
UnrealScript[edit]
Log("Hello, world!");
V[edit]
Vala[edit]
void main () { print ("Hello, world!\n"); }
VBScript[edit]
MsgBox "Hello World"
Verilog[edit]
module hello(); initial begin $display("Hello, world!"); $finish; end endmodule
VHDL[edit]
entity hello_world is end; architecture hello_world of hello_world is begin stimulus : PROCESS begin assert false report "Hello, world!" severity note; wait; end PROCESS stimulus; end hello_world;
Visual Basic[edit]
MsgBox "Hello, world!"
Visual Basic .NET[edit]
Module Module1 Sub Main() Console.WriteLine("Hello, world!") End Sub End Module 'non-console example: Class Form1 Public Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load() MsgBox("Hello, world!") End Sub End Class
W[edit]
Whitespace[edit]
This example shows the program with syntax highlighting. Without highlighting, it would appear to be blank space.
S S S T S S T S S S L T L S S S S S T T S S T S T L T L S S S S S T T S T T S S L T L S S S S S T T S T T S S L T L S S S S S T T S T T T T L T L S S S S S T S T T S S L T L S S S S S T S S S S S L T L S S S S S T T T S T T T L T L S S S S S T T S T T T T L T L S S S S S T T T S S T S L T L S S S S S T T S T T S S L T L S S S S S T T S S T S S L T L S S S S S T S S S S T L T L S S L L L
X[edit]
XSLT[edit]
Main article : XSLT
<?xml version='1.0' encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0' > <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>Hello World </xsl:text> </xsl:template> </xsl:stylesheet>
Z[edit]
Zimbu[edit]
FUNC Main() int IO.print("Hello, World!") RETURN 0 }
References[edit]
- ^ "Assembler". NTECS Consulting. Archived from the original on 6 January 2014. Retrieved 30 March 2014.
External links[edit]
![]() |
Wikibooks has a book on the topic of: Computer Programming/Hello world |
- Nodewave's computer language comparison, examples implementing the same loop algorithm I will not throw paper airplanes in class.
- Rosetta Code hello world listing, hello world examples for 230 programming languages.
- List of Hello World Programs in 300 Programming Languages - C and C++ Programming Resources, hello world examples for 300 programming languages.