List of Hello world program examples

From Wikipedia, the free encyclopedia
  (Redirected from Hello world program examples)
Jump to: navigation, search

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]

Main article: ABAP
REPORT ZHELLOWORLD.
WRITE 'Hello, world!'.

ActionScript 3.0[edit]

Main article: ActionScript
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]

Main article: Adventure Game Studio
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]

Main article: ALGOL
BEGIN
   DISPLAY ("Hello, world!");
END.

ALGOL 68[edit]

Main article: ALGOL 68
print("Hello, world!")

Amiga E[edit]

Main article: Amiga E
PROC main()
   WriteF('Hello, world!')
ENDPROC

APL[edit]

'Hello, world!'

AppleScript[edit]

Main article: AppleScript
display dialog "Hello, world!"

or if you want a button to trigger the dialog:

on helloWorld()
  display dialog "Hello, world!"
end helloWorld
 
helloWorld()

AS/400 Control Language[edit]

PGM
SNDPGMMSG MSG('Hello, world!')
ENDPGM

ASP.Net[edit]

Main article: ASP.Net
Response.Write("Hello World!");

Assembly language — MOS Technology 6502, Apple II (II+, IIe, IIC)[edit]

Main article: Assembly language
; 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

[1]

Assembly language — MOS Technology 6502, Acorn MOS[edit]

Main article: Assembly language
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]

Main article: Assembly language
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]

Main article: Assembly language
 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 — Motorola 68000, Atari TOS[edit]

Main article: Assembly language
; Assmebled with Devpac and VASM
; VASM -devpac -m68000 -no-opt -nosym -Ftos
 
;Cconws
	pea		Text(PC)
	move.w	#9,-(SP)
	trap	#1
	addq.l	#6,SP
 
;Pterm0
	clr.w	-(A7)
	trap	#1
 
Text
	dc.b	"Hello, world!",0

Assembly language — x86 DOS[edit]

Main article: Assembly language
; 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]

Main article: Assembly language
; 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]

Main article: Assembly language
# The helloWorld.s file contains the source for a linux-x86_64 hello world
# example using the new 64 bit system call ABI.
# 2014 John Wassilak
#
# Compile with :
#     as -o helloWorld.o helloWorld.s
#     ld -e main -o helloWorld -s -Os helloWorld.o
.section .rodata                       # The rodata section contains the
                                       #     constants used by the program.
string: .ascii "Hello, world!\n"       # The string constant contains the
                                       #     string to be printed.
length: .quad . - string               # The length constant contains the
                                       #     length of the string constant.
.section .text                         # The text section contains the
                                       #     executable instructions of the
                                       #     program.
.globl main                            # Declare the main symbol as global so
                                       #     that the linker can see it.
main:                                  # The main symbol is the entry point of
                                       #     the program.
mov   $1, %rax                         # Move 1(sys_write) into rax.
mov   $1, %rdi                         # Move 1(fd stdOut) into rdi.
mov   $string, %rsi                    # Move the location of the string
                                       #     constant into rsi.
mov   length, %rdx                     # Move the length of the string
                                       #     constant into rdx.
syscall                                # Print the string constant to stdOut by
                                       #     making a system call.
                                       #     written = sys_write(
                                       #         stdOut, string, length
                                       #     )
mov   %rax, %rdi                       # Move the number of bytes written to
                                       #     rdi.
mov   $60, %rax                        # Move 60(sys_exit) into rax.
syscall                                # Terminate the process, returning the
                                       #     number of bytes written by
                                       #     sys_write as the exit status.
                                       #     sys_exit(written)

[2] [3]

Assembly language — x86-64 Unix-like operating systems, NASM syntax[edit]

Main article: Netwide Assembler
; MacOS X: /usr/local/bin/nasm -f macho64 *.s && ld -macosx_version_min 10.7 *.o
; Solaris/FreeBSD/DragonFly: nasm -f elf64 -D UNIX *.s && ld *.o
; NetBSD: nasm -f elf64 -D UNIX -D NetBSD *.s && ld *.o
; OpenBSD: nasm -f elf64 -D UNIX -D OpenBSD *.s && ld -static *.o
; OpenIndiana: nasm -f elf64 -D UNIX *.s && ld -m elf_x86_64 *.o
; Linux: nasm -f elf64 *.s && ld *.o
 
