There are very nice collections of 200+ HelloWorld in a lot of ProgrammingLanguages at http://www.latech.edu/~acm/HelloWorld.shtml. A big collection of 440+ Hello World programs can be found here: http://helloworldcollection.de
See also: ProgrammingChrestomathy, ArraySumInManyProgrammingLanguages, CounterInManyProgrammingLanguages, DotProductInManyProgrammingLanguages, WardNumberInManyProgrammingLanguages, HexDumpInManyProgrammingLanguages, NinetyNineBottlesOfBeerOnTheWall, QuineProgram, and TrainSpotting
If you are confused about whether or not your selected language is a programming language take this easy test to determine it: if it is possible to modify the program to print the greeting ten times without duplicating code, then it most likely is a programming language.
An apparently reasonable attempt was made to edit this page on August 6th, 2013, to presumably present a new Algol 60 example, but some of the existing content was damaged in the process. I lack the patience to sort out the mess, so I reverted the edit but made some effort to retain the (corrected?) Algol 60 example. I removed the commentary that related to the old (convoluted, and probably erroneous) example.
trace('hello world');
actsl
from http://compilers.iecc.com/comparch/article/07-10-055
int nul
fun main
"Hello World!\n" arg call printf ref nul =
endfun
procedure HELLO_WARD is
begin
What about Tandy TRS 80 (Level 1) with 4k Ram
PUT ("Hello, Ward");
end HELLO_WARD;
Is a variation on the version offered in Understanding Ada by Ken Shumate.
println "Hello World!"
trans a "Hello World!"
a
trans hello nil { println "Hello World!" }
hello
const Hello (class)
trans Hello:greet nil { String "Hello World!" }
const nice-user (Hello)
trans nice-user:hello nil { println (this:greet) }
nice-user:hello
It is nice :-) -- DavidDeLis
Algol-60
begin
file rmt (kind = remote);
write(rmt, <"Hello World!">);
end.
AmigaE (AmigaEe):
PROC main()
PrintF('Hello world\n')
ENDPROC
But if you want to use some OOP for more interest:
PROC main() HANDLE
DEF message=NIL:PTR TO printMessage ->object to be allocated
NEW message.new('Hello world\n')
message.print()
EXCEPT DO
END message
IF exception
PrintF('Exception raised: \s.\n', IF exceptioninfo THEN exceptioninfo ELSE 'Unknown')
ENDIF
ENDPROC
OBJECT printMessage PRIVATE
message:PTR TO CHAR ->message to be printed
ENDOBJECT
/* This is the constructor */
PROC new(message:PTR TO CHAR) OF printMessage
self.message := message
ENDPROC
/* This is a normal method */
PROC print(addNewLine=FALSE) OF printMessage
IF addNewLine = FALSE
PrintF(self.message)
ELSE
PrintF('\s\n', self.message)
ENDIF
ENDPROC
Please note that AmigaE is case-sensitive, that keywords must be uppercase, and that user-defined names must at-least start with a lower-case letter.
APL (AplLanguage)
'Hello World'
on helloWorld()
display dialog "Hello World!" buttons {"OK"}
end helloWorld
helloWorld()
AssemblyLanguage for the IBM-PC (i386):
dosseg
.model small
.stack 100h
.data
hello_message db 'Hello, World!',0dh,0ah,'$'
.code
main proc
mov ax,@data
mov ds,ax
mov ah,9
mov dx,offset hello_message
int 21h
mov ax,4C00h
int 21h
main endp
end main
But nowadays, we do it in protected mode in Linux.
.text
.global _start
_start:
mov $4, %eax /* write system call */
mov $1, %ebx /* stdout */
mov $msg, %ecx
mov $msgend-msg, %edx
int $0x80
mov $1, %eax /* _exit system call */
mov $0, %ebx /* EXIT_SUCCESS */
int $0x80
.data
msg: .ascii "Hello, world\n"
msgend:
(Very nice, but gas/gcc format should be:
.global main
main:
I have just checked it.. otherwise, it's cool, my assembler days are long gone...)
Nope. That is if you want to use the libc and use the C startup code. The above program, however, does not require any C library code to be linked; it calls directly to the kernel through the interrupt 0x80 interface.
Autoit 3
Msgbox(0,"Hello!!","Hello,World !!")
Or
ConsoleWrite("Hello, World !!!")
IBM 360/370/390 BAL (Basic Assembler Language)
// EXEC ASSEMBLY
START
MAIN BALR 2,0
USING *,2
OPEN PRINT
MVC BUF,HW
PUT PRINT
CLOSE PRINT
EOJ
HW DC CL132'HELLO WORLD'
BUF DS CL132
PRINT DTFPR IOAREA1=BUF,DEVADDR=SYSLST,BLKSIZE=132, *
DEVICE=3203,CONTROL=YES,PRINTOV=YES
END MAIN
/*
// EXEC LNKEDT
// EXEC
/*
/&
(Ahhh... those were the days)
Sorry, had to tweak it! Opcodes start in col. 10; operands in col. 16. These two rules aren't essential - an opcode can start as early as col. 2. Continuation character is in col. 72 (didn't bother spacing that far over). Continuations of statements on the next line start at col. 16. These last two rules are essential.
echo "" | awk 'BEGIN{print "Hello World"}'
or
echo "Hello World" | awk '{print $0}'
GNU Awk:
awk 'BEGIN{print "Hello World"}'
B (BeeLanguage):
main( ) {
putchar('hell');
putchar('o, w');
putchar('orld');
putchar('*n' );
}
-- AdamBerger
(Obviously optional, but included 99.999% of the time...)
RUN (AWAY, LAUGHING)
Poor old Basic - everybody's forgotten you...
,:
^_@
BlitzMax (http://www.blitzmax.com)
Can be done in two variants
Print "Hello World!"
Or if you want it in a nice dialog box
Notify "Hello World!"
Bourne Shell:
#!/bin/sh
echo hello, world
BrainLanguage (brain hello.brn):
"Hello, world" println.
BrainfuckLanguage (an EsotericProgrammingLanguage)::
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++. [-]>++++++++[<++++>-]<.>+++++++++++[<+++++>-]<. >++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[<++++>-]<+. [-]++++++++++.
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++. [-]>++++++++[<++++>-]<.#>+++++++++++[<+++++>-]<. >++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[<++++>-]<+. [-]++++++++++.
-- DavidHooker
shorter:
++++++++++[>+++++++>++++++++++>+++>+<<<<-]
>++.>+.+++++++..+++.>++.<<+++++++++++++++.
>.+++.------.--------.>+.>.
C (CeeLanguage) (according to KernighanAndRitchie):
#include
#include
int main(void)
{
printf("Hello, world\n");
return EXIT_SUCCESS;
}
Cerner Command Language (CCL)
;Example 1
call echo("Hello World!") go
;Example 2
drop program helloworld2 go
create program helloworld2
call echo("Hello World!")
end go
;Example 3
drop program helloworld3 go
create program helloworld3
PAINT
call TEXT(1,1, "Hello World!")
end go
class Hello {
static void Main() {
System.Console.Write("Hello World");
}
}
C++ (CeePlusPlus)
#include
int main()
{
std::cout << "Hello, World.";
}
The code does not actually need the
return 0; // an integer return value is expected. Thou shalt not remove this line!
to be conformant - main will implicitly return 0 if no return value is given. See 3.6.1.5 (http://www.open-std.org/jtc1/sc22/open/n2356/basic.html#basic.start.main) -- ScottMcMurray
Cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. Hello.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
Display 'Hello, World'.
STOP RUN.
Tag based:
#hello#
Script based:
WriteOutput("Hello World!");
Note that you don't need to assign a variable first. You can just type Hello World without any tags (if you don't care about "proper" HTML).
COM HelloWorld client:
#define WIN32_LEAN_AND_MEAN
#include
#include
#include
#include
#import "HelloSrv.tlb"
void _tmain (int argc, TCHAR * argv[])
{
if (S_OK == CoInitialize(NULL))
{
try
{
HELLOSRVLib::IHelloWorld p(__uuidof(HELLOSRVLib::HelloWorld));
p->Hello();
}
catch (const _com_error& Err)
{
cerr << Err.ErrorMessage() << endl;
}
CoUninitialize();
}
else
{
cerr << "Error during OLE initialization" << endl;
}
}
RM COBOL:
Interactively (at the ReadEvalPrintLoop):
"Hello World!"
If you're picky and you want a file you can "execute" which will write the sequence "Hello World!\n" on stdout:
(write-line "Hello World!")
COW (an EsotericProgrammingLanguage):
see: http://www.bigzaphod.org/cow/
MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO Moo Moo MoO MoO MoO Moo OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo MoO MoO MoO Moo MOo MOo MOo MOo MOo MOo Moo MOo MOo MOo MOo MOo MOo MOo MOo Moo OOO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO MoO Moo
Is this code translated from the BrainfuckLanguage code given above? -- AnonymousDonor
D
See: http://dlang.org/
import std.c.stdio;
int main(char[][] args)
{
printf("Hello, World!\n");
return 0
}
-- PaulRuane
Also:
import std.stdio;
void main() {
writeln("Hello, World!");
}
[Hello, world!] p
Dodo http://dodo.sourceforge.net
In the runnable dodo0 variant:
println("Hello World!") ->
exit()
A proper dodo program would be:
import console
def Main: Main()
{
console!Stdout().Puts("Hello World!")
}.
DOS (DiskOperatingSystem)
command.com Shell Script:
echo Hello World
Mac users often confuse the operating system with the small sample shell that came with it.
It was claimed that DOS did not qualify as a programming language, according to the test given at the top of the page. However, consider the following cmd.exe shell script:
for /l %i in (1,1,10) do echo Hello World
(at least under NT-like shells)
class HELLO
creation make
feature make is
do
print ("Hello, World%N")
end
end -- class HELLO
(defun hello-world ()
(interactive)
(with-current-buffer (pop-to-buffer "*Hello!*")
(insert "Hello World\n")))
In file hello.erl:
-module(hello).
-export([hello_world/0]).
hello_world() -> io:fwrite("hello, world\n").
in erl (or esh, or compiling it):
> c(hello).
> hello:hello_world().
##X#
For non-programmers:
These examples are mere toys! Don't forget the real thing, GNU HelloWorld at http://www.gnu.org/software/hello/
From the page:
The GNU `hello' program produces a familiar, friendly greeting. It
allows nonprogrammers to use a classic computer science tool which
would otherwise be unavailable to them.
Yes, this really is the classic program that prints "Hello, world!"
when you run it. Unlike the elementary version often presented in
books like K&R, GNU hello processes its argument list to modify its
behavior, supports internationalization, and includes a mail
reader. The primary purpose of this program is to demonstrate how to
write other programs that do these things; it serves as a model for
all of the GNU coding standards.
This is an interesting corollary to the joke among Windows programmers that the last Windows program was written sometime in 1994; everything since then has been a modification of HELLO.C from Petzold. Sadly, I actually worked on a commercial product where that was the case.
Forte TOOL:
task.part.logmgr.putline( 'Hello World ' );
-- DavidVydra
CR .( Hello, world!)
FortranLanguage -- this works both with f77 and f90
PROGRAM HELLOWORLD
WRITE(6,10)
END
println["Hello World!"]
package main
import "fmt"
func main() {
fmt.Printf("Hello, World\n")
}
obbs["Hello World!"]xx:
main = do putStrLn "Hello, world."
-- LoganHanks
In file HelloWorld.hs:
module Main where
main = putStrLn "Hello, World!\n"
Then compile it or call it (eg. using hugs98: hugs HelloWorld.hs and at the prompt -> main)
h
Hello World
executed as helloworld.htag if htag is properly associated with the interpreter, or as htag helloworld.htag if it isn't.
Here if it's called as http://localhost/helloworld.htag'':
Hello world
Hello World
This is also the reason why I created HtagLanguage, so I don't need unnecessary fluff. -- SvenNeumann
HTML
not a programming language.
That's not a sufficient reason to exclude it. Anyhow, ColdFusion is based around it, thus one can "print" just by stating the string:
Hello World
Hard to beat that.
Icon
procedure main(args)
write("Hello, World!");
end
[ Main;
print "Hello World!^";
];
"Hello World!" print
"Hello World!" println
Jakarta Velocity (JakartaVelocity)
import java.io.StringWriter;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.VelocityContext;
public class HelloWorld
{
public static void main(String args[])
throws Exception
{
Velocity.init();
VelocityContext context = new VelocityContext();
context.put("name", "World");
String s = "Hello $name!";
StringWriter w = new StringWriter();
Velocity.evaluate(context, w, "hello", s);
System.out.println(w);
}
}
public class Hello {
public static void main(String []args) {
System.out.println("Hello World");
}
}
Object oriented Java
class Greeting {
void greet(Named target) {
System.out.println("Hello, " + target.getName() + "!");
}
}
interface Named {
String getName();
}
class World implements Named {
String getName() {
return "World";
}
}
class Main {
public static void main( String[] args ) {
Greeting greeting = new Greeting();
greeting.greet(new World());
}
}
Swing Java
public class Hello {
public static void main(String []args) {
JOptionPane.showMessageDialog(null,"Hello, world!");
}
}
import java.applet.*;
import java.awt.*;
public class Hello extends Applet {
public void paint(Graphics g) {
g.drawString("Hello World", 25, 50);
}
}
document.writeln("Hello, World");
-- Paul Gresham, 07NOV1999
Pop up:
alert("Hello, World");
Note that none of these two examples are, strictly speaking, correct. They might however produce some results when being run from a specific host environment, and might even produce the intended result when this host environment happens to be a WebBrowser...
J (JayLanguage)
'Hello World'
"Hello World!" putln .
-- ShaeErisson
K (KayLanguage):
`0:"Hello World"
LatteLanguage (http://www.latte.org/):'''
{\def \hello "Hello, World!"}
{\head {\title \hello}}
{\body \hello}
LISP:
(DEFUN HELLO-WORLD ()
(PRINT (LIST 'HELLO 'WORLD)))
put "Hello World"
or:
alert "Hello World"
-- Welshy31
Logo
the turtle language, still unbeaten in handling of sets, there is an interpreter here: http://www.cs.berkeley.edu/~bh/logo.html
print [Hello World]
-- michael
HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE
Lotus Formula:
@Prompt([Ok];"";"Hello World")
Sub Click(Source As Button)
Print "Hello World"
End Sub
print "Hello, World."
import IO = LX.Text_IO
procedure HELLO() is
IO.WriteLn "Hello World"
(* Classic Modula-2, aka PIM *)
MODULE HelloWorld;
FROM InOut IMPORT WriteString,WriteLn;
BEGIN
WriteString("Hello World!");
WriteLn;
END HelloWorld.
(* ISO Modula-2 *)
MODULE HelloWorld;
FROM STextIO IMPORT WriteString,WriteLn;
BEGIN
WriteString("Hello World!");
WriteLn;
END HelloWorld.
(* Modula-2 R10 *)
MODULE HelloWorld;
IMPORT PervasiveIO;
BEGIN
WRITE("HelloWorld!\n");
END HelloWorld.
MODULE Hello EXPORTS Main;
IMPORT Stdio, Wr;
BEGIN
Wr.PutText(Stdio.stdout, "Hello World");
END Hello.
Graphical version
MODULE Hello EXPORTS Main;
IMPORT Trestle, TextVBT;
VAR v := TextVBT.New("Hello World");
BEGIN
Trestle.Intall(v);
Trestle.AwaitDelete();
END Hello.
Multiple languages:
All such discussions are concluded by contemplating HelloPolyGlots. Cobol, Pascal, Fortran, C, PostScript, BourneShell, Assembly: All in one single source file!
That makes my cheesy little effort (Perl and C) look, well cheesy. Here it is anyway. -- BruceIde
#include
#define sub int
#define print(a) printf("%s", a)
sub main() {
print("Hello world\n");
}
#ifdef _perl
main();
#endif
NemerleLanguage: (http://www.nemerle.org)
module Hello {
Main(): void {
Nemerle.IO.printf("Hello world\n");
}
}
or a graphical version, using Gtk#:
using System;
using Gtk;
using GtkSharp;
module hello {
Main(): void {
Application.Init();
def button = Button("Hello World");
button.Clicked += (fun(_,_) {
Console.WriteLine("Hello World")
});
def window = Window("Helloworld");
window.DeleteEvent += (fun(_,_) {
Application.Quit()
});
window.Add(button);
window.ShowAll();
Application.Run()
}
}
#import
@interface Greeter : NSObject {
}
- greet;
@end
@implementation Greeter
- greet {
NSLog(@"Hello, World!");
}
@end
int main(int argc, char *argv[]) {
Greeter *gr = [Greeter new];
[gr greet];
[gr release];
return 0;
}
-- MartinHëer
OpalLanguage:
FUN hello : denotation
DEF hello == "Hello, World"
Since Opal is a pure functional language there is no such side-effect as outputting something to stdout the only possibillity is to call this from the interpreter and so get the string as a result. (Ok, there is an output monad, but I'm not gonna touch that. :)
The idea is to show a program which prints out "Hello, world!" to the standard output. If it is difficult or ugly in your language, then so be it. If you are ashamed, then remove it completely.
At the interactive prompt:
print_string("Hello World!");;
This is more correct (adds a newline and flushes the channel):
print_endline "Hello, World!";;
-- MarcoMaggesi
program HelloWorld;
begin
writeln('Hello World');
end.
$\/\ /\ /\ /\ I wish Ward
+++ ++ ++ ++
+++ ++ /++++\ ++ ++ /++++\ would fix the
++\++\++ + + ++ ++ + +
++ +++ +/+++/ ++ ++ + +
++ +++ ++ ++ ++ + +
\/ \/\ /\+++ /\ /\ /++.+/
\ \ backslash
/++++.+++++++++++++++++++++++++++ / \ bug!
/\ - -#
++ . -.
+ / \++++\ /++++\ ++ /---\- -+
+ /\ + + + + + +. - .- ->
+ +. + + + + +- - +-
. +> + + + + +- - +- -.
\.+/\++/ \++++/ + +\ /-.+/- --
\ / \. \ / \/
You forgot the '$'. --AnonymousDonor
It's not strictly necessary for this program, since you start at the top left by default.
print "Hello World\n"
Type this into a file and run it with the single command, perl hello.pl.
Or provide the program on the command line, as:
perl -e "print 'Hello, world'"
(Note: The double-quotes are placed at the outer level to be compatible with DOS-based systems - and still work with Un*x.)
Or, invoke Perl as an interactive interpreter/compiler ala Forth, BASIC, etc.
perl -e "while(<>){eval;print $@;}"
or
perl -ne "eval; print $@;"
or
perl -de 1 # given appropriate CPAN bits, this has command-line editing
and input the program directly:
print "Hello, world"
Hello, world # Perl's immediate response
or even:
sub hello { print "Hello, world" };
hello; # Call the subroutine we just defined
Hello, world # Perl's immediate response
Perl subsumes all languages eventually...
perl -e 'use Inline C=>q{void hw(){printf("Hello, world!\n");}};hw'
perl -e 'use Inline Ruby=>q{def hw;puts "Hello, world!";end};hw'
Perl "Obfuscation" (taken from http://www.perlmonks.net/index.pl?node_id=329174)
package Earth;sub Greet{
%_=('Y','~');$_='$;=!(Middle
Earth.age~~~
.age)?!(defined$ti~~~~~~~~~~~mez~~~On
e[2])?!(push@time~~~~~~~~~~~~~~~~Zone,loc
~altime())?rotation?~~~~~~~~~~~~~q~~?The Worl
~~d?:q:[\w]::q=[\~~~~~~~~~~~~~~~~~d~a-f]=:q?..~~
~~~?:q:.:;"42b3d3~~~~~~~~~~~~~~~~~~~~~728656c6c6f6
~~~~~0277f627c64672~~~~~~~~~~~~~~~~~~~~~b3072796e647
~~~~~~~42b3b3rg7d"=Ym~~~~~~~~~~~~~~~~~~~\$;~~*\;p~~~~u
~~~~~~~~~sh@_,$&;bless~~~~~~~~~~~~~~~~~~~~~~~~~$c~~~~~~~
~~~~~~~~~o~ntine~~~~~nt~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~s=\~~~~~~~$~~~~~~~~~~~~~~~~~~~~~~~pangaea~~~~
~~~~~~~~~~~~~~~;{l~~~~~~~~~~~~~~~~~~~~~~~~~~~~ocal@_;local$;
~~~~~~~~~~~~~~~~~="o~~~~~~~~~~~~~~~~~~~~~~~~~cean";$^A=(defi
~~~~~~~~~~~~~~~~~~~n~~~~~~~~~~~~~~~~~~~~~~~~~ed$continents)?
~~~~~~~~~~~~~~~~~~~(vec(~~~~~~~~~~~~~~~~~~~~~~$;, YYsplit(\'
~~~~~~~~~~~~~~~~~\',${\$;}~~~~~~~~~~~~~~~~~~~~~~)%3,YYsplit(
~~~~~~~~~~~~~~~~q??,$;)**2-~~~~~~~~~~~~~~~~~~~~~~(($;=Ytr/oa
~~~~~~~~~~~~~~~~eiu//)**2))=~~~~~~~~~~~~~~~~~~~~~~=28160)?q:
~~~~~~~~~~~~~~~~~.::q?!?:\'?~~~~~~~~~~~~~~~~~~~~~~\';}$^A=Ys
~~~~~~~~~~~~~~~~:\Q.\E:pack(~~~~~~~~~~~~~~~~~~~~~~\'h*\',j
~~~~~~~~~~~~~~~~~oin(q(),~~~~~~~~~~~~~~~~~~~~~~~grep{$_=
~~~~~~~~~~~~~~~~~~Ym,$,,}~~~~~~~~~~~~~~~~~~~~~~~split("
~~~~~~~~~~~~~~~~~",@_~~~~~~~~~~~~~~~~~~~~~~~~~~[0]))
~~~~~~~~~~~~~~~~):e~~~~~~~~~~~~~~~~~~~~~~~~~~~gexe
~~~~~~~~~~~~~~~;$d~~~~~~~~~~~~~~~~~~~~~~~~~~~="s
~~~~~~~~~~~~~~ort~~~~~~~~~~~~~~~~~~~~~~~~~~<=
~~~~~~~~~~~~>,~~~~~~~~~~~~~~~~~~~~~~~~~~YY
~~~~~~~~~~~@_~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~"~~~~~~~~~~~~~~~~~~~';;
s,(~|\r|\n|\s),,g;s.Y.\x7e.g;
eval};Greet;'the world';
="Hello World"?>
But you have to have short tags turned on in the ini file, otherwise:
-- BrynJones
Or just type "Hello, world!" in a file, and run php -f helloworld.php (doesn't have to pre-process plain old text, now does it?)
-- Phil
Pike
int main() {
write("Hello World\n");
}
PlbLanguage (or Databus)
DISPLAY "HELLO WORLD"
STOP
PL/SQL
BEGIN
DBMS_OUTPUT.PUT_LINE('Frank and Beans');
END;
(Hello World) =
or (only strings, to stdout)
(Hello World\n) print
or (to any file)
(%stdout) (w) file (Hello World\n) writestring
or (put on paper)
/Times-Roman findfont 12 scalefont setfont
showpage
PowerScript
(used in PowerSoft/Sybase PowerBuilder)
global type main from application
end type
global main main
on main.create
appname = "main"
end on
event open;MessageBox (, 'Hello World')
end event
"Hello World"
In this now-defunct, really visual dataflow OOP language, that was very cool and way ahead of its time, the program is:
(Note that in Prograph there was no "C code generation" or similar idiocy -- the compiler acted directly on this hierarchical hypergraph to create executable code. Alas for visionaries everywhere....) --BillTozier
Highlighting one DISadvantage of a really visual dataflow language, the above image link is now broken, while the code for the plain old behind the times textual languages remains.
Prolog:
go :-
writeln('Hello World').
-- TechnoKid
You copy the following text into a file and call the file (hello.py) (remember python is sensitive of it's indenting, which rocks :) )
print "hello world"
Now invoke the interpreter and pass it your file with the single command: python hello.py
QBasic:
? "Hello, world!"
The only language so far with Q? (See G entry) ... No I haven't forgotten you, dear QB (See BASIC entry)
-- Phil
P.S. (Anyone brave enough for a QuickBasic version? How about QB4.5 (mmm, compiled basic...)? VBDOS???)
Rebol
print "Hello World"
or:
"Hello World"
In a script:
Rebol []
print "Hello World"
-- AndrewMartin
say 'hello, world';
RpgLanguage - RPG Column positions are crucial - in old style RPG
Columns . . . : 6 76 Browse TESTLIB/QRPGLESRC SEU==> TESTPGM FMT C CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
FQSYSPRT O PRINTER OFLIND(*IN88)
D*
C EXFMT RECFMT
C EVAL *INLR = *ON
O RECFMT R
O 11 'HELLO WORLD'
Free format RPG IBM finally put the cash in for something a little more readable.
Columns . . . : 6 76 Browse TESTLIB/QRPGLESRC SEU==> TESTPGM
/Free
dsply 'Hello World';
/end-free
puts "Hello, world"
(run with ruby hello.rb or ruby -e 'puts "Hello, world"')
HelloWorld in Scala is discussed in several steps on this page: http://www.artima.com/scalazine/articles/steps.html
println("Hello, world, from a script!")
(display "Hello, World!")
(newline)
The following version does not work unless your Scheme system contains the writes procedure, which is non-standard.
(define hello-world
(lambda ()
(writes 'nil "Hello, World!")))
-- IainLowe
I thought that at the Scheme interpreter prompt, since strings evaluate to themselves, you would just type
"Hello World"
and the interpreter would print it right back at you. -- EdwardKiser
That's true, I hadn't thought of that. That bodes ill for SimplestThingThatCouldPossiblyWork.
The same thing works in FalseLanguage.
I'd even venture:
(display "Hello, world!\n")
We all love Closures - don't we:
(define function lambda) ; for non-lispers only
(define greet-constructor
(function (x y)
(cons x y)))
(define get-greeting-function
(function (a)
(function (b)
(greet-constructor a b))))
(define my-greeting-function
(get-greeting-function 'hello))
(my-greeting-function 'world)
-- ClausGittinger
sed:
s;.*;Hello, Ward;
q
Actually, this fails on empty input files. How about this:
Hello, world!
d
ShellScript:
#!/bin/sh
echo "Hello World"
Small Basic (Microsoft):
TextWindow.WriteLine("Hello, World")
Also
GraphicsWindow.DrawText(10, 10, "Hello, World")
Transcript cr; show: 'Hello World'.
Type this into a workspace, select it and choose doit. Or, if you prefer a prototype, just type the quoted string, select it and choose printit.
Then let's see how to build an "executable" that will run in something like the same way all the other languages will. We can do anything in Smalltalk, but the packaging, oy! -- RonJeffries
I always show this, when asked by C/C++ programmers, as a typing in of "Hello, World!," preferably into an empty Transcript pane. And then I save the image. Loading the program subsequently brings up: "Hello, World!" Individuals will quibble over this relentlessly, saying, "It's not the same!" I can only agree that it's not the same, but that was my point about the languages and their environments in the first place. -- JerryArchibald
(Eeeh - I have an eerie feeling I've just walked through this exact thing from the POV of a non-Smalltalk programmer on SmalltalkHelloWorld)
I don't think this argument holds any longer - there are smalltalks around which can do this kind of stuff quite neatly (GNU-ST, ST/X...) -- ClausGittinger
SmileBASIC
print "Hello World"
val () = print "Hello, world!\n"
output = "Hello, world"
end
SnuspLanguage (possibly the most fun I've ever had writing Hello world!)
/e+++++++++++++++++++++++++++++.\
./\/\/\ /+++\!>.+++o.l.+++++++l/ #/?\
$H!\++++++\ + \comma.------------ .
/++++++/ +/\ /.--------o/ \-/!.++++++++++/?\n
/=\++++++\ +\\!=++++++\ \r+++.l------.d--------.>+.!\-/
\!\/\/\/\/ \++++++++++/
or in Modular SNUSP:
/@@@@++++# #+++@@\ #-----@@@\n
$@\H.@/e.+++++++l.l.+++o.>>++++.< .<@/w.@\o.+++r.++@\l.@\d.>+.@/.#
\@@@@=>++++>+++++<<@+++++# #---@@/!=========/!==/
Skeleton key (the flexiblity of PathLanguage or BefungeLanguage combined with the aesthetics of Brainf**k):
There is an interpreter in Perl on the SnuspLanguage page, in case you don't believe the above is executable!
SQL (StructuredQueryLanguage):
SQL has no branching or conditionals. It is not a programming language. It is a query language.
Hmm, well.
SELECT 'Hello World!';
And how about the Oracle SQL flavour?
SELECT 'Hello World!' FROM dual;
I don't know if there is a vendor-neutral way to specify this. Most dialects require the specification of a table in a SELECT statement, if I'm not mistaken.
println("Hello, World")
TeX
Hello,~world!
or (messing with subroutines / macros)
\def\hw#1{Hello,~#1}
\hw{world!} \\
\hw{Ward.}
(BTW, writing these examples I ran across a bug: end-of-line backslashes are eaten (together with the linefeed) at edit.)
in LaTeX, you should use \newcommand:
\newcommand{\hw}[1]{Hello,~#1}
While we're at it, let's see the same definition in other macro processors:
m4: define(`hw',`Hello, $1')
cpp: #define hw(who) Hello, who
It was claimed that TeX did not qualify as a programming language, according to the test given at the top of the page. However, consider the following:
\long\def\repeat#1#2{
\count0=0
\def\onceMore{
\ifnum\count0<#1
#2
\advance \count0 by 1
\onceMore
\fi
}
\onceMore
}
\repeat{10}{Hello,~World\par}
\bye
And let's not forget that there exists a BasicLanguage interpreter written in TeX: http://texcatalogue.sarovar.org/entries/basix.html
Implementation class HelloWorld
int
main Array arguments
{
[[[stdio out] print "Hello, world"] nl];
}
end;
Implementation instance HelloWorld end;
puts "Hello, world"
page = PAGE
page.typeNum = 0
page.10 = TEXT
page.10.value = HELLO WORLD!
`r```````````.H.e.l.l.o. .w.o.r.l.di
Sub Main()
MessageBox("Hello World")
End Sub
VisualFoxPro: ' - will also work in Clipper and almost any other DBase III-driven scripting language, known collectively as "Xbase" (ExBase)
? "Hello World"
MS VJ++ 6.0 version:
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.*;
public class Form1 extends Form
{
public Form1()
{
// Required for Visual J++ Form Designer support
initForm();
}
public void dispose()
{
super.dispose();
components.dispose();
}
/**
Container components = new Container();
private void initForm()
{
this.setText("Form1");
this.setAutoScaleBaseSize(new Point(5, 13));
this.setClientSize(new Point(292, 273));
this.addOnClick(new EventHandler(this.Form1_click));
MessageBox.show("Hello, world");
}
public static void main(String args[])
{
Application.run(new Form1());
}
}
XIML
Whirl
Whitespace - A real language (http://compsoc.dur.ac.uk/whitespace/)
Say hello.
(To be "Readable" and also so that it isn't rejected by the WikiWiki formatting transform):