Hello world
From CodeCodex
Revision as of 22:19, 20 February 2011 by 50.12.34.87 (Talk)
Contents
- 1 Implementations
- 1.1 Ada
- 1.2 Algol 68
- 1.3 ASP
- 1.4 x86 Assembler
- 1.5 BASIC
- 1.6 C
- 1.7 C++
- 1.8 C#
- 1.9 Common Lisp
- 1.10 Erlang
- 1.11 Fortran
- 1.12 Go
- 1.13 Groovy
- 1.14 Haskell
- 1.15 Io
- 1.16 Java
- 1.17 LOLCODE
- 1.18 Lua
- 1.19 OCaml
- 1.20 Pascal
- 1.21 Perl
- 1.22 PHP
- 1.23 PostScript
- 1.24 Progress 4GL/ABL
- 1.25 Python
- 1.26 Rexx
- 1.27 Ruby
- 1.28 Scheme
- 1.29 Seed7
- 1.30 Tcl
- 1.31 Turing
- 1.32 Visual Basic
- 1.33 Zsh
Implementations
Ada
with Ada.Text_IO; procedure Hello is begin Ada.Text_IO.Put_Line("Hello World!"); end Hello;
Algol 68
print(("Hello, World!", new line))
ASP
<% Response.Write("Hello World!") %>
x86 Assembler
Turbo Assembler, Windows
.model tiny .data message db 'Hello, World!' .code org 100h start: mov ah,9 mov dx,offset message int 21h ret end start
Netwide Assember, GNU/Linux
section .text global _start _start: mov edx, msglen mov ecx, msg mov ebx, 0x1 mov eax, 0x4 int 0x80 mov ebx, 0x0 mov eax, 0x1 int 0x80 section .data msg db "Hello, world!", 0xa msglen equ $ - len
BASIC
print "Hello World!"
C
#include <stdio.h> int main(void) { printf("Hello, World!\n"); return 0; }
C++
#include <iostream> int main() { std::cout << "Hello, World!" << std::endl; }
OR
#include <iostream> using namespace std; int main() { cout << "Hello, World!" << endl; }
C#
using System; public class HelloWorld { public static void Main() { System.Console.WriteLine("Hello World!"); } }
Common Lisp
(write-line "Hello, World!\n")
..or..
(defun main () (write-line "Hello, World!") 0)
Erlang
io:fwrite("Hello, World!~n").
Fortran
PROGRAM HelloWorld WRITE(*,*)"Hello, World!" END PROGRAM
Go
package main import "fmt" func main() { fmt.Println("Hello, World!") }
Groovy
println("Hello World!");
or
println "Hello World!"
Haskell
main = putStrLn "Hello World!"
Io
"Hello, world!" println
Java
class HelloWorld { public static void main(String args[]) { System.out.println("Hello World!"); } }
Alternatively:
class HelloWorld { static { System.out.println("Hello World!"); System.exit(0); // exit before the JVM tries to run non-existent main() } }
LOLCODE
HAI CAN HAS STDIO? VISIBLE "HAI WORLD!" KTHXBYE
Lua
print "Hello, world!"
OCaml
# print_endline "Hello world!";; Hello world! - : unit = ()
Pascal
program HelloWorld; begin writeln('Hello, world!'); end.
Perl
print "Hello World\n";
As PL File
print "Hello World\n";
As CGI File
#!/usr/local/bin/perl print "Content-type: text/html\n\n"; print "<H1>Hello World</H1>";
PHP
<?php echo "Hello, world!\n"; ?>
PostScript
The strict equivalent to the other languages (print a string to standard output) would be:
(Hello, World!) =
However, this is not typical of how PostScript is normally used, to generate and print page images.
The following version prints a page with the "Hello, World!" message.
/Helvetica findfont % use a standard font 72 scalefont setfont % make it nice and big 100 100 moveto % someplace convenient on the page (Hello, World!) show showpage
Progress 4GL/ABL
display "Hello World!".
Python
print "Hello, World!"
Rexx
/* */ say "Hello, World!"
Ruby
puts "Hello, World!" # OR p "Hello, World!" # OR print "Hello, World!\n"
Scheme
(display "Hello, world!")
Seed7
$ include "seed7_05.s7i"; const proc: main is func begin writeln("Hello, world!"); end func;
Tcl
puts "Hello, World!"
Turing
put "Hello, World!"
Visual Basic
Console.WriteLine("Hello, World!")
Zsh
Three forms
echo "Hello, World\!" print "Hello, World\!" printf "Hello, World\!\012"