%ifdef  NetBSD
section .note.netbsd.ident
        dd      7,4,1
        db      "NetBSD",0,0
        dd      200000000       ; amd64 supported since 2.0
%endif
 
%ifdef  OpenBSD
section .note.openbsd.ident
        align   2
        dd      8,4,1
        db      "OpenBSD",0
        dd      0
        align   2
%endif
 
section .text
 
%ifidn __OUTPUT_FORMAT__, macho64       ; MacOS X
        %define SYS_exit        0x2000001
        %define SYS_write       0x2000004
 
        global  start
        start:
%elifidn __OUTPUT_FORMAT__, elf64
        %ifdef  UNIX            ; Solaris/OI/FreeBSD/NetBSD/OpenBSD/DragonFly
                %define SYS_exit        1
                %define SYS_write       4
        %else                   ; Linux
                %define SYS_exit        60
                %define SYS_write       1
        %endif
 
        global  _start
        _start:
%else
        %error  "Unsupported platform"
%endif
 
        mov     rax,SYS_write
        mov     rdi,1           ; stdout
        mov     rsi,msg
        mov     rdx,len
        syscall
        mov     rax,SYS_exit
        xor     rdi,rdi         ; exit code 0
        syscall
 
section .data
 
msg     db      "Hello, world!",10
len     equ     $-msg

Assembly language — Z80[edit]

Main article: Assembly language
 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 the calculator's rom to print text
      rst $28
     .dw $452E ; calls a function 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]

Main article: AutoHotkey
Msgbox, Hello, world!
Traytip,, Hello, world!

AutoIt[edit]

Main article: AutoIt
#include <MsgBoxConstants.au3>
 
Msgbox($MB_ICONINFORMATION, "", "Hello, world!")

AWK[edit]

Main article: AWK
BEGIN { print "Hello, world!" }

B[edit]

Backbone.js[edit]

Main article: Backbone.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>hello-backbonejs</title>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.11.0.js"></script>
<script src="https://raw.githubusercontent.com/douglascrockford/JSON-js/master/json2.js"></script>
<script src="http://underscorejs.org/underscore.js"></script>
<script src="http://backbonejs.org/backbone.js"></script>
 
<script>
(function($){
  var MyView = Backbone.View.extend({
     initialize: function(){
       this.render();
    },
    render: function(){
      $('body').append("<h4>hello world</h4>");
    }
  });
  var myView = new MyView();
  var myView = new MyView();
})(jQuery);
</script>
<div>test</div>
</body>
</html>

BASH[edit]

Main article: Bash (Unix shell)
echo "Hello World"

BASIC[edit]

Main article: BASIC
PRINT "Hello, world!"

Batch File[edit]

Main article: Batch file
@echo Hello, world!

BCPL[edit]

Main article: BCPL
GET "LIBHDR"

LET START() BE
$(
  WRITES("Hello, world!*N")
$)

BennuGD[edit]

Main article: BennuGD
import "mod_say"
 
Process Main()
Begin
    say("Hello World!");
End

Befunge[edit]

Main article: Befunge
>25*"!dlrow ,olleH":v
                 v:,_@
                 >  ^

brainfuck[edit]

Main article: brainfuck
+++++ +++++             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)
{
    puts("Hello, world!");
}

C++[edit]

Main article: C++ § Language
#include <iostream>
 
int main()
{
    std::cout << "Hello, world!\n";
}

[4][5]

C++/CLI[edit]

Main article: C++/CLI
using namespace System;
 
int main(array<System::String ^> ^args)
{
    Console::WriteLine(L"Hello World");
    return 0;
}

C++/CX[edit]

Main article: C++/CX
#include "stdafx.h"
#using <Platform.winmd>
using namespace Platform;
 
[MTAThread]
int main(Array<String^>^ args)
{
    String^ message("Hello World!");
    Details::Console::WriteLine(message);}

C++/Qt[edit]

Main article: Qt
#include <QCoreApplication>
#include <QDebug>
 
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
 
    qDebug() << "Hello World!";
 
     return a.exec();
}

