"Hello World" in 65 verschiedenen Sprachen

ACHTUNG: Diese Seite ist veraltet und wird von mir nicht mehr gepflegt.
Schauen Sie auf meine neue Sprachseite.

von Michael Neumann, letzte Änderung 20.11.1999

Dokument offline: sprachen.zip

The Little Coders Homepage || Links zu Sprachen


ABC

Ada 83/9X(95)

ALGOL 60

Amos

APL

Assembler: Intel 80x86 (DOS)

Assembler: Motorola 68000 (ATARI)

BASIC

BETA

C

C++

Cilk

CLAIRE

COBOL

Concurrent Clean

DOS Batch

Dylan

Eiffel

Emerald

Erlang

Euphoria

Forth

Fortran 90

Haskell

Hope

HTML

Icon

J

Java

JavaScript

Leda

Lisp

Logo

ML

Modula-2

Modula-3

NESL

Oberon

Objective-C

Obliq

Oz/Mozart

Pascal

Perl

Phantom

PHP3

PL/0E

PL/1

Postscript

Profan

Prolog

Python

Rebol

REXX

Ruby

Sather

Simula 67

Sina

Sirius

Sisal

Smalltalk

SQL

Tcl/Tk

TOM

UFO

WML


 

 

ABC

WRITE "Hello World"
anderes Beispiel: 
FOR i IN {1..10}
   WRITE i*i
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Ada 83/9X(95)

-- In Ada 83 muß man "Ada.Text_IO" durch "Text_IO" ersetzen!

with Ada.Text_IO; use Ada.Text_IO;

procedure HelloWorld is

begin

    Put_Line("Hello World");

end HelloWorld
anderes Beispiel: 
procedure Test is

with Ada.Text_IO; use Ada.Text_IO;

package MyInt is new Integer_IO(Integer);

begin

    for I in 1..10 loop

	MyInt.Put(I*I);

	Put(" ");

    end loop;

    New_Line;

end Test
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

ALGOL 60

'begin'

   outstring(2, 'Hello World');

'end'
oder
'begin'

   'string'  s := 'Hello World';

   'integer' i;



   'for' i := 1 'step' 1 'until' length(s) 'do' outsymbol(2,s,i);

'end'
anderes Beispiel: 
'begin' 'comment' gibt die Quadrate von 1 bis 10 aus;

   'integer' i;



   'for' i := 1 'step' 1 'until' 10 'do'

   'begin'

      outinteger(2,i*i);

   'end' --for-----diese Schleife gibt die Quadrate aus

'end' --Ende des Programmes
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Amos

PRINT "Hello World"

 

 

APL

'Hello World'
anderes Beispiel: 
(i10)´(i10)
ergibt:
1 4 9 16 25 36 49 64 81 100
anderes Beispiel: 
(7 3ë3 9)r(i9)´(i9)
ergibt:
1 4 9
16 25 36
49 64 81

 

 

Assembler: Intel 80x86 (DOS)

; WRITTEN IN TASM (Turbo Assembler)
.MODEL TINY
CODE SEGMENT
ASSUME CS:CODE, DS:CODE
ORG 100h
START:
	mov ah,9
	mov dx,OFFSET Msg
	int 21h
	int 20h
	Msg DB 'Hello World',13,10,'$'
CODE ENDS
END START

 

 

Assembler: Motorola 68000 (ATARI)

start:
	; Message-String ausgeben
	move.l #msg,-(a7)
	move.w #9,-(a7)	
	trap #1
	addq.l #6,a7

 

	; auf Taste warten
	move.w #1,-(a7)
	trap #1
	addq.l	#2,a7

 

	; Programm beenden
	clr -(a7)
	trap #1

 

	msg: dc.b "Hello World",10,13,0

 

 

BASIC

PRINT "Hello World"
anderes Beispiel: 
FOR I=1 TO 10

   PRINT I*I;

NEXT I
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

BETA Infos

