Hello world/Text: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
mNo edit summary
Line 421: Line 421:
{{works with|M2000 Interpreter}}
{{works with|M2000 Interpreter}}
<lang qbasic>PRINT "Hello world!"</lang>
<lang qbasic>PRINT "Hello world!"</lang>

=={{header|Basic Casio}}==
<lang Basic Casio>Locate 1,1,"Hello World!"</lang>
or just
<lang Basic Casio>"Hello World!"</lang>


=={{header|BASIC256}}==
=={{header|BASIC256}}==
Line 712: Line 707:
return 0;
return 0;
}</lang>
}</lang>

=={{header|Casio BASIC}}==
<lang Basic Casio>Locate 1,1,"Hello World!"</lang>
or just
<lang Basic Casio>"Hello World!"</lang>


=={{header|Cat}}==
=={{header|Cat}}==

Revision as of 20:36, 23 February 2021

Task
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.
Task

Display the string Hello world! on a text console.

Related tasks



0815

<lang 0815> <:48:x<:65:=<:6C:$=$=$$~<:03:+ $~<:ffffffffffffffb1:+$<:77:~$ ~<:fffffffffffff8:x+$~<:03:+$~ <:06:x-$x<:0e:x-$=x<:43:x-$

</lang>

11l

<lang 11l>print(‘Hello world!’)</lang>

360 Assembly

Using native SVC (Supervisor Call) to write to system console: <lang 360 Assembly> HELLO CSECT

        USING HELLO,15
        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
        END</lang>

Using WTO Macro to generate SVC 35 and message area: <lang 360 Assembly> WTO 'Hello world!'

        BR    14            Return
        END

</lang>

4DOS Batch

<lang 4dos>echo Hello world!</lang>

6502 Assembly

<lang asm>; 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 ; C64 KERNEL ROM, output a character to current device. ; use $fded for Apple 2, $ffe3 (ascii) or $ffee (raw) for BBC. .code

ldx #0 ; Starting index 0 in X register. printnext: 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. done: rts ; Return from subroutine.

.rodata

text: .byte "Hello world!", a_cr, 0</lang>

6800 Assembly

<lang> .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

       .en</lang>

8080 Assembly

<lang 8080asm> ; This is Hello World, written in 8080 assembly to run under CP/M ; As you can see, it is similar to the 8086, and CP/M is very ; similar to DOS in the way it is called. org 100h ; CP/M .COM entry point is 100h - like DOS mvi c,9 ; C holds the syscall, 9 = print string - like DOS lxi d,msg ; DE holds a pointer to the string jmp 5 ; CP/M calls are accessed through the jump at 05h ; Normally you'd CALL it, but since you'd end the program by RETurning, ; JMP saves a byte (if you've only got 64k of address space you want to ; save bytes). msg: db 'Hello world!$'</lang>

8086 Assembly

<lang masm>DOSSEG .MODEL TINY .DATA TXT DB "Hello world!$" .CODE START: MOV ax, @DATA 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 END START</lang>

With A86 or NASM syntax:

  org 100h

  mov dx, msg
  mov ah, 9
  int 21h

  mov ax, 4c00h
  int 21h

msg:
  db "Hello world!$"

8th

<lang forth>"Hello world!\n" . bye</lang>

AArch64 Assembly

<lang ARM_Assembly>.equ STDOUT, 1 .equ SVC_WRITE, 64 .equ SVC_EXIT, 93

.text .global _start

_start: stp x29, x30, [sp, -16]! mov x0, #STDOUT ldr x1, =msg mov x2, 13 mov x8, #SVC_WRITE mov x29, sp svc #0 // write(stdout, msg, 13); ldp x29, x30, [sp], 16 mov x0, #0 mov x8, #SVC_EXIT svc #0 // exit(0);

msg: .ascii "Hello World!\n" .align 4</lang>

ABAP

<lang ABAP>REPORT zgoodbyeworld.

 WRITE 'Hello world!'.</lang>

ACL2

<lang lisp>(cw "Hello world!~%")</lang>

ActionScript

<lang ActionScript>trace("Hello world!");</lang>

Ada

Works with: GCC version 4.1.2

<lang ada>with Ada.Text_IO; use Ada.Text_IO; procedure Main is begin

 Put_Line ("Hello world!");

end Main;</lang>

Agena

<lang agena>print( "Hello world!" )</lang>

Aime

<lang aime>o_text("Hello world!\n");</lang>

or:

<lang aime>integer main(void) {

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

}</lang>

Algae

<lang algae>printf("Hello world!\n");</lang>

ALGOL 60

<lang algol60>'BEGIN'

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

'END'</lang>

ALGOL 68

<lang algol68>main: (

 printf($"Hello world!"l$)

)</lang>

ALGOL W

<lang algolw>begin

   write( "Hello world!" )

end.</lang>

ALGOL-M

<lang algol>BEGIN

   WRITE( "Hello world!" );

END</lang>

Alore

<lang alore>Print('Hello world!')</lang>

AmbientTalk

<lang ambienttalk>system.println("Hello world!")</lang>

AmigaE

<lang amigae>PROC main()

 WriteF('Hello world!\n')

ENDPROC</lang>

AntLang

Note, that "Hello, World!" prints twice in interactive mode. One time as side-effect and one as the return value of echo. <lang AntLang>echo["Hello, World!"]</lang>

Anyways

<lang Anyways>There was a guy called Hello World "Ow!" it said. That's all folks!</lang>

APL

<lang apl>'Hello world!'</lang>

AppleScript

To show in Script Editor Result pane: <lang applescript>"Hello world!"</lang>

To show in Script Editor Event Log pane: <lang applescript>log "Hello world!"</lang>

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.

<lang Applesoft BASIC> PRINT "Hello world!"</lang>

Apricot

<lang apricot>(puts "Hello world!")</lang>

Arc

<lang arc>(prn "Hello world!")</lang>

Arendelle

"Hello world!"

Argile

<lang Argile>use std print "Hello world!"</lang> compile with: arc hello_world.arg -o hello_world.c && gcc -o hello_world hello_world.c

ARM Assembly

<lang ARM_Assembly>.global main

message:

   .asciz "Hello world!\n"
   .align 4

main:

   ldr r0, =message
   bl printf
   mov r7, #1
   swi 0</lang>

ArnoldC

<lang ArnoldC>IT'S SHOWTIME TALK TO THE HAND "Hello world!" YOU HAVE BEEN TERMINATED</lang>

Arturo

<lang rebol>print "Hello world!"</lang>

Output:
Hello world!

AsciiDots

<lang AsciiDots> .-$'Hello, World!' </lang>

Astro

<lang python>print "Hello world!"</lang>

Asymptote

<lang asymptote>write('Hello world!');</lang>

ATS

<lang ATS>implement main0 () = print "Hello world!\n"</lang>

AutoHotkey

script launched from windows explorer <lang AutoHotkey>DllCall("AllocConsole") FileAppend, Goodbye`, World!, CONOUT$ FileReadLine, _, CONIN$, 1</lang> scripts run from shell [requires Windows XP or higher; older Versions of Windows don´t have the "AttachConsole" function] <lang AutoHotkey>DllCall("AttachConsole", "int", -1) FileAppend, Goodbye`, World!, CONOUT$</lang> <lang AutoHotkey>SendInput Hello world!{!}</lang>

AutoIt

<lang AutoIt>ConsoleWrite("Hello world!" & @CRLF)</lang>

AutoLISP

<lang cadlisp>(printc "Hello World!")</lang>

Avail

<lang Avail>Print: "Hello World!";</lang>

AWK

<lang awk>BEGIN{print "Hello world!"}</lang>


"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. <lang awk> END {

    print "Hello world!"
   }

</lang>

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). Or instead of //, simply 1 is true. <lang awk> // {

   print "Hello world!" 
   exit
   }

</lang>


For a "single record" file. <lang awk> // {

   print "Hello world!" 
   }

</lang>

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. <lang awk> // </lang>

Axe

Note that the i here is the imaginary i, not the lowercase letter i. <lang axe>Disp "Hello world!",i</lang>

B

Works with: The Amsterdam Compiler Kit - B version V6.1pre1

<lang B>main() {

   putstr("Hello world!*n");
   return(0);

}</lang>

B4X

<lang B4X>Log("Hello world!")</lang>

Babel

<lang babel>"Hello world!" <<</lang>

bash

<lang bash>echo "Hello world!"</lang>

BASIC

Works with: BASICA
Works with: Commodore BASIC
Works with: Locomotive Basic
Works with: M2000 Interpreter
Works with: MSX BASIC
Works with: Tiny BASIC

<lang qbasic>10 print "Hello world!"</lang>

Works with: 7Basic
Works with: BaCon
Works with: QBasic
Works with: M2000 Interpreter

<lang qbasic>PRINT "Hello world!"</lang>

BASIC256

<lang BASIC256>PRINT "Hello world!"</lang>

Batch File

Under normal circumstances, when delayed expansion is disabled <lang dos>echo Hello world!</lang>

If delayed expansion is enabled, then the ! must be escaped twice <lang dos>setlocal enableDelayedExpansion echo Hello world!^^!</lang>

Battlestar

<lang c>const hello = "Hello world!\n"

print(hello)</lang>

BBC BASIC

<lang bbcbasic> PRINT "Hello world!"</lang>

bc

<lang bc>"Hello world! "</lang>

BCPL

<lang BCPL>GET "libhdr"

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

 RESULTIS 0

}</lang>

beeswax

Straightforward:

<lang Beeswax>*`Hello, World!</lang>

Less obvious way:

<lang beeswax>>`ld! `

r
 o
  W
   `
    b` ,olleH`_</lang>

Even less obvious, demonstrating the creation and execution order of instruction pointers, and the hexagonal layout of beeswax programs:

<lang beeswax>r l

l o
 ``