C#[edit]

In a console or terminal:

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

Via a GUI message box:

using System.Windows.Forms;
class Program
{
    public static void Main(string[] args)
    {
        MessageBox.Show("Hello, World!");
    }
}

Casio BASIC[edit]

Main article: Casio BASIC
"HELLO, WORLD!"

Ceylon[edit]

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

Clipper[edit]

? "Hello World"

Clojure[edit]

Main article: Clojure

Console version:

(println "Hello, world!")

GUI version:

(javax.swing.JOptionPane/showMessageDialog nil "Hello, world!")

COBOL[edit]

Main article: COBOL
       IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO-WORLD.
       PROCEDURE DIVISION.
           DISPLAY 'Hello, world!'.
           STOP RUN.

CoffeeScript[edit]

Main article: CoffeeScript

To display an alert dialog box:

alert 'Hello, world!'

To write to a console or debugging log:

console.log 'Hello, world!'

COMAL-80[edit]

Main article: COMAL
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>

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]

program HelloWorld;
begin
  Writeln('Hello, world!');
end.

E[edit]

E[edit]

println("Hello, world!")

Eiffel[edit]

class
    HELLO_WORLD
create
    make
feature
    make
        do
            print ("Hello, world!%N")
        end
end


(message "Hello, World!") </syntaxhighlight>

Euphoria[edit]

puts(1,"Hello World")

Erlang[edit]

io:format("~s~n", ["Hello, world!"])

Ezhil[edit]

பதிப்பி "உலகே வணக்கம்"

F[edit]

F#[edit]

printfn "Hello, world!"

Falcon[edit]

 printl( "Hello, world!" )

or

 > "Hello, world!"

Filemaker[edit]

Main article: Filemaker
#Hello World using Filemaker Pro
Show Custom Dialog ["Hello, world" ; "Hello, world"]

Flowgorithm[edit]

Flowgorithm Hello World.png

Forth[edit]

." Hello, world! "

Fortran[edit]

Main article: Fortran

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

FreeBASIC[edit]

Main article: FreeBASIC
print "Hello, world!"

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]

Main article: Haxe
class Test {
    static function main() {
        trace("Hello World !");
    }
}

HTML[edit]

Main article: HTML
<html>
<body>
 
<h1>Hello World!</h1>
 
</body>
</html>

HOP[edit]

(define-service (hello-world)
  (<HTML>
     (<HEAD>
	(<TITLE> "Hello, world!"))
     (<BODY>
	"Hello, world!")))

I[edit]

IDL[edit]

print, "Hello, world!"
end

INTERCAL[edit]

Main article: INTERCAL
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]

Main article: ISLISP
(format (standard-output) "Hello, world!")

inform7[edit]

Inform 7 when play begins, say "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!");
	}
}

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!");
	}
}

JavaScript[edit]

Main article: JavaScript

To write to a console or 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]

Leet[edit]

Gr34t l33tN3$$?
M3h...
iT 41n't s0 7rIckY.
 
l33t sP33k is U8er keWl 4nD eA5y wehn u 7hink 1t tHr0uGh.
1f u w4nn4be UB3R-l33t u d3f1n1t3lY w4nt in 0n a b4d4sS h4xX0r1ng s1tE!!! ;p
w4r3Z c0ll3cT10n2 r 7eh l3Et3r!
 
Qu4k3 cL4nS r 7eh bE5t tH1ng 1n teh 3nTIr3 w0rlD!!!
g4m3s wh3r3 u g3t to 5h00t ppl r 70tAl1_y w1cK1d!!
I'M teh fr4GM4stEr aN I'lL t0t41_1Ly wIpE teh phr34k1ng fL00r ***j3d1 5tYlE*** wItH y0uR h1dE!!!! L0L0L0L!
t3lEphR4gG1nG l4m3rs wit mY m8tes r34lLy k1kK$ A$$
 
