"hello, world"
Von http://www.jargon.org:hello worldhello world interj. 1. The canonical minimal test message in the C/Unix universe. 2. Any of the minimal programs that emit this message. Traditionally, the first program a C coder is supposed to write in a new environment is one that just prints "hello, world" to standard output (and indeed it is the first example program in K&R;). Environments that generate an unreasonably large executable for this trivial test or which require a hairy compiler-linker invocation to generate it are considered to lose (see X). 3. Greeting uttered by a hacker making an entrance or requesting information from anyone present. "Hello, world! Is the LAN back up yet?"
Hier also nun eine kleine Auswahl an Sprachen und deren hello-world Fassungen unter Linux.
C
#include <stdio.h>Übersetzbar mit der GNU Compiler Collection (aka GNU C Compiler): GCC
int main()
{
printf ("hello, world\n");
return 0;
}
C++
#include <iostream.h>Übersetzbar mit der GNU Compiler Collection: GCC/GPP
void main(){
cout << "hello, world" << endl;
}
Java
class Hello {
static public void main(String[] args) {
System.out.println("hello, world");
}
}
Übersetzbar mit dem javacPascal
program hello;Übersetzbar mit
begin
writeln('hello, world');
end.
Assembler
Übersetzbar mit der GNU Assember: GCC/GPPportable i386-Fassung (aus C-Source generiert):
.file "hello.c" .version "01.01"gcc2_compiled.:.section .rodata.LC0: .string "hello, world\n".text .align 16.globl main .type main,@functionmain: pushl %ebp movl %esp,%ebp pushl $.LC0 call printf addl $4,%esp xorl %eax,%eax jmp .L1 .align 16.L1: movl %ebp,%esp popl %ebp ret.Lfe1: .size main,.Lfe1-main .ident "GCC: (GNU) egcs-2.91.66 19990314 (egcs-1.1.2 release)"Linux-spezifische Fassung
section .text global _start ;must be declared for linker (ld) msg db 'Hello, world!',0xa ;our dear string len equ $ - msg ;length of our dear string _start: ;tell linker entry point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel
Python
#!/usr/bin/pythonprint "Hello world!"
Perl
#!/usr/bin/perlprint("hello, world\n");Basic
print "hello, world"
Lisp
(format t "hello, world~%")
JavaScript
document.write('<h2>hello, world</h2><br>')Shell (Bash)
#!/bin/shecho hello, world
Flex/Bison (Beispiel)
%{/* * The HelloWolrd Language: THeWoL */%}%%[\t ]+ ;hello |hallo |helloworld |halloworld |hi { printf("hello, world\n"); }easteregg { printf("this is an easter egg!\n"); }quit { printf("bye.\n"); exit(0); }. { printf("we have a slight problem here...\n"); }%%int main(int argc, char **argv){ if(argc>1) { printf("usage: %s\n", argv[0]); } printf("Welcome to to THeWoL!\n"); yylex();}yywrap(){ return 0;}Prolog
?- write('Hello world!'), nl.