ol`*`,d!

  ``
  e H
  W</lang>

Befunge

<lang befunge>52*"!dlroW ,eybdooG">:#,_@</lang>

Bird

It's not possible to print exclamation marks in Bird which is why it is not used in this example. <lang Bird>use Console

define Main

   Console.Println "Hello world"

end</lang>

Blast

<lang blast># This will display a goodbye message on the terminal screen .begin display "Hello world!" return

  1. This is the end of the script.</lang>

blz

<lang blz>print("Hello world!")</lang>

BML

<lang bml>display "Hello world!"</lang>

Boo

<lang boo>print "Hello world!"</lang>

bootBASIC

<lang bootBASIC>10 print "Hello world!"</lang>

Brace

<lang brace>#!/usr/bin/env bx use b Main: say("Hello world!")</lang>

Bracmat

<lang bracmat>put$"Hello world!"</lang>

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: <lang bf>+++++ +++++ 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 >>>> + ..

d < .

b < +++++ +++ .

y >>> + .

e << + .

COMMA <<<< ++++ .

SPACE < ++ .

W >>> +++++ ++ .

o >>> .

r +++ .

l < +++++ ++ .

d


--- .

! <<<<< + .

CRLF < +++ . --- .</lang>

Uncommented: <lang bf>++++++++++[>+>+++>++++>+++++++>++++++++>+++++++++>++ ++++++++>+++++++++++>++++++++++++<<<<<<<<<-]>>>>+.>>> >+..<.<++++++++.>>>+.<<+.<<<<++++.<++.>>>+++++++.>>>.+++. <+++++++.--------.<<<<<+.<+++.---.</lang> It can most likely be optimized, but this is a nice way to show how character printing works in Brainf*** :)

Brat

<lang brat>p "Hello world!"</lang>

Brlcad

The mged utility can output text to the terminal:

<lang brlcad> echo Hello world! </lang>

Burlesque

<lang burlesque> "Hello world!"sh </lang>

Although please note that sh actually does not print anything.

C

Works with: gcc version 4.0.1

<lang c>#include <stdlib.h>

  1. include <stdio.h>

int main(void) {

 printf("Hello world!\n");
 return EXIT_SUCCESS;

}</lang> Or: <lang c>#include <stdlib.h>

  1. include <stdio.h>

int main(void) {

 puts("Hello world!");
 return EXIT_SUCCESS;

}</lang> Or, the eternal favourite :) <lang c>

  1. include<stdio.h>

int main() {

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

}</lang>

or better yet... <lang C>

  1. include<stdio.h>

int main() { return printf("\nHello World!"); } </lang>

C#

Works with: Mono version 1.2
Works with: Visual C# version 2003

<lang csharp>namespace HelloWorld {

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

}</lang>

C++

<lang cpp>#include <iostream>

int main () {

 std::cout << "Hello world!" << std::endl;

}</lang>

C++/CLI

<lang cpp>using namespace System; int main() {

 Console::WriteLine("Hello world!");

}</lang>

C1R

<lang C0H>Hello_world/Text</lang>

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

C2

<lang c2>module hello_world; import stdio as io;

func i32 main(i32 argc, char** argv) {

   io.printf("Hello World!\n");
   return 0;

}</lang>

Casio BASIC

<lang Basic Casio>Locate 1,1,"Hello World!"</lang> or just <lang Basic Casio>"Hello World!"</lang>

Cat

<lang Cat>"Hello world!" writeln</lang>

Cduce

<lang Cduce>print "Hello world!";;</lang>

Chapel

<lang Chapel>writeln("Hello world!");</lang>

Chef

<lang Chef>Goodbye World Souffle.

Ingredients. 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

Method. 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.</lang>

ChucK

<lang><<< "Hello world!">>>;</lang>

Cind

<lang cind> execute() {

   host.println("Hello world!");

} </lang>

Clay

<lang clay>main() {

   println("Hello world!");

}</lang>

Clean

<lang clean>Start = "Hello world!"</lang>

Clio

<lang clio>'hello world!' -> print</lang>

Clipper

<lang Clipper>? "Hello world!"</lang>

CLIPS

<lang clips>(printout t "Hello world!" crlf)</lang>

Clojure

<lang lisp>(println "Hello world!")</lang>

CMake

<lang cmake>message(STATUS "Hello world!")</lang>

This outputs

-- Hello world!

COBOL

Using fixed format.

Works with: OpenCOBOL

<lang cobol> program-id. hello. procedure division. display "Hello world!". stop run.</lang>

Using relaxed compilation rules, the hello program can become a single DISPLAY statement.

Works with: GnuCOBOL

<lang cobol>display"Hello, world".</lang>

prompt$ cobc -x -frelax-syntax -free hello.cob
hello.cob: 1: Warning: PROGRAM-ID header missing - assumed
hello.cob: 1: Warning: PROCEDURE DIVISION header missing - assumed

prompt$ ./hello
Hello, world

Note how COBOL can handle the DISPLAY reserved word without a space before the quoted string, the quote being a compile time scan delimiter. The full stop period after the single statement is still mandatory, at least for GnuCOBOL and a clean compile to executable.

Cobra

<lang cobra>class Hello

   def main
       print 'Hello world!'</lang>

CoffeeScript

Works with: Node.js

<lang coffeescript>console.log "Hello world!"</lang>

Works with: Rhino engine

<lang coffeescript>print "Hello world!"</lang>

ColdFusion

<lang coldfusion><cfoutput>Hello world!</cfoutput></lang>

Comal

<lang Comal>PRINT "Hello world!"</lang>

Comefrom0x10

<lang cf0x10>'Hello world!'</lang>

<lang cf0x10>"Hello world!"</lang>

Commodore BASIC

By default some Commodore computers boot into uppercase/graphics mode (C64, C128, VIC-20, Plus 4, etc.) while others (PET, CBM etc.) boot into lowercase/uppercase mode. Therefore, depending on machine used, the CHR$(14) may or may not be required to switch into mixed-case mode. <lang GWBasic>10 print chr$(147);chr$(14);:REM 147=clear screen, 14=switch to lowercase mode 20 print "Hello world!" 30 end </lang>

Output:
Hello world!

Common Lisp

<lang lisp>(format t "Hello world!~%")</lang>

Or

<lang lisp>(print "Hello world!")</lang>

Alternate solution

I use Allegro CL 10.1

<lang lisp>

Project
Hello world/Text

(format t "~a" "Hello world!") </lang> Output:

Hello world!

Component Pascal

<lang oberon2> MODULE Hello; IMPORT Out;

PROCEDURE Do*; BEGIN Out.String("Hello world!"); Out.Ln END Do; END Hello.</lang> Run command Hello.Do by commander.

Corescript

<lang Corescript>print Hello world!</lang>

Cowgol

<lang cowgol>include "cowgol.coh"; print("Hello world!"); print_nl();</lang>


Crack

<lang crack> import crack.io cout; cout `Hello world!\n`; </lang>

Creative Basic

<lang Creative Basic> OPENCONSOLE

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. DO:UNTIL INKEY$<>""

CLOSECONSOLE

END </lang>

Crystal

<lang ruby>puts "Hello world!"</lang>

D

Works with: D version 2.0

<lang D>import std.stdio;

void main() {

   writeln("Hello world!");

}</lang>

Dafny

<lang dafny> method Main() {

 print "hello, world!\n";
 assert 10 < 2;

} </lang>

Dao

<lang dao>io.writeln( 'Hello world!' )</lang>

Dart

<lang dart>main() {

   var bye = 'Hello world!';
   print("$bye");

}</lang>

DataWeave

<lang DataWeave>"Hello world!"</lang>

Dc

<lang dc>[Hello world!]p</lang> ...or print a numerically represented string. <lang dc>5735816763073014741799356604682 P</lang>

DCL

<lang DCL>$ write sys$output "Hello world!"</lang>

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.

<lang ddnc> 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 64 </lang>

Delphi

<lang delphi> program ProjectGoodbye; {$APPTYPE CONSOLE} begin

 WriteLn('Hello world!');

end. </lang>

DeviousYarn

<lang deviousyarn>o:"Hello world!</lang>

DIBOL-11

<lang DIBOL-11>

         START     ;Hello World
         RECORD  HELLO

, A11, 'Hello World'

         PROC
         XCALL FLAGS (0007000000,1)          ;Suppress STOP message
         OPEN(8,O,'TT:')
         WRITES(8,HELLO)
         END

</lang>

DIV Games Studio

<lang div> PROGRAM HELLOWORLD;

BEGIN

   WRITE_TEXT(0,160,100,4,"HELLO WORLD!");
   LOOP
       FRAME;
   END

END

</lang>

DM

<lang DM> /client/New()

   ..()
   src << "Hello world!"

</lang>

Dragon

<lang dragon> showln "Hello world!" </lang>

DWScript

<lang delphi> PrintLn('Hello world!'); </lang>

Dyalect

<lang Dyalect>print("Hello world!")</lang>

Dylan

<lang Dylan> module: hello-world

format-out("%s\n", "Hello world!"); </lang>

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: <lang Dylan.NET>Console::WriteLine("Hello world!")</lang>

Hello World Program: <lang Dylan.NET> //compile using the new dylan.NET v, 11.5.1.2 or later //use mono to run the compiler

  1. refstdasm mscorlib.dll

import System

assembly helloworld exe ver 1.2.0.0

class public Program

  method public static void main()
     Console::WriteLine("Hello world!")
  end method

end class </lang>

Déjà Vu

<lang dejavu>!print "Hello world!"</lang>

E

<lang e>println("Hello world!")

stdout.println("Hello world!")</lang>

EasyLang

<lang>print "Hello world!"</lang>

eC

<lang ec>class GoodByeApp : Application {

  void Main()
  {
     PrintLn("Hello world!");
  }

}</lang>

EchoLisp

