Hello world/Text

From Rosetta Code
< Hello world(Redirected from Hello World)
Jump to: navigation, search
Hello world/Text
You are encouraged to solve this task according to the task description, using any language you may know.
Hello world/Text is part of Short Circuit's Console Program Basics selection.

In this User Output task, the goal is to display the string "Hello world!" [sic] on a text console.

See also


[edit] 0815


[edit] 360 Assembly

Using native SVC (Supervisor Call) to write to system console:

         LA    1,MSGAREA     Point Register 1 to message area
SVC 35 Invoke SVC 35 (Write to Operator)
BR 14 Return
MSGAREA EQU * Message Area
DC AL2(19) Total area length = 19 (Prefix length:4 + Data Length:15)
DC XL2'00' 2 bytes binary of zeros
DC C'Hello world!' Text to be written to system console

Using WTO Macro to generate SVC 35 and message area:

         WTO   'Hello world!'
BR 14 Return

[edit] 4DOS Batch

echo Hello world!

[edit] 6502 Assembly

; goodbyeworld.s for C= 8-bit machines, ca65 assembler format.
; String printing limited to strings of 256 characters or less.
a_cr = $0d ; Carriage return.
bsout = $ffd2 ; KERNAL ROM, output a character to current device.
ldx #0 ; Starting index 0 in X register.
lda text,x ; Get character from string.
beq done ; If we read a 0 we're done.
jsr bsout ; Output character.
inx ; Increment index to next character.
bne printnext ; Repeat if index doesn't overflow to 0.
rts ; Return from subroutine.
.byte "Hello world!", a_cr, 0

[edit] 6800 Assembly

        .cr  6800
.tf gbye6800.obj,AP1
.lf gbye6800
; Hello world! for the Motorola 6800  ;
; by barrym 2013-03-17  ;
; Prints the message "Hello world!" to an ascii  ;
; terminal (console) connected to a 1970s vintage  ;
; SWTPC 6800 system, which is the target device for ;
; this assembly.  ;
; Many thanks to:  ;
; swtpc.com for hosting Michael Holley's documents! ;
; sbprojects.com for a very nice assembler!  ;
; swtpcemu.com for a very capable emulator!  ;
; reg x is the string pointer  ;
; reg a holds the ascii char to be output  ;
outeee = $e1d1  ;ROM: console putchar routine
.or $0f00
main ldx #string  ;Point to the string
bra puts  ; and print it
outs jsr outeee  ;Emit a as ascii
inx  ;Advance the string pointer
puts ldaa ,x  ;Load a string character
bne outs  ;Print it if non-null
swi  ; else return to the monitor
string .as "Hello world!",#13,#10,#0

[edit] 8086 Assembly

TXT DB "Hello world!$"
MOV ds, ax
MOV ah, 09h ; prepare output function
MOV dx, OFFSET TXT ; set offset
INT 21h ; output string TXT
MOV AX, 4C00h ; go back to DOS
INT 21h

With A86 or NASM syntax:

  org 100h

  mov dx, msg
  mov ah, 9
  int 21h

  mov ax, 4c00h
  int 21h

  db "Hello world!$"

[edit] 8th

"Hello world!\n" . bye

[edit] ABAP

REPORT zgoodbyeworld.
WRITE 'Hello world!'.

[edit] ACL2

(cw "Hello world!~%")

[edit] ActionScript

trace("Hello world!");

[edit] Ada

Works with: GCC version 4.1.2
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
Put_Line ("Hello world!");
end Main;

[edit] Aime

o_text("Hello world!\n");


o_text("Hello world!\n");
return 0;

[edit] Algae

printf("Hello world!\n");

[edit] ALGOL 60

OUTSTRING(1,'('Hello world!')');

[edit] ALGOL 68

