Computer Club Ostfriesland e.V.
Gemeinnütziger Verein für Aus- und Fortbildung
  • Startseite
  • Der Verein
  • Ansprechpartner
  • Selbst mitarbeiten
  • Kontakt
  • Adresse
  • Newsletter
  • IRC-Chat
  • Aktuelles
  • Kalender
  • Schulungen
  • Aktuelle Kurse
  • Themen und Gruppen
  • Senioren
  • Video und Foto
  • Linux
  • Mikrocontroller
  • Audio und Sound
  • Jugendliche
  • Administration
  • Mitglieder
  • Blog
  • Homepages
  • Webmail
  • Verteiler
  • Nachrichten schreiben
Startseite  >  Eigene Projekte  >  hello, world
  • Foto-Galerie
  • Projekte
  • Andere LUGs
  • Termine der Treffen
  • Buch-Rezensionen
hello, world

"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>
int main()
{
printf ("hello, world\n");
return 0;
}
Übersetzbar mit der GNU Compiler Collection (aka GNU C Compiler): GCC

C++

#include <iostream.h>
void main(){
cout << "hello, world" << endl;
}
Übersetzbar mit der GNU Compiler Collection: GCC/GPP

Java

class Hello {
static public void main(String[] args) {
System.out.println("hello, world");
}
}
Übersetzbar mit dem javac

Pascal

program hello;
begin
writeln('hello, world');
end
.
Übersetzbar mit
  • Free Pascal: FPC
  • GNU Pascal Compiler: GPC

Assembler

portable 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
Übersetzbar mit der GNU Assember: GCC/GPP

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.

Copyright 1997-2007 Computer Club Ostfriesland e.V. | Impressum