<lang lisp> (display "Hello world!" "color:blue") </lang>

ECL

<lang ECL> OUTPUT('Hello world!'); </lang>

EDSAC order code

The EDSAC did not support lower-case letters. The method used here is to include a separate O order to print each character: for short messages and labels this is quite adequate. A more general (though slightly more involved) solution for printing strings is given at Hello world/Line printer#EDSAC order code. <lang edsac>[ Print HELLO WORLD ] [ A program for the EDSAC ] [ Works with Initial Orders 2 ]

T64K [ Set load point: address 64 ] GK [ Set base address ] O13@ [ Each O order outputs one ] O14@ [ character. The numerical ] O15@ [ parameter gives the offset ] O16@ [ (from the base address) where ] O17@ [ the character to print is ] O18@ [ stored ] O19@ O20@ O21@ O22@ O23@ O24@ ZF [ Stop ]

  • F [ Shift to print letters ]

HF [ Character literals ] EF LF LF OF !F [ Space character ] WF OF RF LF DF EZPF [ Start program beginning at

       the load point ]</lang>
Output:
HELLO WORLD

Efene

short version (without a function)

<lang efene>io.format("Hello world!~n")</lang>

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

<lang efene>@public run = fn () {

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

}</lang>

Egel

<lang Egel> def main = "Hello World!" </lang>

Egison

<lang egison> (define $main

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

</lang>

EGL

Works with: EDT
Works with: RBD

<lang EGL> program HelloWorld

   function main()
       SysLib.writeStdout("Hello world!");
   end

end </lang>

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)

<lang eiffel>class

   HELLO_WORLD

create

   make

feature

   make
       do
           print ("Hello world!%N")
       end

end</lang>

Ela

<lang ela>open monad io do putStrLn "Hello world!" ::: IO</lang>

elastiC

From the elastiC Manual.

<lang elastic>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
   hello();</lang>

Elena

ELENA 4.x: <lang elena>public program() {

   console.writeLine:"Hello world!"

}</lang>

Elisa

<lang elisa> "Hello world!"? </lang>

Elixir

<lang elixir> IO.puts "Hello world!" </lang>

Elm

<lang haskell>main = text "Goodbye World!"</lang>

Emacs Lisp

<lang lisp>(insert "Hello world!")</lang>

Emojicode

<lang emojicode>🏁 🍇

 😀 🔤Hello world!🔤

🍉</lang>

Erlang

<lang erlang>io:format("Hello world!~n").</lang>

ERRE

<lang ERRE> ! Hello World in ERRE language PROGRAM HELLO BEGIN

 PRINT("Hello world!")

END PROGRAM </lang>

Euler Math Toolbox

"Hello world!"

Extended BrainF***

<lang bf>[.>]@Hello world!</lang>

Ezhil

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

F#

<lang fsharp>printfn "%s" "Hello world!"</lang> or using .Net classes directly <lang fsharp>System.Console.WriteLine("Hello world!")</lang>

Factor

<lang factor>"Hello world!" print</lang>

Falcon

With the printl() function: <lang falcon>printl("Hello world!")</lang> Or via "fast print": <lang falcon>> "Hello world!"</lang>

FALSE

<lang false>"Hello world! "</lang>

Fantom

<lang fantom> class HelloText {

 public static Void main ()
 {
   echo ("Hello world!")
 }

} </lang>

ferite

word.}} <lang ferite>uses "console"; Console.println( "Goodby, World!" );</lang>

Fexl

<lang Fexl>say "Hello world!"</lang>

Fish

Standard Hello, world example, modified for this task: <lang Fish>!v"Hello world!"r!

>l?!;o</lang>

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.

FOCAL

<lang focal>TYPE "Hello, world" !</lang>

Forth

<lang forth>." Hello world!"</lang>

Or as a whole program:

<lang forth>: goodbye ( -- ) ." Hello world!" CR ;</lang>

Fortran

Works with: F77

Simplest case - display using default formatting:

<lang fortran>print *,"Hello world!"</lang>

Use explicit output format:

<lang fortran>100 format (5X,A,"!")

     print 100,"Hello world!"</lang>

Output to channels other than stdout goes like this:

<lang fortran>write (89,100) "Hello world!"</lang>

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". Template:7*7

Fortress

<lang fortress>export Executable

run() = println("Hello world!")</lang>

FreeBASIC

<lang FreeBASIC>? "Hello world!" sleep</lang>

Frege

Works with: Frege version 3.20.113

<lang frege>module HelloWorld where main _ = println "Hello world!"</lang>

friendly interactive shell

Unlike other UNIX shell languages, fish doesn't support history substitution, so ! is safe to use without quoting. <lang fishshell>echo Hello world!</lang>

Frink

<lang frink> println["Hello world!"] </lang>

FunL

<lang funl>println( 'Hello world!' )</lang>


Furor

<lang Furor>."Hello, World!\n"</lang>

FUZE BASIC

<lang qbasic>PRINT "Hello world!"</lang>

Gambas

Click this link to run this code <lang gambas>Public Sub Main()

PRINT "Hello world!"

End</lang>

GAP

<lang 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"); CloseStream(f);</lang>

GB BASIC

<lang GB BASIC>10 print "Hello world!"</lang>

gecho

<lang gecho>'Hello, <> 'World! print</lang>

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.

<lang gema>*= ! ignore off content of input \B=Hello world!\! ! Start output with this text.</lang>

Genie

<lang Genie> init

   print "Hello world!"

</lang>

Gentee

<lang gentee>func hello <main> {

  print("Hello world!")

}</lang>

GFA Basic

<lang gfabasic>PRINT "Hello World"</lang>

GLBasic

<lang GLBasic>STDOUT "Hello world!"</lang>

Glee

<lang glee>"Hello world!"</lang>

or

<lang glee>'Hello world!'</lang>

or to display with double quotes

<lang glee> '"Goodbye,World!"'</lang>

or to display with single quotes

<lang glee> "'Goodbye,World!'"</lang>

Global Script

This uses the gsio I/O operations, which are designed to be simple to implement on top of Haskell and simple to use. <lang Global Script>λ _. print qq{Hello world!\n}</lang>

GlovePIE

<lang glovepie>debug="Hello world!"</lang>

GML

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

Go

<lang go>package main

import "fmt"

func main() { fmt.Println("Hello world!") }</lang>

Golfscript

<lang golfscript>"Hello world!"</lang>

Gosu

<lang gosu>print("Hello world!")</lang>

Groovy

<lang groovy>println "Hello world!"</lang>

GW-BASIC

<lang qbasic>10 PRINT "Hello world!"</lang>

Hack

<lang hack><?hh echo 'Hello world!'; ?></lang>

Halon

If the code in run in the REPL the output will be to stdout otherwise syslog LOG_DEBUG will be used.

<lang halon>echo "Hello world!";</lang>

Harbour

<lang visualfoxpro>? "Hello world!"</lang>

Haskell

<lang haskell> main = putStrLn "Hello world!" </lang>

Haxe

<lang ActionScript>trace("Hello world!");</lang>

hexiscript

<lang hexiscript>println "Hello world!"</lang>

HicEst

<lang hicest>WRITE() 'Hello world!'</lang>

HLA

<lang HLA>program goodbyeWorld;

  1. include("stdlib.hhf")

begin goodbyeWorld;

 stdout.put( "Hello world!" nl );

end goodbyeWorld;</lang>

HolyC

<lang holyc>"Hello world!\n";</lang>

Hoon

<lang Hoon>~& "Hello world!" ~</lang>

HPPPL

<lang HPPPL>PRINT("Hello world!");</lang>

HQ9+

This example is incorrect. Please fix the code and remove this message.

Details: output isn't consistent with the task's requirements (and is probably incapable of solving the task).

<lang hq9plus>H</lang>

  • 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!)

Huginn

<lang huginn>#! /bin/sh exec huginn --no-argv -E "${0}" "${@}"

  1. ! huginn

main() { print( "Hello World!\n" ); return ( 0 ); }</lang>

Hy

<lang clojure>(print "Hello world!")</lang>

i

<lang i>software {

   print("Hello world!")

}</lang>

Icon and Unicon

<lang icon>procedure main()

 write( "Hello world!" )

end</lang>

IDL

<lang idl>print,'Hello world!'</lang>

Inform 6

<lang Inform 6>[Main;

 print "Hello world!^";

];</lang>

Inko

<lang inko>import std::stdio::stdout

stdout.print('Hello, world!')</lang>

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.

<lang Integer BASIC> 10 PRINT "Hello world!"

  20 END</lang>

Io

<lang Io>"Hello world!" println</lang>

Ioke

<lang ioke>"Hello world!" println</lang>

IS-BASIC

<lang IS-BASIC>PRINT "Hello world!"</lang>

Isabelle

<lang Isabelle>theory Scratch

 imports Main

begin

 value ‹Hello world!

end</lang>

IWBASIC

<lang IWBASIC> OPENCONSOLE

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. DO:UNTIL INKEY$<>""

CLOSECONSOLE

END </lang>

J

<lang j> 'Hello world!' Hello world!</lang>