main: (
printf($"Hello world!"l$)

[edit] ALGOL W

write( "Hello world!" )

[edit] Alore

Print('Hello world!')

[edit] AmbientTalk

system.println("Hello world!")

[edit] AmigaE

PROC main()
WriteF('Hello world!\n')

[edit] AppleScript

To show in Script Editor Result pane:

"Hello world!"

To show in Script Editor Event Log pane:

log "Hello world!"

[edit] Applesoft BASIC

Important Note: Although Applesoft BASIC allowed the storage and output of mixed-case strings, the ability to enter mixed-case via the keyboard and to output mixed-case on the default display was not offered as standard equipment on the original Apple II/II+. Since Applesoft WAS the default programming language for the Apple II+, perhaps some flexibility in the task specification could be offered, for this and for other systems that lacked proper mixed-case I/O capabilities in at least one popular configuration.

 PRINT "Hello world!"

[edit] Apricot

(puts "Hello world!")

[edit] Arendelle

"Hello world!"

[edit] Argile

use std
print "Hello world!"

compile with: arc hello_world.arg -o hello_world.c && gcc -o hello_world hello_world.c

[edit] ARM Assembly

.global main
.asciz "Hello world!\n"
.align 4
ldr r0, =message
bl printf
mov r7, #1
swi 0

[edit] Asymptote

write('Hello world!');

[edit] ATS

implement main0 () = print "Hello world!\n"

[edit] AutoHotkey

script launched from windows explorer

FileAppend, Goodbye`, World!, CONOUT$
FileReadLine, _, CONIN$, 1

scripts run from shell [requires Windows XP or higher; older Versions of Windows don´t have the "AttachConsole" function]

DllCall("AttachConsole", "int", -1)
FileAppend, Goodbye`, World!, CONOUT$
SendInput Hello world!{!}

[edit] AutoIt

ConsoleWrite("Hello world!" & @CRLF)

[edit] AWK

BEGIN{print "Hello world!"}

"BEGIN" is a "special pattern" - code within "{}" is executed before the input file is read, even if there is no input. "END" is a similar pattern, for after completion of main processing.

print "Hello world!"

For a file containing data, the work can be done in the "body". The "//" is "match anything" so gets the first data, the "exit" halts processing the file (any "END" would then be executed).

// {
print "Hello world!"

For a "single record" file.

// {
print "Hello world!"

For a "single record" file containing - Hello world! -. The "default" action for a "pattern match" (the "/" and "/" define a "pattern" to match data) is to "print" the record.


[edit] Axe

Note that the i here is the imaginary i, not the lowercase letter i.

Disp "Hello world!",i

[edit] Babel

((main { "Hello world!" << }))

[edit] bash

echo "Hello world!"

[edit] BASIC

Works with: BASICA
Works with: Locomotive Basic
Works with: ZX Spectrum Basic
10 PRINT "Hello world!"
Works with: 7Basic
Works with: QBasic
PRINT "Hello world!"

[edit] BASIC256

PRINT "Hello world!"

[edit] Batch File

Under normal circumstances, when delayed expansion is disabled

echo Hello world!

If delayed expansion is enabled, then the ! must be escaped twice

setlocal enableDelayedExpansion
echo Hello world!^^!

[edit] Battlestar

const hello = "Hello world!\n"

[edit] BBC BASIC

      PRINT "Hello world!"

[edit] bc

"Hello world!

[edit] BCPL

GET "libhdr"
LET start() = VALOF
{ writef("Hello world!")

[edit] Befunge

52*"!dlroW ,eybdooG">:#,_@

[edit] Blast

# This will display a goodbye message on the terminal screen
display "Hello world!"
# This is the end of the script.

[edit] BML

display "Hello world!"

[edit] Boo

print "Hello world!"

[edit] Brace

#!/usr/bin/env bx
use b
say("Hello world!")

[edit] Bracmat

put$"Hello world!"

[edit] Brainf***

To print text, we need the ascii-value of each character to output.
So, we wanna make a series of round numbers going like:

10	close to newline and carriage return
30	close to ! and SPACE
40	close to COMMA
70	close to G
80	close to W
90	close to b
100	is d and close to e and l
110	close to o
120	close to y

forming all the letters we need if we just add up a bit

Commented version:

+++++ +++++		First cell 10 (its a counter and we will be "multiplying")
>+ 10 times 1 is 10
>+++ 10 times 3 is 30
>++++ etc etc
>+++++ ++
>+++++ +++
>+++++ ++++
>+++++ +++++
>+++++ ++++++
>+++++ +++++++
<<<<<<<<< - go back to counter and subtract 1
printing G
>>>> + .
o twice
>>>> + ..
< .
< +++++ +++ .
>>> + .
<< + .
<<<< ++++ .
< ++ .
>>> +++++ ++ .
>>> .
+++ .
< +++++ ++ .
----- --- .
<<<<< + .
< +++ . --- .



It can most likely be optimized, but this is a nice way to show how character printing works in Brainf*** :)

[edit] Brat

p "Hello world!"

[edit] Brlcad

The mged utility can output text to the terminal:

echo Hello world!

[edit] Burlesque

"Hello world!"sh

Although please note that sh actually does not print anything.

[edit] C

Works with: gcc version 4.0.1
#include <stdlib.h>
#include <stdio.h>
int main(void)
printf("Hello world!\n");


#include <stdlib.h>
#include <stdio.h>
int main(void)
puts("Hello world!");

Or, the eternal favourite :)

int main()
printf("\nHello world!");
return 0;

[edit] C#

Works with: Mono version 1.2
Works with: Visual C# version 2003
namespace HelloWorld
class Program
static void Main(string[] args)
System.Console.WriteLine("Hello world!");

[edit] C++