(#

do

   'Hello World' -> putline

#)
anderes Beispiel: 
(#

do

   (for i:10 repeat

      i*i -> putint

   for)

#)
ergibt:
1 4 9 16 25 36 49 64 81 100
anderes Beispiel: 
(#

   schleife: (# n: @integer

              enter n

              do (for n repeat inner for)

              #)

do

   9 -> schleife (#

                  do 10-n -> schleife (#

                                      do n -> putint; ' ' -> put

                                      #) newline

                  #)

#)
ergibt:
1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7

1 2 3 4 5 6

1 2 3 4 5

1 2 3 4

1 2 3

1 2

1

 

 

C

#include <stdio.h>



main() {

   printf("Hello World\n");

}

 

 

C++

#include <stdio.h>



void main()

{

   printf("Hello World\n");

}
oder
#include <iostream.h>
void main()

{

   cout << "Hello World" << endl;

}

 

 

Cilk

#include <stdio.h>



cilk void main()

{

   printf("Hello World\n");

}
anderes Beispiel:
/* Cilk ist fast C */

#include <stdio.h>



cilk void main()

{

   int i;

   for(i=1; i<=10; ++i) printf("%d ", i*i);

}
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

CLAIRE

;; Hello World in CLAIRE

[ main() -> printf("Hello World\n") ]
anderes Beispiel:
[

main() ->

    for i in (1 .. 10) printf("~S ",i * i)

]
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

COBOL Infos

IDENTIFICATION DIVISION.

PROGRAM-ID. HelloWorld.

AUTHOR. Fabritius.

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

INPUT-OUTPUT SECTION.

DATA DIVISION.

FILE SECTION.

WORKING-STORAGE SECTION.

LINKAGE SECTION.

PROCEDURE DIVISION.

DISPLAY "Hello World".

STOP RUN.

 

 

Concurrent Clean

// Hello World

module helloworld

import StdEnv



Start:: String

Start = "Hello World"
anderes Beispiel:
module test

import StdEnv



Start:: [(Int, String)]

Start = [(a*a," ") \\ a <- [1..10]]
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

DOS Batch

@ECHO OFF

ECHO Hello World
anderes Beispiel:
@ECHO OFF

REM Gibt die Zahlen 0-99 aus

REM Diese Datei muß numbers.bat heißen



IF "%1" == ""       GOTO outer

IF "%1" == "output" GOTO output

IF "%1" == "inner"  GOTO inner

GOTO exit



:inner

FOR %%i IN (0 1 2 3 4 5 6 7 8 9) DO CALL numbers output %2 %%i

GOTO exit



:outer

FOR %%i IN (0 1 2 3 4 5 6 7 8 9) DO CALL numbers inner %%i

GOTO exit



:output

IF "%2" == "0" ECHO %3

IF NOT "%2" == "0" ECHO %2%3



:exit
ergibt:
die Zahlen von 0 bis 99

 

 

Dylan

define method hello-world()
	format-out("Hello World\n");
end method hello-world;
hello-world();
anderes Beispiel:
for (i :: <integer> from 1 to 10)
	format-out("%d ",i * i);
end for;
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Eiffel Infos

indexing
	title: 	"Hello World";
	author:	"Michael Neumann";
class MAIN creation
	make
feature
	make is
	do
		io.put_string("Hello World");
		io.new_line
	end -- make
 end -- class MAIN

 

 

Emerald

const HelloWorld ==



%

% Hello World in Emerald

%



   object HelloWorld

      process

         stdout.putstring["Hello World\n"]

         stdin.close

         stdout.close

      end process

   end HelloWorld
anderes Beispiel: 
const Test ==

   object Test

      process

         var i : Integer

         

         i <- 1

         loop

            exit when (i>10)

            

            stdout.putint[i*i] 

            stdout.putstring[" "]

         end loop

	 

         stdin.close

         stdout.close

      end process

   end Test
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Erlang

io:fwrite("Hello World~n").	%% im Eingabemodus
anderes Beispiel: 
%%

%% language: Erlang 4.7.3

%% author:   Michael Neumann

%% file:     test.erl

%% 



-module(test).

-export([main/1]).



main(0) -> [];

main(N) -> main(N-1),

           io:fwrite("~w ",[N*N]).



%% Eingabemodus:

c("test.erl").	%% lädt test.erl

test:main(10).
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Euphoria

puts (1, "Hello World\n")
anderes Beispiel: 
for i=1 to 10 do

   print(1,i*i)

   puts(1," ")

end for
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Forth

." Hello World"
oder
: say_hello ." Hello World" ;
say_hello
anderes Beispiel: 
: IS 0 DO I . LOOP ;
: AS 0 DO CR 1 - DUP IS LOOP ;
11 10 AS
ergibt:
0 1 2 3 4 5 6 7 8 9

0 1 2 3 4 5 6 7 8

0 1 2 3 4 5 6 7

0 1 2 3 4 5 6

0 1 2 3 4 5

0 1 2 3 4

0 1 2 3

0 1 2

0 1

0
zur Abschreckung:
10000 constant ztsd  variable zs  2variable tr
: zins ztsd m/mod swap zs @ ztsd */ swap zs @ 1 */ + 1 m* ;
: restd1 2dup zins d+ tr 2@ d- ; ( d -- d )
: restd 0 do restd1 loop ; ( d -- d )
: tdauer 0 >r 2dup zins tr 2@ d< if begin r> 1 + >r restd1 2dup tr 2@ d< until
2dup d0= if 0 else 1 then r> + else ." keine Tilgung " then ; ( d -- d n )

 

 

Fortran 90

PROGRAM HelloWorld



   PRINT *, "Hello World"



END PROGRAM HelloWorld

 

 

Haskell

module HelloWorld (main) where

main = putStr "Hello World\n"
anderes Beispiel: 
--

-- written in Haskell 1.4 (Hugs 1.4 for Windows)

-- by Michael Neumann

-- 



module Test (main) where



square :: [Int] -> String

square []    = "\n"

square (h:t) = show (h*h) ++ " " ++ square t



main = putStr (square [1..10])
ergibt:
1 4 9 16 25 36 49 64 81 100
anderes Beispiel: 
--
-- von Matthias Mann
-- 

module Test (main) where

import List

main = 
   putStr . concat . intersperse " " . map (show . (^2))) [1..10]
ergibt:
1 4 9 16 25 36 49 64 81 100
Quicksort: 
quicksort [] = []

quicksort (s:xs) = quicksort [x|x<-xs,x<s] ++ [s] ++ quicksort [x|x<-xs,x>=s]

 

 

Hope

"Hello World\n";
anderes Beispiel: 
! gibt die Quadrate von 1 bis 10 aus

dec squares : num -> list(num);

--- squares 0 <= nil;

--- squares x <= squares(x-1) <> [x*x];



squares 10;
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

HTML

<html>

<body>

Hello World

</body>

</html>
es geht aber auch einfacher:
Hello World

 

 

Icon

procedure main(args)

    write("Hello World\n")

end
anderes Beispiel: 
# gibt die Quadrate von 1 bis 10 aus

procedure main(args)

    every i := 1 to 10 do {

        write(i*i, " ")

    }

end
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

J

'Hello World'
anderes Beispiel: 
a =. 1 + i. 10

a * a
ergibt:
1 4 9 16 25 36 49 64 81 100
anderes Beispiel: 
+/ % ! i. 9
ergibt:
2.71828    # Eulersche Zahl

 

 

Java

Application:
public class HelloWorld {

   public static void main(String[] args) {

      System.out.println("Hello World");

   }

}
Applett:
public class HelloWorld extends Applet {

   public void paint(Graphics g) {

      g.drawString("Hello World",10,10);

   }

}

 

 

JavaScript

JavaScript (blau) muß in eine HTML-Seite eingebunden werden:
<html>

<body onload="onload()">

<script language="JavaScript">

<!--



function onload() {

   document.writeln('Hello World');

}



//-->

</script>

</body>

</html>

 

 

Leda

{ Hello World in Leda }



include "std.led";

begin

   print("Hello World");

end;
anderes Beispiel: 
include "std.led";



var i:integer;



begin

   for i:=1 to 10 do 

   begin

      print(""+i*i+" ");   

   end;

end;
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Lisp

(print "Hello World")
anderes Beispiel: 
(let ( (a 0) )
  (while (< a 20)
    (princ a) (princ " ")
    (setq a (+ a 1))
  )
)
ergibt:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

 

 

Logo

print [Hello World]

 

 

ML

print "Hello World\n";
anderes Beispiel: 
fun iter (a,b) =

    if a <= b then (print(Int.toString(a*a)^" "); iter(a+1,b) )

    else print "\n";



iter(1,10);
oder:
fun iter 0 = ""

|   iter n = (iter(n-1); print(Int.toString(n*n)^" "); "\n");



print(iter 10);
ergeben:
1 4 9 16 25 36 49 64 81 100

 

 

Modula-2

(* Hello World! *)

MODULE HelloWorld;



FROM InOut IMPORT WriteString, WriteLn;



BEGIN

   WriteString('Hello World');

   WriteLn;

END HelloWorld.

 

 

Modula-3

(* Hello World! *)

MODULE HelloWorld EXPORTS Main;



IMPORT SIO;



BEGIN

   SIO.PutText("Hello World\n");

END HelloWorld.
anderes Beispiel: 
MODULE Test EXPORTS Main;



IMPORT SIO;



BEGIN

   FOR i:=1 TO 10 DO

      SIO.PutInt(i*i);

      SIO.PutText(" ");

   END;

END Test.
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

NESL

% Hello World %

print_string("Hello World\n");
anderes Beispiel: 
function pt(x) = print_string( @(a*a) ++ " " );

{ pt(a) : a in [1..11] };
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Oberon

MODULE HelloWorld;



IMPORT Out;



BEGIN

   Out.Open;

   Out.String('Hello World');

END HelloWorld.

 

 

Objective-C

void main()

{

   printf("Hello World\n");

}
anderes Beispiel: 
void main()

{

   int i;

   for(i=1; i<=10; i++) printf("%d ", i*i);

}
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Obliq

(* Hello World! *)

sys_printText("Hello World\n");
anderes Beispiel: 
for i=1 to 10 do

   sys_printText( text_fromInt(i*i) & " " );

end;
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Oz/Mozart

% Hello World!!!

{Show 'Hello World'}
anderes Beispiel: 
local ShowIt T in

   proc {ShowIt T}

      {Show T*T}

   end



   {For 1 10 1 ShowIt}

end
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Pascal

PROGRAM HelloWorld;

BEGIN

   WRITELN('Hello World');

END.

 

 

Perl

# Hello World in Perl

print 'Hello World.';
anderes Beispiel: 
$a = 3;

$b = 5;

$c = $a + $b;

print "$a + $b = $c"
ergibt:
3 + 5 = 8
anderes Beispiel: 
for($i=1; $i<=10; ++$i) {

   print $i*$i, ' ';

}
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Phantom

(* Hello World! *)

module helloworld;

import stdio;

begin

   stdio.puts("Hello World\n");

end helloworld.
anderes Beispiel: 
module test;

import stdio, fmt;

begin

   for i:=1 to 10 do

      stdio.puts(fmt.fint(i*i) @ " ");

   end;

end test.
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

PHP3

PHP3-Code wird in eine HTML-Seite eingebunden (zwischen <?php und ?>)
<html><body>

<?php echo "Hello World\n"; ?>

</body></html>
anderes Beispiel:
<html><body>

<?php
// gibt die Quadrate von 1-10 aus

for($i=1; $i<=10; ++$i)

{

   echo $i*$i;

   echo " ";

}
?>

</body></html>
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

PL/0E

PROGRAM HelloWorld;

BEGIN

   WRITELN('Hello World');

END.
anderes Beispiel: 
PROGRAM HelloWorld;



VAR i : LONGINT;

BEGIN

   i = 1;



   REPEAT

      WRITE(i*i,' ');

      inc(i);

   UNTIL i>10;

END.
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

PL/1

PRINT(SYSPRINT,'Hello World');
PUTCRLF;
anderes Beispiel: 
i=1;
DO WHILE (i <= 10);
	PRINT(SYSPRINT,i*i,' ');
	i=i+1;
END;
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Postscript

/Courier findfont 
28 scalefont
setfont
0 0 moveto		
(Hello World) show	% Text links unten ausgeben
showpage

 

 

Profan Profan Homepage

PRINT "Hello World"
anderes Beispiel: 
' gibt die Quadrate von 1-10 aus
DECLARE I%
LET I% = 0
WHILENOT @Equ(I%, 10)
	INC I%
	PRINT @Sqr(I%); " ";
WEND
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Prolog Infos

?- write('Hello World'), nl.
anderes Beispiel: 
% Berechnen der Fakultät

fak(0,1).

fak(N,R) :-  N > 0,  M is N - 1,  fak(M,R1),  R is N * R1.



?- fak(6,N).
ergibt:
N = 720

 

 

Python

# Hello World in Python

print "Hello World"
anderes Beispiel: 
arr = range(1,11)

for i in arr: print i*i,
oder: 
for i in map(lambda a: a*a,range(1,11)): print i,
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Rebol

print "Hello World"
anderes Beispiel: 
repeat i 10 [prin i * i prin " "]
oder:
for i 1 10 1 [prin i * i prin " "]
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

REXX

/* Hello World (Kommentar ist wichtig!!!) */

SAY "Hello World"
anderes Beispiel: 
/* */

DO I=1 TO 10

   SAY I*I

END
oder:
/* */

I=1

DO 10

   SAY I*I

   I = I + 1

END
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Ruby Infos

# Hello World in Ruby

print "Hello World\n"
anderes Beispiel: 
(1..10).each { |i| print i*i, " " }
oder:
for i in 1..10

   print i*i, " "

end
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Sather

class MAIN is



   main

   is

      #OUT + "Hello World\n";

   end; -- main



end; -- class MAIN

 

 

Simula 67

begin

   OutText("Hello World");

   OutImage

end
anderes Beispiel: 
comment

   gibt die Quadrate von 1 bis 10 aus;
begin

   integer i;		! ein Integer;



   for i := 1 step 1 until 10 do

   begin

      OutInt(i*i,4);

   end--for-----diese Schleife gibt die Quadrate aus;



   OutImage

end--Ende des Programmes
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Sina

class HelloWorld interface

   methods

      show returns nil;

   inputfilters

      disp: Dispatch = {inner.*};

end;



class HelloWorld implementation

   methods

      show

      begin

         self.printLine('Hello World');

      end;

end;



main

   temps

      hello: HelloWorld;

   begin

      hello.show

   end

 

 

Sirius

@ Hello World in Sirius @



PROGRAM Hello_World

   OUTPUT ('Hello World')

END
anderes Beispiel: 
PROGRAM Squares



PROCEDURE iterate (INTEGER start, ende)

   DECLARE i AS INTEGER

   WHILE (start <= ende)

      i := start * start

      OUTPUT (i)

      start := start + 1

   NEXT

END



iterate (1, 10)



END
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Sisal

%

% Hello World!!!

%



define main

function main(returns array [Character])

   "Hello World"

end function
anderes Beispiel: 
define main

function main(returns array [Integer])

   for i in 1, 10

      x := i * i

      returns array of x

   end for

end function
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

Smalltalk

'Hello World' out.
anderes Beispiel: 
| someNumbers |
someNumbers := { 1 2 3 4 5 6 7 8 9 10}
(someNumbers collect: [:i| i squared.]) out.
ergibt:
1 4 9 16 25 36 49 64 81 100
Quicksort:
" This must be inserted into the class Array as an instance method "
quicksort: l to: r

" sorts the array between l and r after the quicksort method 

  by Michael Neumann 1998

"
	| m il ir temp |

	(r > l) ifTrue: [

		m := self at: ((l + r) // 2).

		il := l.

		ir := r.

		[

			[(self at: il) < m] whileTrue: [il := il + 1.].

			[(self at: ir) > m] whileTrue: [ir := ir - 1.].

			(il < ir) ifTrue: [

				" swap "

				temp := self at: il.

				self at: il put: (self at: ir).

				self at: ir put: temp.				

			].

		] doUntil: [il >= ir.].

		self quicksort: l to: (il - 1).

		self quicksort: (il + 1) to: r.

	].

^self.

 

 

SQL

SELECT 'Hello World'

 

 

Tcl/Tk

ohne Tk (GUI - Graphical User Interface):
puts "Hello World"
mit Tk:
button .hello -text "Hello World" -command {destroy .}
pack .hello
anderes Beispiel: 
set a 3
set b 5
puts "$a + $b = [expr $a + $b]"
ergibt:
3 + 5 = 8
anderes Beispiel: 
set i 1
while {$i <= 10} {puts [expr $i*$i];set i [expr $i+1]}
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

TOM

implementation class HelloWorld



int main Array argv

{

    [[[stdio out] print "Hello World"] nl];

    return 0;

}



end;



implementation instance HelloWorld end;
anderes Beispiel: 
implementation class Test



int main Array argv

{

    for( int i=1; i<=10; ++i ) [[stdio out] print (i*i, " ")];

    return 0;

}



end;



implementation instance Test end;
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

UFO

main : String is

"Hello World\n"
anderes Beispiel:
**

** Gibt die Quadrate von 1 bis 10 aus

**

main : String is

{

   squares = for i in [1 to 10] do

             return all i*i

             od;



   output  = initially txt = ""

             for i in squares do

                new txt = txt ++ print(i) ++ " "

             return txt

             od;



   return output ++ "\n"

}
ergibt:
1 4 9 16 25 36 49 64 81 100

 

 

WML

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
   <card id="Hello_World" title="Hello World">
      <p>Hello World</p>
   </card>
</wml>

 


eMail: neumann@s-direktnet.de

letzte Änderung: 20.11.1999 von Michael Neumann

http://www.s-direktnet.de/homepages/sprachen.htm