Here are some redundant alternatives: <lang J> [data=. 'Hello world!' Hello world!

  data

Hello world!

  smoutput data

Hello world!

  NB. unassigned names are verbs of infinite rank awaiting definition.
  NB. j pretty prints the train.
  Hello World!

Hello World !


  NB. j is glorious, and you should know this!
  i. 2 3   NB. an array of integers

0 1 2 3 4 5

  verb_with_infinite_rank =: 'Hello world!'"_
  verb_with_infinite_rank i. 2 3

Hello world!


  verb_with_atomic_rank =: 'Hello world!'"0
  verb_with_atomic_rank i. 2 3

Hello world! Hello world! Hello world!

Hello world! Hello world! Hello world! </lang>

Jack

<lang jack>class Main {

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

}</lang>

Jacquard Loom

This weaves the string "Hello world!" <lang jacquard>+---------------+ | | | * * | |* * * * | |* * *| |* * *| |* * * | | * * * | | * | +---------------+

+---------------+ | | |* * * | |* * * | | * *| | * *| |* * * | |* * * * | | * | +---------------+

+---------------+ | | |* ** * * | |******* *** * | | **** * * ***| | **** * ******| | ****** ** * | | * * * * | | * | +---------------+

+---------------+ | | |******* *** * | |******* *** * | | ** *| |* * * *| |******* ** * | |******* *** * | | * | +---------------+

+---------------+ | | |******* *** * | |******* *** * | | * * * *| | * * * *| |******* ** * | |******* ** * | | * | +---------------+

+---------------+ | | |***** * *** * | |******* *** * | | * * * * | | * * * | |****** ** * | |****** ** * | | * | +---------------+

+---------------+ | | | * * * | |***** * ***** | |***** ** * ***| |***** ** * ***| |******* * ** | | * * * * | | * | +---------------+

+---------------+ | | | | | * * | | * * | | * | | * | | | | | +---------------+</lang>

Java

<lang java>public class HelloWorld {

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

}</lang>

JavaScript

<lang javascript>document.write("Hello world!");</lang>

Works with: NJS version 0.2.5
Works with: Rhino
Works with: SpiderMonkey

<lang javascript>print('Hello world!');</lang>

Works with: JScript

<lang javascript>WScript.Echo("Hello world!");</lang>

Works with: Node.js

<lang javascript>console.log("Hello world!")</lang>

JCL

<lang JCL>/*MESSAGE Hello world!</lang>

Joy

<lang joy>"Hello world!" putchars.</lang>

jq

<lang jq>"Hello world!"</lang>

Jsish

<lang javascript>puts("Hello world!")</lang>

Julia

<lang Julia>println("Hello world!")</lang>

K

<lang K> "Hello world!" </lang> Some of the other ways this task can be attached are: <lang K> `0: "Hello world!\n" </lang> <lang K> s: "Hello world!" s </lang> <lang K> \echo "Hello world!" </lang>

Kabap

<lang Kabap>return = "Hello world!";</lang>

Kaya

<lang kaya>program hello;

Void main() {

   // My first program!
   putStrLn("Hello world!");

}</lang>

Kdf9 Usercode

This example is incorrect. Please fix the code and remove this message.

Details: output isn't consistent with the task's requirements: wording, punctuation.

<lang joy>

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;

  FINISH;

</lang>

Keg

<lang keg>Hello world\!</lang>

Kite

simply a single line <lang Kite>"#!/usr/local/bin/kite

"Hello world!"|print;</lang>

Kitten

<lang Kitten>"Hello world!" say</lang>

Koka

<lang koka>fun main() {

 println("Hello world!")

}</lang>

KonsolScript

Displays it in a text file or console/terminal. <lang KonsolScript>function main() {

 Konsol:Log("Hello world!")

}</lang>

Kotlin

<lang Kotlin>fun main() {

   println("Hello world!")

}</lang>

KQL

<lang KQL>print 'Hello world!'</lang>

Lambdatalk

<lang scheme> Hello world! {h1 Hello world!} _h1 Hello world!\n </lang>

Lang5

<lang Lang5>"Hello world!\n" .</lang>

langur

<lang langur>writeln "yo, peeps"</lang>

Lasso

A plain string is output automatically. <lang Lasso>'Hello world!'</lang>

LaTeX

<lang LaTeX> \documentclass{scrartcl}

\begin{document} Hello World! \end{document} </lang>

Latitude

<lang Latitude>putln "Hello world!".</lang>

LC3 Assembly

<lang lc3asm>.orig x3000 LEA R0, hello  ; R0 = &hello TRAP x22  ; PUTS (print char array at addr in R0) HALT hello .stringz "Hello World!" .end</lang> Or (without PUTS) <lang lc3asm>.orig x3000 LEA R1, hello  ; R1 = &hello TOP LDR R0, R1, #0  ; R0 = R1[0] BRz END  ; if R0 is string terminator (x0000) go to END TRAP x21  ; else OUT (write char in R0) ADD R1, R1, #1  ; increment R1 BR TOP  ; go to TOP END HALT hello .stringz "Hello World!" .end</lang>

LDPL

<lang LDPL> procedure: display "Hello World!" crlf </lang>

LFE

<lang lisp> (: io format '"Hello world!~n") </lang>

Liberty BASIC

<lang lb>print "Hello world!"</lang>

LIL

<lang tcl>#

  1. Hello world in lil

print "Hello, world!"</lang>

Lily

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

<lang lily>print("Hello world!")</lang>

Second, by using stdout directly:

<lang lily>stdout.print("Hello world!\n")</lang>

Lilypond

<lang lilypond>\version "2.18.2" global = {

 \time 4/4
 \key c \major
 \tempo 4=100

} \relative c{ g e e( g2) } \addlyrics {

 Hel -- lo,   World!

}</lang>

Limbo

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

Lingo

<lang lingo>put "Hello world!"</lang>

or:

<lang lingo>trace("Hello world!")</lang>

Lisaac

Works with: Lisaac version 0.13.1

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

<lang lisaac>Section Header // The Header section is required.

 + name := GOODBYE;    // Define the name of this object.

Section Public

 - main <- ("Hello world!\n".print;);</lang>

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

<lang lisaac>Section Header // The Header section is required.

 + name := GOODBYE2;   // Define the name of this object.

Section Public

 - main <- (IO.put_string "Hello world!\n";);</lang>

Little

Output to terminal: <lang c>puts("Hello world!");</lang>

Without the newline terminator:

<lang c>puts(nonewline: "Hello world!");</lang>

Output to arbitrary open, writable file, for example the standard error channel: <lang c>puts(stderr, "Hello world!");</lang>

LiveCode

Examples using the full LiveCode IDE.

Text input and output done in the Message palette/window: <lang LiveCode>put "Hello World!"</lang>

Present a dialog box to the user <lang LiveCode>Answer "Hello World!"</lang>

Example using command-line livecode-server in shell script <lang LiveCode>#! /usr/local/bin/livecode-server set the outputLineEndings to "lf" put "Hello world!" & return</lang>

Livecode also supports stdout as a device to write to <lang LiveCode>write "Hello world!" & return to stdout</lang>

LLVM

<lang llvm>

const char str[14] = "Hello World!\00"

@.str = private unnamed_addr constant [14 x i8] c"Hello, world!\00"

declare extern `puts` method

declare i32 @puts(i8*) nounwind

define i32 @main() {

 call i32 @puts( i8* getelementptr ([14 x i8]* @str, i32 0,i32 0))
 ret i32 0

}</lang>

Lobster

<lang lobster>print "Hello world!"</lang>

Print includes a line feed: <lang logo>print [Hello world!]</lang> Type does not: <lang logo>type [Hello world!]</lang>

Logtalk

<lang 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.</lang>

LOLCODE

<lang LOLCODE> HAI CAN HAS STDIO? VISIBLE "Hello world!" KTHXBYE </lang>

LotusScript

<lang 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.</lang>

LSE

<lang lse>AFFICHER [U, /] 'Hello world!'</lang>

LSE64

<lang lse64>"Hello world!" ,t nl</lang>

Lua

Function calls with either a string literal or a table constructor passed as their only argument do not require parentheses. <lang lua>print "Hello world!"</lang>

Harder way with a table: <lang lua> local chars = {"G","o","o","d","b","y","e",","," ","W","o","r","l","d","!"} for i = 1, #chars do write(chars[i]) end </lang>

Luna

<lang luna>def main:

   hello = "Hello, World!"
   print hello</lang>

M2000 Interpreter

<lang M2000 Interpreter> Print "Hello World!" \\ printing on columns, in various ways defined by last $() for specific layer Print $(4),"Hello World!" \\ proportional printing using columns, expanded to a number of columns as the length of string indicates. Report "Hello World!" \\ proportional printing with word wrap, for text, can apply justification and rendering a range of text lines </lang>

M4

For the particular nature of m4, this is simply: <lang m4>`Hello world!'</lang>

Maclisp

<lang lisp>(format t "Hello world!~%")</lang> Or <lang lisp>(print "Hello world!")</lang>

MAD

<lang MAD> VECTOR VALUES HELLO = $11HHELLO WORLD*$

          PRINT FORMAT HELLO
          END OF PROGRAM</lang>

make

Makefile contents: <lang make> all: $(info Hello world!) </lang> Running make produces:

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

Malbolge

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

Short version: <lang malbolge>(=<`#9]~6ZY32Vx/4Rs+0No-&Jk)"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc</lang>

Output:
HELLO WORLD!

MANOOL

In “applicative” notation: <lang MANOOL>{{extern "manool.org.18/std/0.3/all"} in WriteLine[Out; "Hello world!"]}</lang> OOPish notation (equivalent to the above, up to Abstract Syntax Tree): <lang MANOOL>{{extern "manool.org.18/std/0.3/all"} in Out.WriteLine["Hello world!"]}</lang> LISPish notation (ditto): <lang MANOOL>{{extern "manool.org.18/std/0.3/all"} in {WriteLine Out "Hello world!"}}</lang> Using a colon punctuator (ditto): <lang MANOOL>{{extern "manool.org.18/std/0.3/all"} in: WriteLine Out "Hello world!"}</lang> Note that all semicolons, wherever allowed, are optional. The above example with all possible semicolons: <lang MANOOL>{{extern; "manool.org.18/std/0.3/all"} in: WriteLine; Out; "Hello world!"}</lang>

Maple

<lang Maple> > printf( "Hello world!\n" ): # print without quotes Hello world! </lang>

Mathcad

Simply type the following directly onto a Mathcad worksheet (A worksheet is Mathcad's combined source code file & console). <lang ayrch>"Hello, World!"</lang> Applies to Mathcad Prime, Mathcad Prime Express and Mathcad 15 (and earlier)

Mathematica / Wolfram Language

<lang mathematica>Print["Hello world!"]</lang>

MATLAB

<lang MATLAB>>> disp('Hello world!')</lang>


Maude

<lang Maude> fmod BYE-WORLD is

protecting STRING .

op sayBye : -> String .

eq sayBye = "Hello world!" .

endfm

red sayBye . </lang>

Maxima

<lang maxima>print("Hello world!");</lang>

MAXScript

<lang maxscript>print "Hello world!"</lang> or: <lang maxscript>format "%" "Hello world!"</lang>

MDL

<lang mdl><PRINC "Hello world!"> <CRLF></lang>

MelonBasic

<lang MelonBasic>Say:Hello world!</lang>

Mercury

<lang mecury>:- module hello.

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

main(!IO) :-

   io.write_string("Hello world!\n", !IO).</lang>

Metafont

<lang metafont>message "Hello world!"; end</lang>

min

<lang min>"Hello world!" puts</lang>

MiniScript

<lang MiniScript>print "Hello world!"</lang>

MiniZinc

<lang MiniZinc> output ["Hello World"]; </lang>

Output:
Hello World
----------

MIPS Assembly

Works with: MARS

and

Works with: SPIM

<lang mips> .data #section for declaring variables hello: .asciiz "Hello world!" #asciiz automatically adds the null terminator. If it's .ascii it doesn't have it.

  .text # beginning of code

main: # a label, which can be used with jump and branching instructions.

  la $a0, hello # load the address of hello into $a0
  li $v0, 4 # set the syscall to print the string at the address $a0
  syscall # make the system call
  li $v0, 10 # set the syscall to exit
  syscall # make the system call</lang>

mIRC Scripting Language

<lang mirc>echo -ag Hello world!</lang>

ML/I

<lang ML/I>Hello world!</lang>

Modula-2

<lang modula2>MODULE Hello; IMPORT InOut;

BEGIN

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

END Hello.</lang>

Modula-3

<lang modula3>MODULE Goodbye EXPORTS Main;

IMPORT IO;

BEGIN

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

END Goodbye.</lang>

MontiLang

<lang MontiLang>|Hello, World!| PRINT .</lang>

Morfa

<lang morfa> import morfa.io.print; func main(): void {

   println("Hello world!");

} </lang>

Mosaic

<lang mosaic>proc start =

     println "Hello, world"

end</lang>

MUF

<lang muf>: main[ -- ] me @ "Hello world!" notify exit

</lang>

MUMPS

<lang MUMPS>Write "Hello world!",!</lang>

MyDef

Run with:

mydef_run hello.def

Perl: <lang MyDef>$print Hello world</lang>

C: <lang MyDef> module: c $print Hello world </lang>

python: <lang MyDef> module: python $print Hello world </lang>

JavaScript <lang MyDef> module: js $print "Hello world" </lang>

go: <lang MyDef> module: go $print Hello world </lang>

MyrtleScript

<lang MyrtleScript>script HelloWorld {

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

} </lang>

MySQL

<lang MySQL>SELECT 'Hello world!';</lang>

Mythryl

<lang Mythryl>print "Hello world!";</lang>

N/t/roff

To get text output, compile the source file using NROFF and set output to the text terminal. If you compile using TROFF, you will get graphical output suitable for typesetting on a graphical typesetter/printer instead.

Because /.ROFF/ is a document formatting language, the majority of input is expected to be text to output onto a medium. Therefore, there are no routines to explicitly call to print text.

<lang N/t/roff>Hello world!</lang>

Nanoquery

<lang nanoquery>println "Hello world!"</lang>

Neat

<lang Neat>void main() writeln "Hello world!";</lang>

Neko

<lang neko>$print("Hello world!");</lang>

Nemerle

<lang Nemerle> class Hello {

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

} </lang> Easier method: <lang Nemerle> System.Console.WriteLine("Hello world!"); </lang>

NetRexx

<lang NetRexx>say 'Hello world!'</lang>

Never

<lang fsharp>func main() -> int {

   prints("Hello world!\n");
   0

}</lang>

Output:
prompt$ never -f hello.nev
Hello world!

newLISP

Works with: newLisp version 6.1 and after

<lang lisp>(println "Hello world!")</lang>

Nickle

<lang c>printf("Hello world!\n")</lang>

Nim

<lang python>echo("Hello world!")</lang>

Nit

<lang nit>print "Hello world!"</lang>

NS-HUBASIC

As lowercase characters are not offered in NS-HUBASIC, perhaps some flexibility in the task specification could be offered.

Using ?: <lang NS-HUBASIC>10 ? "HELLO WORLD!"</lang>

Using PRINT: <lang NS-HUBASIC>10 PRINT "HELLO WORLD!"</lang>

Nyquist

Interpreter: Nyquist (3.15)

LISP syntax

<lang lisp>(format t "Hello world!")</lang>

Or

<lang lisp>(print "Hello world!")</lang>

SAL syntax

<lang SAL>print "Hello World!"</lang>

Or

<lang SAL>exec format(t, "Hello World!")</lang>

Oberon-2

<lang oberon2> MODULE Goodbye; IMPORT Out;

 PROCEDURE World*;
 BEGIN
   Out.String("Hello world!");Out.Ln
 END World;

BEGIN

 World;

END Goodbye. </lang>

Objeck

<lang objeck> class Hello {

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

}</lang>

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:

<lang objc>

  1. import <Foundation/Foundation.h>

int main() {

   @autoreleasepool {
       NSLog(@"Hello, World!");
   }

} </lang>

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:

<lang objc>

  1. import <Foundation/Foundation.h>

int main() {

   @autoreleasepool {
       NSFileHandle *standardOutput = [NSFileHandle fileHandleWithStandardOutput];
       NSString *message = @"Hello, World!\n";
       [standardOutput writeData:[message dataUsingEncoding:NSUTF8StringEncoding]];
   }

} </lang>

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.

<lang objc>

  1. import <Foundation/Foundation.h>

int main() {

   @autoreleasepool {
       NSString *message = @"Hello, World!\n";
       printf("%s", message.UTF8String);
   }

} </lang>

OCaml

<lang ocaml>print_endline "Hello world!"</lang>

Occam

Works with: kroc

<lang occam>#USE "course.lib" PROC main (CHAN BYTE screen!)

 out.string("Hello world!*c*n", 0, screen)
</lang>

Octave

<lang octave>disp("Hello world!");</lang>

Or, using C-style function printf:

<lang octave>printf("Hello world!");</lang>

Oforth

<lang Oforth>"Hello world!" .</lang>

Ol

<lang scheme>(print "Hello world!")</lang>

Onyx

<lang onyx>`Hello world!\n' print flush</lang>

OOC

To print a String, either call its println() method: <lang ooc>main: func {

 "Hello world!" println()

}</lang> Or call the free println() function with the String as the argument. <lang ooc>main: func {

 println("Hello world!")

}</lang>

ooRexx

Refer also to the Rexx and NetRexx solutions. Simple output is common to most Rexx dialects. <lang ooRexx>/* Rexx */ say 'Hello world!' </lang>

OpenLisp

We can use the same code as the Common Lisp example, but as a shell script. <lang openlisp>

  1. !/openlisp/uxlisp -shell

(format t "Hello world!~%") (print "Hello world!") </lang>

Output: Hello world! "Hello world!"

Openscad

<lang openscad> echo("Hello world!"); // writes to the console text("Hello world!"); // creates 2D text in the object space linear_extrude(height=10) text("Hello world!"); // creates 3D text in the object space </lang>

Oxygene

From wp:Oxygene (programming language) <lang oxygene> namespace HelloWorld;

interface

type

 HelloClass = class
 public
   class method Main; 
 end;

implementation

class method HelloClass.Main; begin

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

end;

end. </lang>

>HelloWorld.exe
Hello world!

Oz

<lang oz>{Show "Hello world!"}</lang>

PARI/GP

<lang parigp>print("Hello world!")</lang>

Pascal

Works with: Free Pascal

<lang pascal>program byeworld; begin

writeln('Hello world!');

end.</lang>

PASM

<lang pasm>print "Hello world!\n" end</lang>

PDP-1 Assembly

This can be assembled with macro1.c distributed with SIMH and then run on the SIMH PDP-1 simulator. <lang assembly> hello / above: title line - was punched in human readable letters on paper tape / below: location specifier - told assembler what address to assemble to 100/ lup, lac i ptr / load ac from address stored in pointer cli / clear io register lu2, rcl 6s / rotate combined ac + io reg 6 bits to the left / left 6 bits in ac move into right 6 bits of io reg tyo / type out character in 6 right-most bits of io reg sza / skip next instr if accumulator is zero jmp lu2 / otherwise do next character in current word idx ptr / increment pointer to next word in message sas end / skip next instr if pointer passes the end of message jmp lup / otherwise do next word in message hlt / halt machine ptr, msg / pointer to current word in message msg, text "hello, world" / 3 6-bit fiodec chars packed into each 18-bit word end, . / sentinel for end of message start 100 / tells assembler where program starts </lang>

PDP-11 Assembly

This is Dennis Ritchie's Unix Assembler ("as"). Other PDP-11 assemblers include PAL-11R, PAL-11S and MACRO-11.

Works with: UNIX version 1

to

Works with: UNIX version 7

<lang assembly>.globl start .text start:

       mov	$1,r0               / r0=stream, STDOUT=$1

sys 4; outtext; outlen / sys 4 is write sys 1 / sys 1 is exit rts pc / in case exit returns

.data outtext: <Hello world!\n> outlen = . - outtext</lang>

PepsiScript

The letters are only outputted in uppercase in the running program. However, lowercase characters can be used in the code instead.

For typing: <lang PepsiScript>#include default-libraries

  1. author Childishbeat

class Hello world/Text: function Hello world/Text:

print "Hello world!"

end</lang> For importing:

•dl◘Childishbeat◙♦Hello world/Text♪♣Hello_world!♠

Perl

Works with: Perl version 5.8.8

<lang perl>print "Hello world!\n";</lang>

Works with: Perl version 5.10.x

Backported from Raku: <lang perl>use feature 'say'; say 'Hello world!';</lang>

or: <lang perl>use 5.010; say 'Hello world!';</lang>

Pharo

<lang pharo>"Comments are in double quotes" "Sending message printString to 'Hello World' string"

'Hello World' printString</lang>

Phix

<lang phix>puts(1,"Hello world!")</lang>

PHL

<lang phl>module helloworld; extern printf;

@Integer main [

   printf("Hello world!");
   return 0;

]</lang>

PHP

<lang php><?php echo "Hello world!\n"; ?></lang> Alternatively, any text outside of the <?php ?> tags will be automatically echoed: <lang php>Hello world!</lang>

PicoLisp

<lang PicoLisp>(prinl "Hello world!")</lang>

Pict

Using the syntax sugared version: <lang pict>(prNL "Hello World!");</lang> Using the channel syntax: <lang pict>new done: ^[] run ( prNL!["Hello World!" (rchan done)]

   | done?_ = () )</lang>

Pikachu

<lang pict>pikachu pika pikachu pika pika pi pi pika pikachu pika pikachu pi pikachu pi pikachu pi pika pi pikachu pikachu pi pi pika pika pikachu pika pikachu pikachu pi pika pi pika pika pi pikachu pikachu pi pikachu pi pika pikachu pi pikachu pika pikachu pi pikachu pikachu pi pikachu pika pika pikachu pi pikachu pi pi pikachu pikachu pika pikachu pi pika pi pi pika pika pikachu pikachu pi pi pikachu pi pikachu pikachu pikachu pi pikachu pikachu pika pika pikachu pika pikachu pikachu pika pika pikachu pikachu pi pi pikachu pika pikachu pika pika pi pika pikachu pikachu pi pika pika pikachu pi pika pi pika pi pikachu pi pikachu pika pika pi pi pika pi pika pika pikachu pikachu pika pikachu pikachu pika pi pikachu pika pi pikachu pi pika pika pi pikachu pika pi pika pikachu pi pi pikachu pika pika pi pika pi pikachu pikachu pikachu pi pikachu pikachu pika pi pika pika pikachu pika pikachu pi pikachu pi pi pika pi pikachu pika pi pi pika pikachu pi pikachu pi pi pikachu pikachu pika pikachu pikachu pika pi pikachu pi pika pikachu pi pikachu pika pika pikachu pika pi pi pikachu pikachu pika pika pikachu pi pika pikachu pikachu pi pika pikachu pikachu pika pi pi pikachu pikachu pi pikachu pi pikachu pi pikachu pi pika pikachu pi pikachu pika pikachu pi pika pi pikachu pi pika pikachu pikachu pi pikachu pika pi pikachu pikachu pi pikachu pikachu pi pikachu pi pi pikachu pi pikachu pika pikachu pikachu pi pikachu pikachu pika pi pi pika pikachu pika pikachu pi pi pikachu pika pi pi pikachu pika pika pi pika pika pikachu pika pikachu pi pi pika pikachu pika pi pikachu pikachu pi pikachu pika pikachu pikachu pika pi pi pikachu pikachu pi pika pikachu pi pikachu pika pikachu pikachu pika pi pikachu pikachu pika pikachu pi pikachu pika pika pi pikachu pi pika pi pikachu pikachu pi pikachu pi pika pikachu pikachu pi pikachu pikachu pikachu pi pika pikachu pi pika pika pi pi pika pi pikachu pi pika pi pika pi pika pikachu pika pi pi pikachu pi pikachu pi pika pi pika pika pikachu pi pikachu pikachu pikachu pi pikachu pikachu pi pikachu pika pikachu pi pika pi pikachu pikachu pika pika pi pi pikachu pi pika pi pikachu pi pika pikachu pi pika pi pi pikachu pikachu pika pika pikachu pikachu pi pi pikachu pi pikachu pi pikachu pi pi pikachu pikachu pi pikachu pi pikachu pi pika pika pikachu pikachu pika pi pika pikachu pi pikachu pi pi pika pikachu pika pi pikachu pi pika pi pi pikachu pikachu pika pika pikachu pika pika pikachu pi pika pi pika pikachu pi pika pikachu pika pi pika pikachu pikachu pikachu pika pikachu pikachu pikachu pika pikachu pi pi pikachu pi pikachu pika pika pi pikachu pika pika pi pi pika pika pikachu pi pi pikachu pi pika pi pika pikachu pi pikachu pi pikachu pikachu pi pi pika pika pi pika pika pi pika pikachu pikachu pi pikachu pika pi pi pika pi pi pikachu pikachu pika pi pi pika pika pi pika pikachu pi pikachu pi pi pika pi pika pika pikachu pika pi pika pikachu pi pikachu pikachu pi pi pika pi pika pika pikachu pikachu pi pikachu pikachu pikachu pi pikachu pikachu pi pikachu pikachu pika pikachu pikachu pika pika pikachu pikachu pika pikachu pi pika pikachu pika pika pi pikachu pi pi pika pi pi pikachu pika pika pikachu pikachu pika pikachu pikachu pi pika pi pi pikachu pikachu pika pi pi pikachu pikachu pika pikachu pika pi pikachu pi pika pi pika pikachu pika pi pikachu pi pikachu pikachu pi pika pikachu pi pikachu pikachu pi pika pi pikachu pikachu pi pikachu pika pika pi pi pikachu pikachu pi pi pika pi pi pikachu pika pikachu pikachu pika pika pi pi pika pikachu pi pikachu pi pi pika pi pika pi pi pika pikachu pi pika pi pikachu pika pikachu pika pi pi pika pi pi pikachu pi pikachu pikachu pika pi pikachu pi pi pika pi pikachu pi pi pika pi pi pikachu pika pikachu pika pikachu pika pi pikachu pikachu pi pi pika pika pikachu pikachu pikachu pi pikachu pikachu pikachu pika pikachu</lang>

Pike

<lang pike>int main(){

  write("Hello world!\n");

}</lang>

PILOT

<lang pilot>T:Hello world!</lang>

PIR

<lang pir>.sub hello_world_text :main print "Hello world!\n" .end</lang>

Pixilang

<lang Pixilang>fputs("Hello world!\n")</lang>

PL/I

<lang pli>goodbye:proc options(main);

    put list('Hello world!');

end goodbye;</lang>

PL/M

Assuming the existence of a WRITE$STRING library routine. <lang plm>HELLO_WORLD: DO;

   /* external I/O routines */
   WRITE$STRING: PROCEDURE( S ) EXTERNAL; DECLARE S POINTER; END WRITE$STRING;
   /* end external routines */
   MAIN: PROCEDURE;
       CALL WRITE$STRING( @( 'Hello world!', 0AH, 0 ) );
   END MAIN;

END HELLO_WORLD; </lang>

PL/SQL

Works with: Oracle

<lang plsql> set serveroutput on

BEGIN

 DBMS_OUTPUT.PUT_LINE('Hello world!');

END; / </lang>

SQL> set serveroutput on
SQL> 
SQL> BEGIN
  2    DBMS_OUTPUT.PUT_LINE('Hello world!');
  3  END;
  4  /
Hello world!                                                                    

PL/SQL procedure successfully completed.

Plain English

<lang plainenglish>\This prints Hello World within the CAL-4700 IDE. \...and backslashes are comments! To run: Start up. Write "Hello World!" to the console. Wait for the escape key. Shut down.</lang>

Plan

This prints HELLO WORLD on operator's console.

<lang plan>#STEER LIST,BINARY

  1. PROGRAM HLWD
  2. LOWER

MSG1A 11HHELLO WORLD MSG1B 11/MSG1A

  1. PROGRAM
  2. ENTRY 0
     DISTY    MSG1B
     SUSWT    2HHH
  1. END
  2. FINISH
  3. STOP</lang>

Pony

<lang pony>actor Main

 new create(env: Env) =>
   env.out.print("Hello world!")</lang>

Pop11

<lang pop11>printf('Hello world!\n');</lang>

PostScript

To generate a document that shows the text "Hello world!":

<lang postscript>%!PS /Helvetica 20 selectfont 70 700 moveto (Hello world!) show showpage</lang>

If the viewer has a console, then there are the following ways to display the topmost element of the stack:

<lang postscript>(Hello world!) ==</lang>

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

<lang postscript>(Hello world!) =</lang>

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

<lang postscript>(Hello world!) print</lang>

will do the same, without printing a newline. It may be necessary to provoke an error message to make the console pop up. The following program combines all four above variants:

<lang postscript>%!PS /Helvetica 20 selectfont 70 700 moveto (Hello world!) dup dup dup = print == % prints three times to the console show % prints to document 1 0 div % provokes error message showpage</lang>

Potion

<lang potion>"Hello world!\n" print</lang>

PowerBASIC

<lang powerbasic>#COMPILE EXE

  1. COMPILER PBCC 6

FUNCTION PBMAIN () AS LONG

 CON.PRINT "Hello world!"
 CON.WAITKEY$

END FUNCTION</lang>

PowerShell

This example used to say that using Write-Host was good practice. This is not true - it should in fact be avoided in most cases.

See http://www.jsnover.com/blog/2013/12/07/write-host-considered-harmful/ (Jeffrey Snover is one of the creators of PowerShell). <lang powershell>'Hello world!'</lang>

Processing

<lang processing>println("Hello world!");</lang>

ProDOS

<lang ProDOS>printline Hello world!</lang>

Programming Language

For typing: <lang Programming Language>print(Hello world!)</lang> For importing:

[print(Hello world!)]

Prolog

<lang prolog>:- write('Hello world!'), nl.</lang>

PSQL

 EXECUTE BLOCK
   RETURNS(S VARCHAR(40))
 AS
 BEGIN
   S = 'Hello world!';
   SUSPEND;
 END

Pure

<lang pure> using system;

puts "Hello world!\n" ; </lang>

PureBasic

<lang PureBasic>OpenConsole() PrintN("Hello world!") Input() ; Wait for enter</lang>

Python

Works with: Python version 2.4

<lang python>print "Hello world!"</lang>

The same using sys.stdout <lang python>import sys sys.stdout.write("Hello world!\n")</lang>

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

Works with: Python version 3.0

(And version 2.X too).

<lang python>print("Hello world!")</lang>

An easter egg The first two examples print Hello, world! once, and the last one prints it twice. <lang python>import __hello__</lang>

<lang python>import __phello__</lang>

<lang python>import __phello__.spam</lang>

QB64

<lang qbasic>PRINT "Hello world!"</lang>

Quackery

<lang quackery>say "Hello world!"</lang>

Quill

<lang quill>"Hello world!" print</lang>

Quite BASIC

<lang Quite BASIC>10 print "Hello world!"</lang>

R

<lang R> cat("Hello world!\n")</lang> or <lang R> message("Hello world!")</lang> or <lang R> print("Hello world!")</lang>

Ra

<lang Ra> class HelloWorld **Prints "Hello world!"**

on start

print "Hello world!" </lang>

Racket

<lang Racket> (printf "Hello world!\n") </lang>

Raku

(formerly Perl 6) <lang perl6>say 'Hello world!';</lang> In an object-oriented approach, the string is treated as an object calling its say() method: <lang perl6>"Hello, World!".say();</lang>

Raven

<lang raven>'Hello world!' print</lang>

REALbasic

Works with: REALbasic version 5.5

This requires a console application.

<lang realbasic>Function Run(args() as String) As Integer

 Print "Hello world!"
 Quit

End Function</lang>

REBOL

<lang REBOL>print "Hello world!"</lang>

RED

<lang RED>print "Hello world!"</lang>

Retro

<lang Retro> 'Hello_world! s:put </lang>

Relation

<lang Relation> ' Hello world! </lang>

REXX

using SAY

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

using SAY variable

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

using LINEOUT

<lang rexx>/*REXX program to show a line of text. */

call lineout ,"Hello world!"</lang>

Ring

<lang ring>See "Hello world!"</lang>

Risc-V

<lang Risc-V>.data hello: .string "Hello World!\n\0" .text main: la a0, hello li a7, 4 ecall li a7, 10 ecall </lang>

RTL/2

<lang RTL/2>TITLE Goodbye World;

LET NL=10;

EXT PROC(REF ARRAY BYTE) TWRT;

ENT PROC INT RRJOB();

   TWRT("Hello world!#NL#");
   RETURN(1);

ENDPROC;</lang>

Ruby

Works with: Ruby version 1.8.4

<lang ruby>puts "Hello world!"</lang> or <lang ruby>$stdout.puts "Hello world!"</lang> or even <lang ruby> STDOUT.write "Hello world!\n"</lang>


Using the > global <lang ruby>$>.puts "Hello world!"</lang> <lang ruby>$>.write "Hello world!\n"</lang>

Run BASIC

<lang Runbasic>print "Hello world!"</lang>

Rust

<lang rust> fn main() {

  print!("Hello world!");

} </lang>

or

<lang rust> fn main() {

  println!("Hello world!");

} </lang>

Salmon

<lang Salmon>"Hello world!"!</lang>

or

<lang Salmon>print("Hello world!\n");</lang>

or

<lang Salmon>standard_output.print("Hello world!\n");</lang>

SAS

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

SASL

Note that a string starts with a single and ends with a double quote <lang SASL> 'Hello World!",nl </lang>

Sather

<lang sather>class GOODBYE_WORLD is

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

end;</lang>

Scala

Library: Console

Ad hoc REPL solution

Ad hoc solution as REPL script. Type this in a REPL session: <lang Scala>println("Hello world!")</lang>

Via Java runtime

This is a call to the Java run-time library. Not recommended. <lang Scala>System.out.println("Hello world!")</lang>

Via Scala Console API

This is a call to the Scala run-time library. Recommended. <lang Scala>println("Hello world!")</lang>

Short term deviation to out

<lang Scala>Console.withErr(Console.out) { Console.err.println("This goes to default _out_") }</lang>

Long term deviation to out

<lang Scala> Console.err.println ("Err not deviated")

 Console.setErr(Console.out)
 Console.err.println ("Err deviated")
 Console.setErr(Console.err) // Reset to normal</lang>

Scheme

All Scheme implementations display the value of the last evaluated expression before the program terminates. <lang scheme>"Hello world!"</lang>

The display and newline procedures are found in specific modules of the standard library in R6RS and R7RS. The previous standards have no concept of modules and the entirety of the standard library is loaded by default.

R5RS

<lang scheme>(display "Hello world!") (newline)</lang>

R6RS

<lang scheme>(import (rnrs base (6))

       (rnrs io simple (6)))

(display "Hello world!") (newline)</lang>

R7RS

<lang scheme>(import (scheme base)

       (scheme write))

(display "Hello world!") (newline)</lang>

Scilab

<lang Scilab>disp("Hello world!");</lang>

ScratchScript

<lang ScratchScript>print "Hello world!"</lang> This example waits until the mouse is clicked for the program to end. This can be useful if the program executes too fast for "Hello world!" to be visible on the screen long enough for it to be comfortable. <lang ScratchScript>print "Hello world!" delayOnClick</lang>

sed

<lang sed>i\ Hello world! q</lang>

Seed7

<lang seed7>$ include "seed7_05.s7i";

const proc: main is func

 begin
   writeln("Hello world!");
 end func;</lang>

Self

<lang self>'Hello world!' printLine.</lang>

SenseTalk

<lang sensetalk>put "Hello world!"</lang>

Set lang

<lang set_lang>set ! H set ! E set ! L set ! L set ! O set ! 32 set ! W set ! O set ! R set ! L set ! D set ! 33</lang>

SETL

<lang SETL>print("Hello world!");</lang>

SETL4

<lang SETL4>out("Hello world!");end</lang>

Shen

<lang Shen>(output "Hello world!~%")</lang>

Shiny

<lang shiny>say 'Hello world!'</lang>

Sidef

<lang sidef>„Hello world!”.say;</lang>

SimpleCode

The letters are only outputted in uppercase in the running program. However, lowercase characters can be used in the code instead. <lang SimpleCode>dtxt Hello world!</lang>

SIMPOL

<lang simpol>function main() end function "Hello world!{d}{a}"</lang>

Simula

Works with: SIMULA-67

<lang simula>BEGIN

  OUTTEXT("Hello world!");
  OUTIMAGE

END</lang>

Sisal

<lang 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</lang>

SkookumScript

<lang javascript>print("Hello world!")</lang> Alternatively if just typing in the SkookumIDE REPL: <lang javascript>"Hello world!"</lang>

Slate

<lang slate>inform: 'Hello world!'.</lang>

Smalltalk

<lang smalltalk>Transcript show: 'Hello world!'; cr.</lang>

Works with: GNU Smalltalk

(as does the above code)

<lang smalltalk>'Hello world!' printNl.</lang>

smart BASIC

<lang qbasic>PRINT "Hello world!"</lang>

SmileBASIC

<lang smilebasic>PRINT "Hello world!"</lang>

SNOBOL4

Using CSnobol4 dialect <lang snobol4> OUTPUT = "Hello world!" END</lang>

SNUSP

Core SNUSP

<lang snusp>/++++!/===========?\>++.>+.+++++++..+++\ \+++\ | /+>+++++++>/ /++++++++++<<.++>./ $+++/ | \+++++++++>\ \+++++.>.+++.-----\

     \==-<<<<+>+++/ /=.>.+>.--------.-/</lang>

Modular SNUSP

<lang snusp>@\G.@\o.o.@\d.--b.@\y.@\e.>@\comma.@\.<-@\W.+@\o.+++r.------l.@\d.>+.! #

|   |     \@------|#  |    \@@+@@++|+++#-    \\               -
|   \@@@@=+++++#  |   \===--------!\===!\-----|-------#-------/
\@@+@@@+++++#     \!#+++++++++++++++++++++++#!/</lang>

SoneKing Assembly

<lang soneking assembly> extern print

dv Msg Goodbye,World!

mov eax Msg push call print pop </lang>

SPARC Assembly

<lang sparc> .section ".text" .global _start _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

.msg: .ascii "Hello world!\n" .msgend: </lang>

Sparkling

<lang sparkling>print("Hello world!");</lang>

SPL

<lang spl>#.output("Hello world!")</lang>

SQL

Works with: Oracle
Works with: Db2 LUW

<lang sql> select 'Hello world!' text from dual; </lang>

SQL>select 'Hello world!' text from dual;
TEXT
------------
Hello world!

SQL PL

Works with: Db2 LUW

With SQL only: <lang sql pl> SELECT 'Hello world!' AS text FROM sysibm.sysdummy1; </lang> Output:

db2 -t
db2 => SELECT 'Hello world!' AS text FROM sysibm.sysdummy1;

TEXT        
------------
Hello world!

  1 record(s) selected.
Works with: Db2 LUW

version 9.7 or higher.

With SQL PL: <lang sql pl> SET SERVEROUTPUT ON;

CALL DBMS_OUTPUT.PUT_LINE('Hello world!'); </lang> Output:

db2 -t
db2 => SET SERVEROUTPUT ON
DB20000I  The SET SERVEROUTPUT command completed successfully.
db2 => CALL DBMS_OUTPUT.PUT_LINE('Hello world!')

  Return Status = 0

Hello world!

Standard ML

<lang sml>print "Hello world!\n"</lang>

Stata

<lang stata>display "Hello world!"</lang>

Suneido

<lang Suneido>Print("Hello world!")</lang>

Swahili

<lang swahili>andika("Hello world!")</lang>

Swift

Works with: Swift version 2.x+

<lang swift>print("Hello world!")</lang>

Works with: Swift version 1.x

<lang swift>println("Hello world!")</lang>

Symsyn

<lang symsyn>

'hello world' []

</lang>

Tailspin

<lang tailspin>'Hello World' -> !OUT::write</lang>

Tcl

Output to terminal: <lang tcl>puts "Hello world!"</lang>

Output to arbitrary open, writable file: <lang tcl>puts $fileID "Hello world!"</lang>

Teco

Outputting to terminal. Please note that ^A means control-A, not a caret followed by 'A', and that $ represent the ESC key. <lang teco>^AHello world!^A$$</lang>

Tern

<lang tern>println("Hello world!");</lang>

Terra

<lang terra>C = terralib.includec("stdio.h")

terra hello(argc : int, argv : &rawstring)

 C.printf("Hello world!\n")
 return 0

end</lang>

Terraform

<lang hcl>output "result" {

 value = "Hello world!"

}</lang>

Output:
$ terraform init
$ terraform apply

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

result = Hello world!
$ terraform output result
Hello world!

TestML

<lang TestML>%TestML 0.1.0 Print("Hello world!")</lang>

TI-83 BASIC

<lang ti83b>Disp "Hello world!</lang> (Lowercase letters DO exist in TI-BASIC, though you need an assembly program to enable them.)

TI-89 BASIC

<lang ti89b>Disp "Hello world!"</lang>

Tiny BASIC

<lang Tiny BASIC> 10 PRINT "Hello, World!" </lang>

TMG

Unix TMG: <lang tqs>begin: parse(( = { <Hello, World!> * } ));</lang>

TorqueScript

<lang tqs>echo("Hello world!");</lang>

TPP

<lang tpp>Hello world!</lang>

Transact-SQL

<lang sql>PRINT "Hello world!"</lang>

Transd

<lang scheme>(textout "Hello, World!")</lang>

TransFORTH

<lang forth>PRINT " Hello world! "</lang>

Trith

<lang trith>"Hello world!" print</lang>

True BASIC

<lang truebasic> ! In True BASIC all programs run in their own window. So this is almost a graphical version. PRINT "Hello world!" END </lang>

TUSCRIPT

<lang tuscript> $$ MODE TUSCRIPT PRINT "Hello world!" </lang> Output:

Hello world!

Uniface

<lang Uniface> message "Hello world!" </lang>

Unison

<lang Unison> main = '(printLine "Hello world!") </lang>

UNIX Shell

Works with: Bourne Shell

<lang bash>#!/bin/sh echo "Hello world!"</lang>

C Shell

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

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

Unlambda

<lang unlambda>`r```````````````.G.o.o.d.b.y.e.,. .W.o.r.l.d.!i</lang>

Ursa

<lang ursa>out "hello world!" endl console</lang>

Ursala

output as a side effect of compilation <lang Ursala>#show+

main = -[Hello world!]-</lang> output by a compiled executable <lang Ursala>#import std

  1. executable ('parameterized',)

main = <file[contents: -[Hello world!]-]>!</lang>

உயிர்/Uyir

<lang உயிர்/Uyir>முதன்மை என்பதின் வகை எண் பணி {{

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

}};</lang>

V

<lang v>"Hello world!" puts</lang>

Vala

<lang vala>void main(){ stdout.printf("Hello world!\n"); }</lang>

VAX Assembly

<lang VAX Assembly> desc: .ascid "Hello World!" ;descriptor (len+addr) and text .entry hello, ^m<> ;register save mask

      pushaq desc                ;address of descriptor
      calls #1, g^lib$put_output ;call with one argument on stack
      ret                        ;restore registers, clean stack & return

.end hello ;transfer address for linker </lang>

VBScript

Works with: Windows Script Host version 5.7

<lang VBScript>WScript.Echo "Hello world!"</lang>

Vedit macro language

<lang vedit>Message("Hello world!")</lang>

Verbexx

<lang Verbexx>@SAY "Hello world!";</lang>

VHDL

<lang VHDL>LIBRARY std; USE std.TEXTIO.all;

entity test is end entity test;

architecture beh of test is begin

 process
   variable line_out : line;
 begin
   write(line_out, string'("Hello world!"));
   writeline(OUTPUT, line_out);
   wait; -- needed to stop the execution
 end process;

end architecture beh;</lang>

Vim Script

<lang vim>echo "Hello world!\n"</lang>

Visual Basic

Works with: Visual Basic version VB6 Standard

Visual Basic 6 is actually designed to create GUI applications, however with a little help from the Microsoft.Scripting Library it is fairly easy to write a simple console application. <lang vb>Option Explicit

Private Declare Function AllocConsole Lib "kernel32.dll" () As Long Private Declare Function FreeConsole Lib "kernel32.dll" () As Long 'needs a reference set to "Microsoft Scripting Runtime" (scrrun.dll)

Sub Main()

 Call AllocConsole
 Dim mFSO As Scripting.FileSystemObject
 Dim mStdIn As Scripting.TextStream
 Dim mStdOut As Scripting.TextStream
 Set mFSO = New Scripting.FileSystemObject
 Set mStdIn = mFSO.GetStandardStream(StdIn)
 Set mStdOut = mFSO.GetStandardStream(StdOut)
 mStdOut.Write "Hello world!" & vbNewLine
 mStdOut.Write "press enter to quit program."
 mStdIn.Read 1
 Call FreeConsole

End Sub</lang>

Visual Basic .NET

<lang vb>Imports System

Module HelloWorld

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

End Module</lang>

Viua VM assembly

<lang>.function: main/0

   text %1 local "Hello World!"
   print %1 local
   izero %0 local
   return

.end</lang>

Vlang

<lang vlang>fn main() {

       println('Hello World!')

}</lang>

Wart

<lang wart>prn "Hello world!"</lang>

WDTE

<lang WDTE>io.writeln io.stdout 'Hello world!';</lang>

WebAssembly

Library: WASI

<lang webassembly>(module $helloworld

   ;;Import fd_write from WASI, declaring that it takes 4 i32 inputs and returns 1 i32 value
   (import "wasi_unstable" "fd_write"
       (func $fd_write (param i32 i32 i32 i32) (result i32))
   )
   ;;Declare initial memory size of 32 bytes
   (memory 32)
   ;;Export memory so external functions can see it
   (export "memory" (memory 0))

   ;;Declare test data starting at address 8
   (data (i32.const 8) "Hello world!\n")

   ;;The entry point for WASI is called _start
   (func $main (export "_start")
       
       ;;Write the start address of the string to address 0
       (i32.store (i32.const 0) (i32.const 8)) 

       ;;Write the length of the string to address 4
       (i32.store (i32.const 4) (i32.const 13))
       ;;Call fd_write to print to console
       (call $fd_write
           (i32.const 1) ;;Value of 1 corresponds to stdout
           (i32.const 0) ;;The location in memory of the string pointer
           (i32.const 1) ;;Number of strings to output
           (i32.const 24) ;;Address to write number of bytes written
       )
       drop ;;Ignore return code
   )

) </lang>

Wee Basic

<lang Wee Basic>print 1 "Hello world!" end</lang>

Whenever

<lang whenever>1 print("Hello world!");</lang>

Whiley

<lang whiley>import whiley.lang.System

method main(System.Console console):

   console.out.println("Hello world!")</lang>

Whitespace

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

Wolfram Language

<lang wolfram>Print["Hello world!"]</lang>

Wren

<lang ecmascript>System.print("Hello world!")</lang>

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): <lang asm>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</lang>

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

<lang asm>.section .text

.globl main

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 ret

.section .data str: .ascii "Hello world!\12"</lang>

AT&T syntax (x64): <lang>// No "main" used // compile with `gcc -nostdlib`

  1. define SYS_WRITE $1
  2. define STDOUT $1
  3. define SYS_EXIT $60
  4. define MSGLEN $14

.global _start .text

_start:

   movq    $message, %rsi          // char *
   movq    SYS_WRITE, %rax
   movq    STDOUT, %rdi
   movq    MSGLEN, %rdx
   syscall                         // sys_write(message, stdout, 0x14);
   
   movq    SYS_EXIT, %rax
   xorq    %rdi, %rdi              // The exit code.
   syscall                         // exit(0)
   

.data message: .ascii "Hello, world!\n"</lang>

XBasic

Works with: Windows XBasic

<lang xbasic> PROGRAM "hello" VERSION "0.0003"

DECLARE FUNCTION Entry()

FUNCTION Entry()

 PRINT "Hello World"

END FUNCTION END PROGRAM </lang>

xEec

<lang 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 </lang>

XL

<lang XL>use XL.UI.CONSOLE WriteLn "Hello world!"</lang>

XLISP

<lang xlisp>(DISPLAY "Hello world!") (NEWLINE)</lang>

XPL0

<lang XPL0>code Text=12; Text(0, "Hello world! ")</lang>

XSLT

<lang xml><xsl:text>Hello world! </xsl:text></lang>

Yorick

<lang yorick>write, "Hello world!"</lang>

Z80 Assembly

Using the Amstrad CPC firmware:

<lang z80>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 ret

world: defm "Hello world!\r\n\0"</lang>

zkl

<lang zkl>println("Hello world!");</lang>

Zoea

<lang Zoea>program: hello_world

 output: "Hello  world!"</lang>

Zoomscript

For typing: <lang Zoomscript>print "Hello world!"</lang> For importing:

¶0¶print "Hello world!"

ZX Spectrum Basic

<lang zxbasic>10 print "Hello world!"</lang>