Liste von Hallo-Welt-Programmen/Höhere Programmiersprachen
Dies ist eine Liste von Hallo-Welt-Programmen für gebräuchliche Programmiersprachen. Weitere Beispiele für grafische Benutzeroberflächen, Web-Technologien, exotische Programmiersprachen und Textauszeichnungssprachen sind unter Liste von Hallo-Welt-Programmen/Sonstige aufgeführt.
Alert("Hallo Welt!")
REPORT Z_HALLO_WELT. WRITE 'Hallo Welt!'.
trace('Hallo Welt');
ActionScript 3.0 und unter Benutzung der DocumentClass
package {
import flash.display.Sprite;
public class Main extends Sprite
{
public function Main() {
trace( "Hallo Welt!" );
}
}
}
with Ada.Text_IO;
procedure Hallo is
begin
Ada.Text_IO.Put_Line ("Hallo Welt!");
end Hallo;
Für eine Erklärung des Programmes siehe wikibooks:Ada_Programming/Basic.
'BEGIN' OUTSTRING(2,'('HALLO WELT')'); 'END'
- Anmerkung: Bei der Sprachdefinition von ALGOL 60 wurden die Ein-/Ausgabeanweisungen ausdrücklich von der Standardisierung ausgenommen, so dass deren Implementierungen stark zwischen den Compilern variieren. So wird dieser Text bei der Electrologica X1 (nach vorheriger Wahl des Ausgabekanals mit SELECTOUTPUT(2);) mit WRITETEXT('('HALLO WELT')'); statt mit dem OUTSTRING-Befehl ausgegeben.
( print("Hallo Welt!") )
'Hallo Welt!'
.MODEL Small
.STACK 100h
.DATA
HW DB 'Hallo Welt!$'
.CODE
start:
MOV AX,@data
MOV DS,AX
MOV DX, OFFSET HW
MOV AH, 09H
INT 21H
MOV AH, 4Ch
INT 21H
end start
'''FASM example of writing 16-bit DOS .COM program'''
; Kompilieren: "FASM HELLO.ASM HELLO.COM"
org $100
use16
mov ah,9
mov dx,hello
int $21 ; Textausgabe
mov ah,$4C
int $21 ; Programm beenden
hello db 'Hallo Welt !!!$'
# Kompilieren mit "as -o hallo.o hallo.s; ld -o hallo hallo.o" .section .data s: .ascii "Hallo Welt!\n" .section .text .globl _start _start: movl $4,%eax # Syscall-ID 4 (= __NR_write) movl $1,%ebx # Ausgabe-Filedeskriptor STDOUT (= 1) movl $s,%ecx # Adresse des ersten Zeichens der Zeichenkette movl $12,%edx # Länge der Zeichenkette (12 Zeichen) int $0x80 # Softwareinterrupt 0x80 um Syscall (write(1,s,12))auszuführen movl $1,%eax # Syscall-ID 1 (= __NR_exit) movl $0,%ebx # Rückgabewert 0 (= alles ok) int $0x80 # Softwareinterrupt 0x80 um Syscall (exit(0)) auszuführen
# Kompilieren mit "gcc -nostdlib -s hallo.s" .section .rodata .align 2 .s: .string "Hallo Welt!\n" .section ".text" .align 2 .globl _start _start: li 0,4 # SYS_write li 3,1 # fd = 1 (stdout) lis 4,.s@ha # buf = .s la 4,.s@l(4) li 5,12 # len = 12 sc # syscall li 0,1 # SYS_exit li 3,0 # returncode = 0 sc # syscall
; Getestet mit ASM-One V1.01 move.l 4.w,a6 lea dosn(pc),a1 jsr -408(a6) ; OldOpenLibrary move.l d0,a6 lea s(pc),a0 move.l a0,d1 jsr -948(a6) ; PutStr move.l a6,a1 move.l 4.w,a6 jsr -414(a6) ; CloseLibrary moveq #0,d0 rts dosn: dc.b "dos.library",0 s: dc.b "Hallo Welt!",10,0
; Kompiliert und getestet mit ; "as hallo.s ; ld hallo.o /usr/ccs/lib/crt0" ; unter HP-UX 11.0 auf einer HP9000/L2000 .LEVEL 1.1 .SPACE $TEXT$ .SUBSPA $LIT$,ACCESS=0x2c s .STRING "Hallo Welt!\x0a" .SPACE $TEXT$ .SUBSPA $CODE$,ACCESS=0x2c,CODE_ONLY .EXPORT _start,ENTRY,PRIV_LEV=3 .EXPORT __errno .EXPORT __sys_atexit _start __errno __sys_atexit ldil L'0xC0000000,%r18 ldi 4,%r22 ; SYS_write ldi 1,%r26 ; fd = stdout ldil LR's,%r4 ldo RR's(%r4),%r25 ; buf = s be,l 4(%sr7,%r18) ; Syscall ldi 12,%r24 ; len = 12 (Branch delay slot) ldi 1,%r22 ; SYS_exit be,l 4(%sr7,%r18) ; Syscall ldi 0,%r26 ; returncode = 0 (Branch delay slot)
x86-CPU, FreeBSD, Intel-Syntax
section .data
hello_world db 'Hallo Welt!', 0x0a
hello_world_len equ $ - hello_world
section .text
align 4
sys:
int 0x80
ret
global _start
_start:
push hello_world_len
push hello_world
push 1
mov eax, 4
call sys
push 0
mov eax, 1
call sys
; Kompilieren mit "as -o hallo.o hallo.s; ld -o hallo hallo.o"
.section .data
hello_str:
.asciz "Hallo Welt!\n"
.align 4 ; Speicher muss aligned sein, damit wir später mit ld darauf zugreifen können
hello_str_len:
.word . - hello_str ; Länge der Zeichenkette (12 Zeichen)
.section .text
.global _start
_start:
set 4, %g1 ; Syscall-ID 4 (= __NR_write)
set 1, %o0 ; Ausgabe-Filedeskriptor STDOUT (= 1)
set hello_str, %o1 ; Adresse des ersten Zeichens der Zeichenkette
set hello_str_len, %l0 ; Die Stack-Adresse an der die Länge der Zeichenkette steht in local 0 laden
ld [%l0], %o2 ; Den Wert auf den local 0 zeigt in out 2 laden
t 0x110 ; Softwareinterrupt 0x110 um Syscall (write(1,hello_str,hello_str_len))auszuführen
set 1, %g1 ; Syscall-ID 1 (= __NR_exit)
set 0, %o0 ; Rückgabewert 0 (= alles ok)
t 0x110 ; Softwareinterrupt 0x110 um Syscall (exit(0)) auszuführen
Assemblersprache (Jasmin):
; HelloWorld.j .bytecode 50.0 .source HelloWorld.java .class public HelloWorld .super java/lang/Object .method public <init>()V .limit stack 1 .limit locals 1 aload_0 invokespecial java/lang/Object/<init>()V return .end method .method public static main([Ljava/lang/String;)V .limit stack 2 .limit locals 1 getstatic java/lang/System/out Ljava/io/PrintStream; ldc "Hallo Welt!" invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V return .end method
MIPS-32 mit erweitertem Befehlssatz
.data helloworld: .asciiz "Hallo Welt!" .text la $a0, helloworld li $v0, 4 syscall
Variante 1 - eine klassische MessageBox
MsgBox Hallo Welt!
Variante 2 startet das Programm Notepad und tippt dort Hallo Welt ein
Run, "notepad.exe" WinWaitActive, ahk_class Notepad Send, Hallo Welt{!}
Variante 1: Startet eine normale Message box ohne Titel
MsgBox(0, "", "Hallo Welt!")
Variante 2: Startet den Notepad, wartet bis Aktiv, hält das Fenster während der Ausführung des Send Befehles aktiv und schreibt Hallo Welt! rein.
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
SendKeepActive("[CLASS:Notepad]")
Send("Hallo Welt!",1)
BEGIN { print "Hallo Welt!" }
main() {
printf("Hallo Welt!");
}
Traditionelles, unstrukturiertes BASIC:
10 PRINT "Hallo Welt!"
bzw. im Direktmodus:
?"Hallo Welt!"
@echo Hallo Welt!
GET "LIBHDR" LET START () BE $( WRITES ("Hallo Welt!*N") $)
print("Hallo Welt!");
Gibt nur "Hi" aus. Das "Hello World" wäre zwölf mal so lang.
Baa, badassed areas! Jarheads' arses queasy nude adverbs! Dare address abase adder? *bares baser dadas* HA! Equalize, add bezique, bra emblaze. He (quezal), aeons liable. Label lilac "bulla," ocean sauce! Ends, addends, duodena sounded amends.
Print "Hallo Welt!"
Waitkey
print "Hallo Welt!"
MESSAGE('Hallo Welt')
#include <stdio.h>
int main(void)
{
printf("Hallo Welt!\n");
return 0;
}
Siehe auch: Hallo-Welt-Programm in C, Varianten der Programmiersprache C
#include <iostream>
#include <ostream>
int main()
{
std::cout << "Hallo Welt!" << std::endl;
}
int main()
{
System::Console::WriteLine("Hallo Welt!");
}
class MainClass
{
public static void Main()
{
System.Console.WriteLine("Hallo Welt!");
}
}
.method public static void Main() cil managed
{
.entrypoint
.maxstack 1
ldstr "Hallo Welt!"
call void [mscorlib]System.Console::WriteLine(string)
ret
}
? "Hallo Welt!"
WRITE HALLO WELT
CLP
PGM
SNDPGMMSG MSG('Hallo Welt!') MSGTYPE(*COMP)
ENDPGM
000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. HELLOWORLD. 000500 ENVIRONMENT DIVISION. 000700 DATA DIVISION. 000900 PROCEDURE DIVISION. 001100 MAIN-LOGIC SECTION. 001200 DISPLAY "Hallo Welt!". 001300 STOP RUN.
<cfscript> WriteOutput("Hallo Welt!"); </cfscript>
10 PRINT "Hallo Welt!"
10 print "Hallo Welt!";
(write-line "Hallo Welt!")
MODULE HalloWelt; IMPORT Out; PROCEDURE Output*; BEGIN Out.String ("Hallo Welt!"); Out.Ln; END Output; END HalloWelt.
module helloworld;
import std.stdio;
void main()
{
writeln("Hallo Welt!");
}
print "Hallo Welt!" wait key
Ausgabe in der nächsten freien Zeile:
? "Hallo Welt!"
Zeilen- und spaltengenaue Ausgabe:
@1,1 say "Hallo Welt!"
Ausgabe in einem Fenster:
wait window "Hallo Welt!"
define method hallo-welt() format-out("Hallo Welt!\n"); end method hallo-welt; hallo-welt();
in der Variante tdbengine:
module helloworld procedure Main cgiclosebuffer cgiwriteln("content-type: text/html") cgiwriteln("") cgiwriteln("Hallo Welt!") endproc
class HALLO_WELT
create
make
feature
make is
do
io.put_string("Hallo Welt!%N")
end
end
putline ("Hallo Welt!");
Emacs Lisp
(print "Hallo Welt!")
-module(Hallo). -export([Hallo_Welt/0]). Hallo_Welt() -> io:fwrite("Hallo Welt!\n").
im Direktmodus via Interpreter (z.B in einem "Forth-Script"):
.( Hallo Welt!)
oder in kompilierter Form:
: GREET ." Hallo Welt!" ; ( GREET wird durch Kompilierung erzeugt ) GREET ( und unmittelbar darauf ausgeführt )
program hallo
write(*,*) "Hallo Welt!"
end program hallo
component HalloWelt export Executable run(args:String...) = print "Hallo Welt!" end
print "Hallo Welt!"
show_message("Hallo Welt!");
oder
draw_text(x,y,"Hallo Welt!");
def name='World'; println "Hello $name!"
main :: IO () main = putStrLn "Hallo Welt!"
PRO hallo_welt
PRINT, "Hallo Welt!"
END
"Hallo Welt!" print
.assembly HalloWelt { } .assembly extern mscorlib { } .method public static void SchreibeHalloWelt() { .maxstack 1 .entrypoint ldstr "Hallo Welt!" call void [mscorlib]System.Console::WriteLine(string) ret }
Jass
function test takes nothing returns nothing call BJDebugMsg("Hallo Welt!") endfunction
oder
function test takes nothing returns nothing call DisplayTextToPlayer(Player(0), 0, 0, "Hallo Welt!") // für Spieler 1 endfunction
oder
function test takes nothing returns nothing call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Hallo Welt!") // für den lokalen Spieler endfunction
Das ganze jetzt noch für eine bestimmte Zeit:
function test takes nothing returns nothing call DisplayTimedTextToPlayer(Player(0), 0, 0, 10, "Hallo Welt!") // für Spieler 1 und für 10 sekunden endfunction
oder
function test takes nothing returns nothing call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 10, "Hallo Welt!") // für den lokalen Spieler und für 10 sekunden endfunction
public class HalloWelt
{
public static void main(String[] args)
{
System.Console.WriteLine("Hallo Welt!");
}
}
document.write("Hallo Welt!");
oder
document.innerHTML="Hallo Welt!";
oder
alert("Hallo Welt!");
public class Hallo
{
public static void main(String[] args)
{
System.out.println("Hallo Welt!");
}
}
print ("Hallo Welt!")
print [Hallo Welt!]
Hallo Welt!
fprintf('Hallo Welt!');
oder
disp('Hallo Welt!');
oder
disp Hallo_Welt
Maschinensprache (DOS-COM-Programm auf Intel 80x86)
BA 0B 01 B4 09 CD 21 B4 4C CD 21 48 61 6C 6C 6F 2C 20 57 65 6C 74 21 0D 0A 24
on 1:load:*: { echo Hallo Welt! }
TERM EQU 18 the MIX console device number ORIG 1000 start address START OUT MSG(TERM) output data at address MSG HLT halt execution MSG ALF "MIXAL" ALF " HALL" ALF "O WEL" ALF "T " END START end of the program
string BYTE "Hallo Welt!",#a,0 % auszugebende Zeichenkette (#a ist ein Zeilenumbruch, % 0 schließt die Zeichenkette ab) Main GETA $255,string % Adresse der Zeichenkette in Register $255 ablegen TRAP 0,Fputs,StdOut % Zeichenkette, auf die mit Register $255 % verwiesen wird, nach StdOut ausgeben (Systemaufruf) TRAP 0,Halt,0 % Prozess beenden
echo Hallo Welt!
W "Hallo Welt!",!
WRITE 'Hallo Welt!'.
class Hello { static Main () : void { System.Console.WriteLine ("Hallo Welt!"); } }
oder:
System.Console.WriteLine("Hallo Welt!");
MODULE HalloWelt; IMPORT Write; BEGIN Write.Line("Hallo Welt!"); END HalloWelt.
print_string "Hallo Welt!\n";;
#import <stdio.h>
int main()
{
puts("Hallo Welt!");
return 0;
}
Oder mit Hilfe des Foundation-Frameworks (und in neuer typischer Schreibweise):
#import "Class.h"
int main() {
NSLog(@"Hallo Welt");
return 0;
}
Außerdem wird ein Header benötigt:
#import <Foundation/Foundation.h>
@interface Class : NSObject {
}
@end
method run(var eventInfo Event) msginfo("Info", "Hallo Welt!") endMethod
Object Pascal (Delphi)
program HalloWelt;
{$APPTYPE CONSOLE}
begin
writeln('Hallo Welt!');
end.
-- Signatur und Implementation sind eigentlich zwei Dateien Signature HelloWorld FUN Hello : denotation Implementation HelloWorld FUN Hello : denotation DEF Hello == "Hallo Welt!\n"
PROC Hallo: PRINT "Hallo Welt!" ENDP
{Show 'Hallo Welt!'}
program Hallo ( output );
begin
writeln('Hallo Welt!')
end.
program HalloWelt;
begin
WriteLn('Hallo Welt!');
end.
print "Hallo Welt!\n";
oder
say "Hallo Welt!";
<? class Program { static function Main() { echo "Hallo Welt!\n"; return 0; } } ?>
<?php
print "Hallo Welt!";
?>
oder:
<?php
echo "Hallo Welt!";
?>
oder mit "short tags":
<?="Hallo Welt!"?>
int main() {
write("Hallo Welt!\n");
return 0;
}
T:Hallo Welt!
Konsole:
main() {
puts("Hallo Welt!");
}
Dialogfenster:
main() {
alert("Hallo Welt!");
}
In einer Textbox:
main() {
box=createctl("EDIT","Test",ES_MULTILINE,0x000,30,30,100,30,3000);
editset(box,"Hallo Welt!");
}
Test: procedure options(main); put skip list("Hallo Welt!"); end Test;
CREATE OR REPLACE PROCEDURE HelloWorld as
BEGIN
DBMS_OUTPUT.PUT_LINE('Hallo Welt!');
END;
%! /Courier findfont % Schrift auswählen 20 scalefont % auf Schriftgröße 20 skalieren setfont % zum aktuellen Zeichensatz machen 50 50 moveto % (50, 50) als aktuelle Schreibposition setzen (Hallo Welt!) show % und dort den Text ausgeben showpage % Seite ausgeben
camera { location <0, 0, -5> look_at <0, 0, 0> } light_source { <10, 20, -10> color rgb 1 } light_source { <-10, 20, -10> color rgb 1 } background { color rgb 1 } text { ttf "someFont.ttf" "Hallo Welt!", 0.015, 0 pigment { color rgb <0, 0, 1> } translate -3*x }
Kommandozeile:
"Hallo Welt!"
alternativ:
Write-Host "Hallo Welt!"
oder:
echo "Hallo Welt!"
oder:
[System.Console]::WriteLine("Hallo Welt!")
Dialogfenster:
[System.Windows.Forms.MessageBox]::Show("Hallo Welt!")
DISPLAY "Hallo Welt!".
?- write('Hallo Welt!'), nl.
active proctype HalloWeltProc() { printf("Hallo Welt!"); }
oder
proctype HalloWeltProc() { printf("Hallo Welt!"); } init { run HalloWeltProc(); }
In der Konsole
OpenConsole() Print("Hallo Welt!") Input() ;Beendet das Programm beim nächsten Tastendruck CloseConsole()
Im Dialogfenster
MessageRequester("","Hallo Welt!",0)
Im Fenster
If OpenWindow (1,0,0,300,50,"Hallo Welt!",#PB_Window_ScreenCentered|#PB_Window_SystemMenu) ; Öffnet ein zentriertes Fenster If CreateGadgetList(WindowID(1)) ; Erstellt eine Gadgetliste TextGadget(1,10,10,280,20,"Hallo Welt!",#PB_Text_Border) ; Erstellt ein Textfeld "Hallo Welt!" EndIf Repeat delay(0) ; 0 ms warten (Prozessor entlasten) event.l = WaitWindowEvent() ; Arbeitet die Windowsevents ab Until event.l = #PB_Event_CloseWindow ; solange bis X gedrückt wird End EndIf
Patch im Quelltext
#N canvas 0 0 300 300 10; #X obj 100 100 loadbang; #X msg 100 150 Hallo Welt; #X obj 100 200 print; #X connect 0 0 1 0; #X connect 1 0 2 0;
print "Hallo Welt!"
PRINT "Hallo Welt!"
print ("Hallo Welt!")
oder
cat ("Hallo Welt!\n")
say "Hallo Welt!"
RPG 3
C MOVE *BLANKS HALLO 10 C MOVEL'HALLO' HALLO C MOVE 'WELT' HALLO C DSPLY HALLO C MOVE '1' *INLR
RPG 4
D HALLO S 10A C EVAL HALLO = 'Hallo Welt' C DSPLY HALLO C EVAL *INLR = *ON
RPG 4 (Free)
D HALLO S 10A /FREE HALLO = 'Hallo Welt'; DSPLY HALLO; *INLR = *ON; /END-FREE
<< "Hallo Welt!" 1 DISP>>
puts 'Hallo Welt!'
data _null_;
put "Hallo Welt!";
run;
oder
%put Hallo Welt!;
object HalloWelt extends Application { println("Hallo Welt!") }
(display "Hallo Welt!")
(newline)
iHallo Welt! Q
$ include "seed7_05.s7i"; const proc: main is func begin writeln("Hallo Welt!"); end func;
'Hallo Welt!' print.
Mit Enfin Smalltalk:
'Hallo Welt!' out.
Mit VisualWorks:
Transcript show: 'Hallo Welt!'.
OUTPUT = "Hallo Welt!" END
using System; public class Program { public static void Main(string![]! args) requires forall{int i in (0:args.Length); args[i] != null}; { Console.WriteLine("Hallo Welt!"); } }
print "Hallo Welt!\n"
debug "Hallo Welt!";
SELECT 'Hallo Welt!' AS message;
SELECT 'Hallo Welt!' FROM dual;
Für IBM-DB2
SELECT 'Hallo Welt!' FROM sysibm.sysdummy1;
Für MSSQL
SELECT 'Hallo Welt!'
StarOffice Basic
sub main print "Hallo Welt!" end sub
puts "Hallo Welt!"
iHallo Welt!$ht$$
TI-Basic auf dem TI-83 Plus.
:Disp "Hallo Welt!"
oder
:Output(1,1,"Hallo Welt!")
oder
:Text(1,1,"Hallo Welt!")
put "Hallo Welt!"
echo 'Hallo Welt!'
module hallo_welt; initial begin $display ("Hallo Welt!"); #10 $finish; end endmodule
entity HelloWorld is
end entity HelloWorld;
architecture Bhv of HelloWorld is
begin
HelloWorldProc: process is
begin
report "Hallo Welt!";
wait;
end process HelloWorldProc;
end architecture Bhv;
Public Shared Sub main()
System.Console.Write("Hallo Welt!")
End Sub
print "Hallo Welt!\n"; pause;
oder
info("Hallo Welt!\n");
module Main; begin writeln("Hallo Welt!") end Main.
Siehe auch
Weblinks
- The Hello World Collection (über 370 Programmbeispiele)
- Index of Hello World! programs and beyond (englisch)