#include <iostream>
int main () {
std::cout << "Hello world!" << std::endl;

[edit] C++/CLI

using namespace System;
int main()
Console::WriteLine("Hello world!");

[edit] C1R

$ echo Hello_world/Text >hw.c1r
$ ./c1r hw.c1r
$ ./a.out
Hello world!

[edit] Cat

"Hello world!" writeln

[edit] Cduce

print "Hello world!";;

[edit] Chef

Goodbye World Souffle.
71 g green beans
111 cups oil
98 g butter
121 ml yogurt
101 eggs
44 g wheat flour
32 zucchinis
119 ml water
114 g red salmon
108 g lard
100 g dijon mustard
33 potatoes
Put potatoes into the mixing bowl.
Put dijon mustard into the mixing bowl.
Put lard into the mixing bowl.
Put red salmon into the mixing bowl.
Put oil into the mixing bowl.
Put water into the mixing bowl.
Put zucchinis into the mixing bowl.
Put wheat flour into the mixing bowl.
Put eggs into the mixing bowl.
Put yogurt into the mixing bowl.
Put butter into the mixing bowl.
Put dijon mustard into the mixing bowl.
Put oil into the mixing bowl.
Put oil into the mixing bowl.
Put green beans into the mixing bowl.
Liquefy contents of the mixing bowl.
Pour contents of the mixing bowl into the baking dish.
Serves 1.

[edit] ChucK

<<< "Hello world!">>>;

[edit] Clay

main() {
println("Hello world!");

[edit] Clean

Start = "Hello world!"

[edit] Clipper

? "Hello world!"

[edit] CLIPS

(printout t "Hello world!" crlf)

[edit] Clojure

(println "Hello world!")

[edit] CMake

message(STATUS "Hello world!")

This outputs

-- Hello world!

[edit] COBOL

Using fixed format.

Works with: OpenCOBOL
	program-id. hello.
procedure division.
display "Hello world!".
stop run.

[edit] Cobra

class Hello
def main
print 'Hello world!'

[edit] CoffeeScript

Works with: Node.js
console.log "Hello world!"
Works with: Rhino engine
print "Hello world!"

[edit] ColdFusion

<cfoutput>Hello world!</cfoutput>

[edit] Common Lisp

(format t "Hello world!~%")


(print "Hello world!")

[edit] Component Pascal

Out.String("Hello world!"); Out.Ln
END Hello.

Run command Hello.Do by commander.

[edit] Crack

import crack.io cout;
cout `Hello world!\n`;

[edit] Creative Basic

PRINT"Hello world!"
'This line could be left out.
PRINT:PRINT:PRINT"Press any key to end."
'Keep the console from closing right away so the text can be read.

[edit] Crystal

puts "Hello world!"

[edit] D

Works with: D version 2.0
import std.stdio;
void main() {
writeln("Hello world!");

[edit] Dao

io.writeln( 'Hello world!' )

[edit] Dart

main() {
var bye = 'Hello world!';

[edit] dc

[Hello world!]p

[edit] DCL

$ write sys$output "Hello world!"

[edit] DDNC

DDNC can only output to a single 7-segment LED display digit, so first we must convert each character into its 7-segment equivalent numerical value.

The three horizontal bars are assigned bits 6, 3, and 0 from top to bottom. The top two vertical bars are assigned bits 5 and 4 while the bottom two vertical bars are assigned bits 2 and 1 from left to right.

Because DDNC can only interpret literals in decimal, each binary number was converted and stored in consecutive memory cells starting at cell 10.

The code can be divided into three sections. The first stores the character numbers in order in an array. The second sets up the loop by loading a delay of 500 milliseconds to slot 3, the start address of the character array in memory to slot 2, and the number of times to loop (14) plus one to slot 5. The third section starts the loop of displaying the characters, waiting for the delay time, incrementing the pointer, decrementing the counter, and checking if the counter is negative to know whether to continue the loop.

0 111 10
0 15 11
0 15 12
0 31 13
0 47 14
0 59 15
0 125 16
0 3 17
0 0 18
0 63 19
0 15 20
0 12 21
0 36 22
0 31 23
0 17 24
0 500 3
0 10 2
0 15 5
60 4
2 2 1
80 1
72 3
30 2
31 5
62 5
61 4

[edit] Déjà Vu

!print "Hello world!"

[edit] Delphi

program ProjectGoodbye;
WriteLn('Hello world!');

[edit] DWScript

PrintLn('Hello world!');

[edit] Dylan

module: hello-world
format-out("%s\n", "Hello world!");

[edit] Dylan.NET

Works with: Mono version 2.6.7
Works with: Mono version 2.10.x
Works with: Mono version 3.x.y
Works with: .NET version 3.5
Works with: .NET version 4.0
Works with: .NET version 4.5

One Line version:

Console::WriteLine("Hello world!")

Hello World Program:

//compile using the new dylan.NET v, or later
//use mono to run the compiler
#refstdasm mscorlib.dll
import System
assembly helloworld exe
class public Program
method public static void main()
Console::WriteLine("Hello world!")
end method
end class

[edit] E

println("Hello world!")
stdout.println("Hello world!")

[edit] eC

class GoodByeApp : Application
void Main()
PrintLn("Hello world!");

[edit] EchoLisp

(display "Hello world!" "color:blue")

[edit] ECL

OUTPUT('Hello world!');

[edit] Efene

short version (without a function)

io.format("Hello world!~n")

complete version (put this in a file and compile it)

run = fn () {
io.format("Hello world!~n")

[edit] Egison

(define $main
(lambda [$argv]
(write-string "Hello world!\n")))

[edit] EGL

Works with: EDT
Works with: RBD
program HelloWorld
function main()
SysLib.writeStdout("Hello world!");

[edit] Eiffel

This page uses content from Wikipedia. The original article was at Eiffel (programming language). The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
print ("Hello world!%N")

[edit] Ela

open monad io
do putStrLn "Googbye, World!" ::: IO

[edit] elastiC

From the elastiC Manual.

package hello;
// Import the `basic' package
import basic;
// Define a simple function
function hello()
// Print hello world
basic.print( "Hello world!\n" );
* Here we start to execute package code
// Invoke the `hello' function

[edit] Elena

#symbol Program =
system'console writeLine:"Hello world!".

[edit] Elena Script

#define start ::= "?" < system'console.eval&writeLine( > $literal < ) >;
? "Hello world!"

[edit] Elisa

 "Hello world!"? 

[edit] Elixir

IO.puts "Hello world!"

[edit] Elm

main = plainText "Goodbye World!"

[edit] Emacs Lisp

(insert "Hello world!")

[edit] Erlang

io:format("Hello world!~n").

[edit] ERRE

! Hello World in ERRE language
PRINT("Hello world!")

[edit] Euler Math Toolbox

"Hello world!"

[edit] Extended BrainF***

[.>]@Hello world!

[edit] Ezhil

பதிப்பி"வணக்கம் உலகம்!"
பதிப்பி "Hello world!"
பதிப்பி"******* வணக்கம்! மீண்டும் சந்திப்போம் *******"

[edit] F#

printfn "%s" "Hello world!"

or using .Net classes directly

System.Console.WriteLine("Hello world!")

[edit] Factor

"Hello world!" print

[edit] Falcon

With the printl() function:

printl("Hello world!")

Or via "fast print":

> "Hello world!"

[edit] FALSE

"Hello world!

[edit] Fantom

class HelloText
public static Void main ()
echo ("Hello world!")

[edit] ferite


uses "console";
Console.println( "Goodby, World!" );

[edit] Fexl

say "Hello world!"

[edit] Fish

Standard Hello, world example, modified for this task:

!v"Hello world!"r!

Explanation of the code:
!v" jumps over the v character with the ! sign, then starts the string mode with " .
Then the characters Hello world! are added, and string mode is closed with ".
The stack is reversed for printing (r), and a jump (!) is executed to jump over the ! at the beginning of the line and execute the v. (Fish is torical)
After going down by v, it goes rightwards again by > and this line is being executed.
This line pushes the stack size (l), and stops (;) if the top item on the stack is equal to 0 (?). Else it executes the ! directly after it and jumps to the o, which outputs the top item in ASCII. Then the line is executed again. It effectively prints the stack until it's empty, then it terminates.

[edit] Forth

." Hello world!"

Or as a whole program:

: goodbye ( -- )   ." Hello world!" CR ;

[edit] Fortran

Works with: F77

Simplest case - display using default formatting:

print *,"Hello world!"

Use explicit output format:

100   format (5X,A,"!")
print 100,"Hello world!"

Output to channels other than stdout goes like this:

write (89,100) "Hello world!"

uses the format given at label 100 to output to unit 89. If output unit with this number exists yet (no "OPEN" statement or processor-specific external unit setting), a new file will be created and the output sent there. On most UNIX/Linux systems that file will be named "fort.89".

[edit] Fortress

export Executable                                                                                                                       
run() = println("Hello world!")

[edit] FreeBASIC

'FreeBASIC Hello-fb0.bas May 2015
Screen 0 'open text window
Print "Hello world"
Print "Enter any key to go the graphics screen"
screen 18 'Screen 18 Resolution 640x480 with at least 256 colors
locate 10,10
Print "Hello world!"
locate 20,10
Print "Enter any key to exit"

[edit] Frege

Works with: Frege version 3.20.113
module HelloWorld where
main _ = println "Hello world!"

[edit] friendly interactive shell

Unlike other UNIX shell languages, fish doesn't support history substitution, so ! is safe to use without quoting.

echo Hello world!

[edit] Frink

println["Hello world!"]

[edit] FunL

println( 'Hello world!' )

[edit] Gambas

PRINT "Hello world!"

[edit] GAP

# Several ways to do it
"Hello world!";
Print("Hello world!\n"); # No EOL appended
Display("Hello world!");
f := OutputTextUser();
WriteLine(f, "Hello world!\n");

[edit] gecho

'Goodbye, <> 'World! print

[edit] Gema

Gema ia a preprocessor that reads an input file and writes an output file. This code will write "Hello world!' no matter what input is given.

*= ! ignore off content of input
\B=Hello world!\! ! Start output with this text.

[edit] Gentee

func hello <main>
print("Hello world!")

[edit] GLBasic

STDOUT "Hello world!"

[edit] Glee

"Hello world!"


'Hello world!'

or to display with double quotes


or to display with single quotes


[edit] GML

show_message("Hello world!"); // displays a pop-up message
show_debug_message("Hello world!"); // sends text to the debug log or IDE

[edit] Go

package main
import "fmt"
func main() { fmt.Println("Hello world!") }

[edit] Golfscript

"Hello world!"

[edit] Gosu

print("Hello world!")

[edit] Groovy

println "Hello world!"

[edit] GW-BASIC

10 PRINT "Hello world!"

[edit] Hack

<?hh echo 'Hello world!'; ?>

[edit] Harbour

? "Hello world!"

[edit] Haskell

main = putStrLn "Hello world!"

[edit] Haxe

trace("Hello world!");

[edit] HicEst

WRITE() 'Hello world!'

[edit] HLA

program goodbyeWorld;
begin goodbyeWorld;
stdout.put( "Hello world!" nl );
end goodbyeWorld;

[edit] Hoon

~&  "Hello world!"  ~

[edit] HQ9+

This example is incorrect. output isn't consistent with the task's requirements (and is probably incapable of solving the task). Please fix the code and remove this message.
  • Technically, HQ9+ can't print "Hello world!" text because of its specification.

- H : Print 'Hello World!'
- Q : Quine
- 9 : Print '99 Bottles of Beer'
- + : Increase Pointer (useless!)

[edit] Icon and Unicon

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

[edit] IDL

print,'Hello world!'

[edit] Inform 6

print "Hello world!^";

[edit] Integer BASIC

NOTE: Integer BASIC was written (and hand-assembled by Woz himself) for the Apple 1 and original Apple 2. The Apple 1 has NO support for lower-case letters, and it was an expensive (and later) option on the Apple 2. This example accurately represents the only reasonable solution for those target devices, and therefore cannot be "fixed", only deleted.

   10 PRINT "Hello world!"
20 END

[edit] Io

"Hello world!" println

[edit] Ioke

"Hello world!" println

[edit] IWBASIC

PRINT"Hello world!"
'This line could be left out.
PRINT:PRINT:PRINT"Press any key to end."
'Keep the console from closing right away so the text can be read.

[edit] J

   'Hello world!'
Hello world!

Here are some redundant alternatives:

   [data=. 'Hello world!'
Hello world!
Hello world!
smoutput data
Hello world!

[edit] Jack

class Main {
function void main () {
do Output.printString("Hello world!");
do Output.println();

[edit] Jacquard Loom

This weaves the string "Hello world!"

| |
| * * |
|* * * * |
|* * *|
|* * *|
|* * * |
| * * * |
| * |
| |
|* * * |
|* * * |
| * *|
| * *|
|* * * |
|* * * * |
| * |
| |
|* ** * * |
|******* *** * |
| **** * * ***|
| **** * ******|
| ****** ** * |
| * * * * |
| * |
| |
|******* *** * |
|******* *** * |
| ** *|
|* * * *|
|******* ** * |
|******* *** * |
| * |
| |
|******* *** * |
|******* *** * |
| * * * *|
| * * * *|
|******* ** * |
|******* ** * |
| * |
| |
|***** * *** * |
|******* *** * |
| * * * * |
| * * * |
|****** ** * |
|****** ** * |
| * |
| |
| * * * |
|***** * ***** |
|***** ** * ***|
|***** ** * ***|
|******* * ** |
| * * * * |
| * |
| |
| |
| * * |
| * * |
| * |
| * |
| |
| |

[edit] Java

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

[edit] JavaScript

document.write("Hello world!");
Works with: NJS version 0.2.5
Works with: Rhino
Works with: SpiderMonkey
print('Hello world!');
Works with: JScript
WScript.Echo("Hello world!");
Works with: Node.js
console.log("Hello world!")

[edit] JCL

/*MESSAGE Hello world!

[edit] Joy

"Hello world!" putchars.

[edit] jq

"Hello world!"

[edit] Julia

println("Hello world!")

[edit] Kaya

program hello;
Void main() {
// My first program!
putStrLn("Hello world!");

[edit] Kdf9 Usercode

This example is incorrect. output isn't consistent with the task's requirements: wording, punctuation. Please fix the code and remove this message.
V2; W0;
RESTART; J999; J999;
PROGRAM; (main program);
V0 = Q0/AV1/AV2;
V1 = B0750064554545700; ("Hello" in Flexowriter code);
V2 = B0767065762544477; ("World" in Flexowriter code);
V0; =Q9; POAQ9; (write "Hello World" to Flexowriter);
999; OUT;

[edit] Kite

simply a single line

"Hello world!"|print;

[edit] Kitten

"Hello world!" say

[edit] KonsolScript

Displays it in a text file or console/terminal.

function main() {
Konsol:Log("Hello world!")

[edit] Kotlin

fun main(args: Array<String>) {
println("Hello world!")

[edit] Lang5

"Hello world!\n" .

[edit] Lasso

A plain string is output automatically.

'Hello world!'

[edit] LFE

(: io format '"Hello world!~n")

[edit] Liberty BASIC

print "Hello world!"

[edit] Lily

There are two ways to do this. First, with the builtin print:

print("Hello world!\n")

Second, by using stdout directly:

stdout.write("Hello world!\n")

[edit] Limbo

implement Command;
include "sys.m";
sys: Sys;
include "draw.m";
include "sh.m";
init(nil: ref Draw->Context, nil: list of string)
sys = load Sys Sys->PATH;
sys->print("Hello world!\n");

[edit] Lisaac

Works with: Lisaac version 0.13.1

You can print to standard output in Lisaac by calling STRING.print or INTEGER.print:

Section Header          // The Header section is required.
+ name := GOODBYE; // Define the name of this object.
Section Public
- main <- ("Hello world!\n".print;);

However, it may be more straightforward to use IO.print_string instead:

Section Header          // The Header section is required.
+ name := GOODBYE2; // Define the name of this object.
Section Public
- main <- (IO.put_string "Hello world!\n";);

[edit] LiveCode

Example on OS X using livecode-server in shell script

#! /usr/local/bin/livecode-server
set the outputLineEndings to "lf"
put "Hello world!" & return
Livecode also supports stdout as a device to write to
write "Hello world!" & return to stdout

[edit] LLVM

@str = internal constant [14 x i8] c"Hello, world!\00"
declare i32 @puts(i8*)
define i32 @main()
call i32 @puts( i8* getelementptr ([14 x i8]* @str, i32 0,i32 0))
ret i32 0

[edit] Lobster

print "Hello world!"


Print includes a line feed:

print [Hello world!]

Type does not:

type [Hello world!]

[edit] Logtalk

:- object(hello_world).
% the initialization/1 directive argument is automatically executed
% when the object is loaded into memory:
:- initialization(write('Hello world!\n')).
:- end_object.

[edit] LOLCODE

VISIBLE "Hello world!"

[edit] LotusScript

:- object(hello_world).
'This will send the output to the status bar at the bottom of the Notes client screen
print "Hello world!"
:- end_object.

[edit] LSE64

"Hello world!" ,t nl

[edit] Lua

Function calls with either a string literal or a table constructor passed as their only argument do not require parentheses.

print "Hello world!"

Harder way with a table:

local chars = {"G","o","o","d","b","y","e",","," ","W","o","r","l","d","!"}
for i = 1, #chars do

[edit] M4

For the particular nature of m4, this is simply:

`Hello world!'

[edit] make

Makefile contents:

$(info Hello world!)

Running make produces:

Hello world!
make: Nothing to be done for `all'.

[edit] Malbolge

Long Version:


Short Version:


[edit] Maple

> printf( "Hello world!\n" ): # print without quotes
Hello world!

[edit] Mathematica

Print["Hello world!"]

[edit] MATLAB

>> disp('Hello world!')

[edit] Maude

fmod BYE-WORLD is
protecting STRING .
op sayBye : -> String .
eq sayBye = "Hello world!" .
red sayBye .

[edit] Maxima

print("Hello world!");

[edit] MAXScript

print "Hello world!"


format "%" "Hello world!"

[edit] Mercury

:- module hello.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
io.write_string("Hello world!\n", !IO).

[edit] Metafont

message "Hello world!"; end

[edit] MIPS Assembly

Works with: MARS
Works with: SPIM
hello: .asciiz "Hello world!"
la $a0, hello
li $v0, 4
li $v0, 10

[edit] mIRC Scripting Language

echo -ag Hello world!

[edit] ML/I

Hello world!

[edit] Modula-2

InOut.WriteString('Hello world!');
END Hello.

[edit] Modula-3

IO.Put("Hello world!\n");
END Goodbye.

[edit] Morfa

import morfa.io.print;
func main(): void
println("Hello world!");

[edit] MUF

: main[ -- ]
me @ "Hello world!" notify

[edit] MUMPS

Write "Hello world!",!

[edit] MyrtleScript

script HelloWorld {
func main returns: int {
print("Hello World!")

[edit] MySQL

SELECT 'Hello world!';

[edit] Mythryl

print "Hello world!";

[edit] Neat

void main() writeln "Hello world!";

[edit] Neko

$print("Hello world!");

[edit] Nemerle

class Hello
static Main () : void
System.Console.WriteLine ("Hello world!");

Easier method:

System.Console.WriteLine("Hello world!");

[edit] NetRexx

say  'Hello world!'

[edit] newLISP

Works with: newLisp version 6.1 and after
(println "Hello world!")

[edit] Nim

echo("Hello world!")

[edit] Nit

print "Hello world!"

[edit] Oberon-2

MODULE Goodbye;
Out.String("Hello world!");Out.Ln
END World;
END Goodbye.

[edit] Objeck

class Hello {
function : Main(args : String[]) ~ Nil {
"Hello world!"->PrintLine();

[edit] Objective-C

Works with: clang-602.0.53

The de facto Objective-C "Hello, World!" program is most commonly illustrated as the following, using the NSLog() function:

#import <Foundation/Foundation.h>
int main() {
@autoreleasepool {
NSLog(@"Hello, World!");

However the purpose of the NSLog() function is to print a message to standard error prefixed with a timestamp, which does not meet the most common criteria of a "Hello, World!" program of displaying only the requested message to standard output.

The following code prints the message to standard output without a timestamp using exclusively Objective-C messages:

#import <Foundation/Foundation.h>
int main() {
@autoreleasepool {
NSFileHandle *standardOutput = [NSFileHandle fileHandleWithStandardOutput];
NSString *message = @"Hello, World!\n";
[standardOutput writeData:[message dataUsingEncoding:NSUTF8StringEncoding]];

Objective-C also supports functions contained within the C standard library. However, Objective-C's NSString objects must be converted into a UTF-8 string in order to be supported by the C language's I/O functions.

#import <Foundation/Foundation.h>
int main() {
@autoreleasepool {
NSString *message = @"Hello, World!\n";
printf("%s", message.UTF8String);

[edit] OCaml

print_endline "Hello world!"

[edit] Occam

Works with: kroc
#USE "course.lib"
PROC main (CHAN BYTE screen!)
out.string("Hello world!*c*n", 0, screen)

[edit] Octave

disp("Hello world!");

Or, using C-style function printf:

printf("Hello world!");

[edit] Oforth

"Hello world!" println

[edit] Onyx

`Hello world!\n' print

[edit] OOC

To print a String, either call its println() method:

main: func {
"Hello world!" println()

Or call the free println() function with the String as the argument.

main: func {
println("Hello world!")

[edit] ooRexx

Refer also to the Rexx and NetRexx solutions. Simple output is common to most Rexx dialects.

/* Rexx */
say 'Hello world!'

[edit] Openscad

echo("Hello world!");

[edit] Oxygene

From wp:Oxygene (programming language)

namespace HelloWorld;
HelloClass = class
class method Main;
class method HelloClass.Main;
System.Console.WriteLine('Hello world!');
Hello world!

[edit] Oz

{Show "Hello world!"}

[edit] PARI/GP

print("Hello world!")

[edit] Pascal

Works with: Free Pascal
program byeworld;
writeln('Hello world!');

[edit] PASM

print "Hello world!\n"

[edit] PDP-11 Assembly

Works with: UNIX version 7

This is tested on Unix v7 Prints "Hello world!" to stdout:

.globl  start
mov $1,r0
sys 4; outtext; outlen
sys 1
rts pc
outtext: <Hello world!\n>
outlen = . - outtext

[edit] Perl

Works with: Perl version 5.8.8
print "Hello world!\n";
Works with: Perl version 5.10.x

Backported from Perl 6:

use feature 'say';
say 'Hello world!';


use 5.010;
say 'Hello world!';

[edit] Perl 6

say 'Hello world!';

[edit] Phix

puts(1,"Hello world!")

[edit] PHL

module helloworld;
extern printf;
@Integer main [
printf("Hello world!");
return 0;

[edit] PHP

echo "Hello world!\n";

Alternatively, any text outside of the <?php ?> tags will be automatically echoed:

Hello world!

[edit] PicoLisp

(prinl "Hello world!")

[edit] Pike

int main(){
write("Hello world!\n");

[edit] PIR

.sub hello_world_text :main
print "Hello world!\n"

[edit] PL/I

goodbye:proc options(main);
put list('Hello world!');
end goodbye;

[edit] Pony

actor Main
new create(env: Env) =>
env.out.print("Hello world!")

[edit] Pop11

printf('Hello world!\n');

[edit] PostScript

The "==" and "=" operators display the topmost element of the stack with or without processing, followed by a newline. Thus:

(Hello world!) ==

will display the string "(Hello world!)" while

(Hello world!) =

will display the content of the string "(Hello world!)"; that is, "Hello world!".

To print a string without the following newline, use

(Hello world!) print

[edit] PowerShell

'Hello world!'
#It's considered good practice to use Write-Host, although it works just fine without too
Write-Host 'Hello world!'
# For extra flair, you can specify colored output
Write-Host 'Hello world!' -foregroundcolor red

[edit] ProDOS

printline Hello world!

[edit] Prolog

:- write('Hello world!'), nl.

[edit] PSQL

   S = 'Hello world!';

[edit] Pure

using system;
puts "Hello world!\n" ;

[edit] PureBasic

PrintN("Hello world!")
Input() ; Wait for enter

[edit] Python

Works with: Python version 2.4
print "Hello world!"

The same using sys.stdout

import sys
sys.stdout.write("Hello world!\n")

In Python 3.0, print is changed from a statement to a function.

Works with: Python version 3.0
(And version 2.X too).
print("Hello world!")

[edit] Quill

"Hello world!" print

[edit] R

 cat("Hello world!\n")

[edit] Ra

class HelloWorld
**Prints "Hello world!"**
on start
print "Hello world!"

[edit] Racket

(printf "Hello world!\n")

[edit] Raven

'Hello world!' print

[edit] REALbasic

Works with: REALbasic version 5.5

This requires a console application.

Function Run(args() as String) As Integer
Print "Hello world!"
End Function

[edit] REBOL

print "Hello world!"

[edit] RED

print "Hello world!"

[edit] Retro

"Hello world!" puts

[edit] REXX

[edit] using SAY

/*REXX program to show a line of text.  */
say 'Hello world!'

[edit] using SAY variable

/*REXX program to show a line of text.  */
yyy = 'Hello world!'
say yyy

[edit] using LINEOUT

/*REXX program to show a line of text.  */
call lineout ,"Hello world!"

[edit] RTL/2

TITLE Goodbye World;
LET NL=10;
TWRT("Hello world!#NL#");

[edit] Ruby

Works with: Ruby version 1.8.4
puts "Hello world!"


$stdout.puts "Hello world!"

or even

 STDOUT.write "Hello world!\n"

[edit] Run BASIC

print "Hello world!"

[edit] Rust

fn main () {
println!("Hello world!");

[edit] Salmon

"Hello world!"!


print("Hello world!\n");


standard_output.print("Hello world!\n");

[edit] SAS

/* Using a data step. Will print the string in the log window */
data _null_;
put "Hello world!";

[edit] Sather

main is
#OUT+"Hello world!\n";

[edit] Scala

Library: Console

[edit] Ad hoc REPL solution

Ad hoc solution as REPL script. Type this in a REPL session:

println("Hello world!")

[edit] Via Java runtime

This is a call to the Java run-time library. Not recommendated.

System.out.println("Hello world!")

[edit] Via Scala Console API

This is a call to the Scala run-time library. Recommendated.

println("Hello world!")

[edit] Short term deviation to out

Console.withErr(Console.out) { Console.err.println("This goes to default _out_") }

[edit] Long term deviation to out

  Console.err.println ("Err not deviated")
Console.err.println ("Err deviated")
Console.setErr(Console.err) // Reset to normal

[edit] Scheme

Works with: Gauche
Works with: Guile
(display "Hello world!")
Works with: Gauche
(print "Hello world!")

or just:

"Hello world!"

(should work on any scheme)

[edit] R7RS Scheme

(import (scheme base)
(scheme write))
(display "Hello world!")

[edit] Scilab

disp("Hello world!");

[edit] sed

Hello world!

[edit] Seed7

$ include "seed7_05.s7i";
const proc: main is func
writeln("Hello world!");
end func;

[edit] Self

'Hello world!' printLine.

[edit] SETL

print("Hello world!");

[edit] Shen

(output "Hello world!~%")

[edit] Shiny

say 'Hello world!'

[edit] Sidef

„Hello world!”.say;

[edit] SIMPOL

function main()
end function "Hello world!{d}{a}"

[edit] Simula

Works with: SIMULA-67
OUTTEXT("Hello world!");

[edit] Sisal

define main
% Sisal doesn't yet have a string built-in.
% Let's define one as an array of characters.
type string = array[character];
function main(returns string)
"Hello world!"
end function

[edit] Slate

inform: 'Hello world!'.

[edit] Smalltalk

Transcript show: 'Hello world!'; cr.
Works with: GNU Smalltalk
(as does the above code)
'Hello world!' printNl.

[edit] SmileBASIC

PRINT "Hello world!"

[edit] SNOBOL4

Using CSnobol4 dialect

    OUTPUT = "Hello world!"

[edit] SNUSP

[edit] Core SNUSP

\+++\ | /+>+++++++>/ /++++++++++<<.++>./
$+++/ | \+++++++++>\ \+++++.>.+++.-----\
\==-<<<<+>+++/ /=.>.+>.--------.-/

[edit] Modular SNUSP

@\G.@\o.o.@\d.--b.@\y.@\e.>@\comma.@\.<-@\W.+@\o.+++r.------l.@\d.>+.! #
| | \@------|# | \@@+@@++|+++#- \\ -
| \@@@@=+++++# | \===--------!\===!\-----|-------#-------/
\@@+@@@+++++# \!#+++++++++++++++++++++++#!/

[edit] SoneKing Assembly

extern print
dv Msg Goodbye,World!
mov eax Msg
call print

[edit] SPARC Assembly

.section ".text"
.global _start
mov 4,%g1 ! 4 is SYS_write
mov 1,%o0 ! 1 is stdout
set .msg,%o1 ! pointer to buffer
mov (.msgend-.msg),%o2 ! length
ta 8
mov 1,%g1 ! 1 is SYS_exit
clr %o0 ! return status is 0
ta 8
.ascii "Hello world!\n"

[edit] Sparkling

print("Hello world!");

[edit] Standard ML

print "Hello world!\n"

[edit] Suneido

Print("Hello world!")

[edit] Swift

Works with: Swift version 2.x+
print("Hello world!")
Works with: Swift version 1.x
println("Hello world!")

[edit] Tcl

Output to terminal:

puts "Hello world!"

Output to arbitrary open, writable file:

puts $fileID "Hello world!"

[edit] Teco

Outputting to terminal. Please note that ^A means control-A, not a caret followed by 'A', and that $ represent the ESC key.

^AHello world!^A$$

[edit] Terra

C = terralib.includec("stdio.h")
terra hello(argc : int, argv : &rawstring)
C.printf("Hello world!\n")
return 0

[edit] TestML

%TestML 0.1.0
Print("Hello world!")

[edit] TI-83 BASIC

Disp "Hello world!

(Lowercase letters DO exist in TI-BASIC, though you need an assembly program to enable them.)

[edit] TI-89 BASIC

Disp "Hello world!"

[edit] TorqueScript

echo("Hello world!");

[edit] TPP

Hello world!

[edit] Transact-SQL

PRINT "Hello world!"

[edit] Trith

"Hello world!" print


PRINT "Hello world!"


Hello world!

[edit] Uniface

message "Hello world!"

[edit] UNIX Shell

Works with: Bourne Shell
echo "Hello world!"

[edit] C Shell

#!/bin/csh -f
echo "Hello world!\!"

We use \! to prevent history substitution. Plain ! at end of string seems to be safe, but we use \! to be sure.

[edit] Unlambda

`r```````````````.G.o.o.d.b.y.e.,. .W.o.r.l.d.!i

[edit] Ursala

output as a side effect of compilation

main = -[Hello world!]-

output by a compiled executable

#import std
#executable ('parameterized','')
main = <file[contents: -[Hello world!]-]>!

[edit] உயிர்/Uyir

முதன்மை என்பதின் வகை எண் பணி {{
("உலகத்தோருக்கு வணக்கம்") என்பதை திரை.இடு;
முதன்மை = 0;

[edit] V

"Hello world!" puts

[edit] Vala

void main(){
stdout.printf("Hello world!\n");

[edit] VBScript

Works with: Windows Script Host version 5.7
WScript.Echo("Hello world!")

[edit] Vedit macro language

Message("Hello world!")

[edit] VHDL

USE std.TEXTIO.all;
entity test is
end entity test;
architecture beh of test is
variable line_out : line;
write(line_out, string'("Hello world!"));
writeline(OUTPUT, line_out);
wait; -- needed to stop the execution
end process;
end architecture beh;

[edit] Vim Script

echo "Hello world!\n"

[edit] Wart

prn "Hello world!"

[edit] Whenever

1 print("Hello world!");

[edit] Whiley

import whiley.lang.System
method main(System.Console console):
console.out.println("Hello world!")

[edit] Whitespace

There is a "Hello World" - example-program on the Whitespace-website

[edit] Wolfram Language

Print["Hello world!"]

[edit] Wren

IO.print("Hello world!")

[edit] X86 Assembly

Works with: nasm version 2.05.01

This is known to work on Linux, it may or may not work on other Unix-like systems

Prints "Hello world!" to stdout (and there is probably an even simpler version):

section .data
msg db 'Hello world!', 0AH
len equ $-msg
section .text
global _start
_start: mov edx, len
mov ecx, msg
mov ebx, 1
mov eax, 4
int 80h
mov ebx, 0
mov eax, 1
int 80h

AT&T syntax: works with gcc (version 4.9.2) and gas (version 2.5):

.section .text
.globl main
movl $4,%eax #syscall number 4
movl $1,%ebx #number 1 for stdout
movl $str,%ecx #string pointer
movl $16,%edx #number of bytes
int $0x80 #syscall interrupt
.section .data
str: .ascii "Hello world!\12"

[edit] xEec

h#10 h$! h$d h$l h$r h$o h$w h#32
h$o h$l h$l h$e h$H >o o$ p jno

[edit] XL

WriteLn "Hello world!"

[edit] XPL0

code Text=12;
Text(0, "Hello world!

[edit] XSLT

<xsl:text>Hello world!

[edit] Yorick

write, "Hello world!"

[edit] Z80 Assembly

Using the Amstrad CPC firmware:

org		$4000
txt_output: equ $bb5a
push hl
ld hl,world
print: ld a,(hl)
cp 0
jr z,end
call txt_output
inc hl
jr print
end: pop hl
world: defm "Hello world!\r\n\0"

[edit] zkl

println("Hello world!");
Personal tools