l33t hAxX0r$ CrE4t3 u8er- k3wL 5tUff lIkE n34t pR0gR4mm1nG lAnguidGe$...
s0m3tIm3$ teh l4nGu4gES l00k jUst l1k3 rE41_ 0neS 7o mAkE ppl Th1nk th3y'r3 ju$t n0rMal lEE7 5pEEk but th3y're 5ecRetLy c0dE!!!!
n080DY unDer5tAnD$ l33t SpEaK 4p4rT fr0m j3d1!!!!!
50mE kId 0n A me$$4gEb04rD m1ghT 8E a r0xX0r1nG hAxX0r wH0 w4nT2 t0 bR34k 5tuFf, 0r mAyb3 ju5t sh0w 7eh wAy5 l33t ppl cAn 8E m0re lIkE y0d4!!! hE i5 teh u8ER!!!!
1t m1ght 8E 5omE v1rus 0r a Pl4ySt4tI0n ch34t c0dE.
1t 3v3n MiTe jUs7 s4y "H3LL0 W0RLD!!!" u ju5t cAn'T gu3s5.
tH3r3's n3v3r anY p0iNt l00KiNg sC3pT1c4l c0s th4t, be1_1Ev3 iT 0r n0t, 1s whAt th1s 1s!!!!!
 
5uxX0r5!!!L0L0L0L0L!!!!!!!

Linden Scripting Language[edit]

default
{
    state_entry()
    {
        llSay(0, "Hello, world!");
    }
}

Lisp[edit]

(princ "Hello, world!")

[edit]

print [Hello, world!]

LOLCODE[edit]

Main article: LOLCODE
HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE

Lua[edit]

print("Hello, world!")

M[edit]

M4[edit]

Hello, world!

Malbolge[edit]

Main article: Malbolge
('&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>}=<M:9wv6WsU2T|nm-,jcL(I&%$#"
`CB]V?Tx<uVtT`Rpo3NlF.Jh++FdbCBA@?]!~|4XzyTT43Qsqq(Lnmkj"Fhg${z@>

Mathematica[edit]

Main article: Mathematica
Print["Hello, world!"]

Maple[edit]

Main article: Maple (software)
print(`Hello, world!`);

MATLAB[edit]

Main article: MATLAB
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!

Modula-2[edit]

Main article: Modula-2
MODULE Hello;
FROM STextIO IMPORT WriteString;
BEGIN
  WriteString("Hello World!");
END Hello.

MUMPS[edit]

Main article: MUMPS
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]

Main article: Objective-C
#import <stdio.h>
#import <Foundation/Foundation.h>
 
int main(void)
{
    NSLog(@"Hello, world!\n");
    return 0;
}

Otherwise (by gcc on pre-OpenStep or 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]

Main article: OCaml
 print_endline "Hello, world!"

Opa[edit]

A "hello world" web server:

Server.start(Server.http,
    { title: "Hello, world!",
      page: function() { <>Hello, world!</> } })

OpenEdge Advanced Business Language (PROGRESS)[edit]

 DISPLAY "Hello World!".

Oriel[edit]

MessageBox(OK, 1, INFORMATION, "Hello, world!", "Oriel Says Hello", ResponseValue)

Oz[edit]

{Show 'Hello World'}

P[edit]

Pascal[edit]

program HelloWorld;
 
begin
  WriteLn('Hello, world!');
end.

Pawn[edit]

main()
{
	print("Hello, world!");
}

Perl 5[edit]

Main article: Perl
print "Hello, world!\n";

Or

use v5.10;
say 'Hello, world!';

PHP[edit]

Main article: PHP
<?php echo 'Hello, world!'; ?>

or

<?php print ('Hello, world!'); ?>

or

<?= 'Hello, world!'; ?>

or

Hello world

This works because php will echo by default

PL/SQL[edit]

Main article: PL/SQL
SET SERVEROUTPUT ON;
BEGIN
    DBMS_OUTPUT.PUT_LINE('Hello, world!');
END;

PostScript[edit]

Main article: PostScript
%!PS
/Courier 72 selectfont
20 20 moveto
(Hello World!) show
showpage

PowerShell[edit]

Main article: Windows PowerShell
'Hello, world!'

Processing[edit]

void setup(){
  println("Hello, world!");
}

Prolog[edit]

Main article: Prolog
main :- write('Hello, world!'), nl.

Python[edit]

Python 2:

print "Hello, world!"

Python 3:

print("Hello, world!")

Python IDLE:

"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!

Rebol[edit]

Main article: Rebol
print "Hello, world!"

Red[edit]

Red [
    Title: "Simple hello world script"
]
 
print "Hello World!"

REXX[edit]

Main article: REXX
say Hello, world!

RPL[edit]

<< "Hello, world!" MSGBOX >>

RPG (free-format)[edit]

Main article: IBM RPG
/free
dsply 'Hello, world!';
*inlr = *on;
/end-free

RTL/2[edit]

Main article: RTL/2
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!")
}

or

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

Scheme[edit]

(display "Hello, world!")

Scratch[edit]

Hello, World! in Scratch


Sed[edit]

Main article: Sed
# convert input text stream to "Hello, world!"
s/.*/Hello, world!/
q

Shell[edit]

Main article: Bourne shell
echo Hello, world!

SimpleC[edit]

Main article: SimpleC
OUT<"Hello, world!"

Simula[edit]

Main article: Simula
Begin
   OutText ("Hello, world!");
   Outimage;
End;

Small Basic[edit]

Main article: Small Basic
TextWindow.WriteLine("Hello, World!")

Smalltalk[edit]

Main article: Smalltalk
Transcript show: 'Hello, world!'.

SmileBASIC[edit]

Main article: SmallBASIC
?"Hello, world!

or

PRINT "Hello, world!"

SNOBOL[edit]

Main article: SNOBOL
  OUTPUT = 'Hello, world!'
END

Speakeasy[edit]

As an interactive statement :

"Hello, world!"

As a program :

program hello
   "Hello, world!"
end

SQL[edit]

Main article: SQL
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]

Main article: Stata
display "Hello, world!"

Swift[edit]

println("Hello, world!")

T[edit]

Tcl[edit]

Main article: Tcl
puts "Hello, world!"

TI-BASIC[edit]

Main article: TI-BASIC
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!"

TypeScript[edit]

class Greeter {
    constructor(public greeting: string) { }
    greet() {
        return "<h1>" + this.greeting + "</h1>";
    }
};
var greeter = new Greeter("Hello, world!");
var str = greeter.greet();
document.body.innerHTML = str;

U[edit]

UnrealScript[edit]

Main article: UnrealScript
Log("Hello, world!");

V[edit]

Vala[edit]

void main ()
{
    print ("Hello, world!\n");
}

VBScript[edit]

MsgBox "Hello, World!"

Verilog[edit]

Main article: Verilog
module hello();
 
initial begin
 
	$display("Hello, world!");
        $finish;
end
 
endmodule

VHDL[edit]

Main article: VHDL
entity hello_world is
end entity;
 
architecture behavior of hello_world is
begin
  PROCESS
  begin
    report "Hello, world!";
  end PROCESS;
end architecture;

Visual Basic[edit]

Main article: Visual Basic
 MsgBox "Hello, world!"

Visual Basic .NET[edit]

Main article: Visual Basic .NET

In a console or terminal window:

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

In a message box:

Module Module1
    Sub Main()
         MsgBox("Hello, world!")
    End Sub
End Module

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]

Zebra[edit]

^XA^LH30,30
^FO20,10^ADN,90,50^AD^FDHello, World!^FS
^XZ

References[edit]

  1. ^ "Assembler". NTECS Consulting. Archived from the original on 6 January 2014. Retrieved 30 March 2014. 
  2. ^ "x86-64 assembly on Linux - syscalls". callumscode. Archived from the original on 29 August 2013. Retrieved 20 May 2014. 
  3. ^ "Linux System Call Table for x86_64". blog.rchapman. Archived from the original on 13 November 2013. Retrieved 20 May 2014. 
  4. ^ Stroustrup, Bjarne (2000). The C++ Programming Language (Special ed.). Addison-Wesley. p. 46. ISBN 0-201-70073-5. 
  5. ^ Stroustrup, Bjarne. "Open issues for The C++ Programming Language (3rd Edition)". This code is copied directly from Bjarne Stroustrup's errata page (p. 633). He addresses the use of '\n' rather than std::endl. Also see Can I write "void main()"? for an explanation of the implicit return 0; in the main function. This implicit return is not available in other functions. 

External links[edit]