Hello world

From CodeCodex

Contents

[edit] Implementations

[edit] Ada


with Ada.Text_IO;

procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello World!");
end Hello;

[edit] Algol 68

print(("Hello, World!", new line))

[edit] ASP


<% Response.Write("Hello World!") %>

[edit] x86 Assembler

[edit] 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

[edit] 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

[edit] BASIC


print "Hello World!"

[edit] C


#include <stdio.h>

int main(void)
{
        printf("Hello, World!\n");
        return 0;
}

[edit] C++


#include <iostream>

int main()
{
        std::cout << "Hello, World!" << std::endl;
        return 0;
}

OR


#include <iostream>
using namespace std;

int main()
{
        cout << "Hello, World!" << endl;
        return 0;
}

[edit] C#


using System;

public class HelloWorld
{
        public static void Main()
        {
                System.Console.WriteLine("Hello World!");
        }
}

[edit] Common Lisp

(write-line "Hello, World!\n")

..or..


(defun main ()
(write-line "Hello, World!")
0)

[edit] Fortran


PROGRAM HelloWorld
WRITE(*,*)"Hello, World!"
END PROGRAM

[edit] Go


package main

import "fmt"

func main()
{
        fmt.Println("Hello, World!")
}

[edit] Groovy


println("Hello World!");

or


println "Hello World!"

[edit] Haskell

main = putStrLn "Hello World!"

[edit] Io

"Hello, world!" println

[edit] 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()
        }
}

[edit] Lua

print "Hello, world!"

[edit] OCaml


# print_endline "Hello world!";;
Hello world!
- : unit = ()

[edit] Pascal


program HelloWorld;

begin
writeln('Hello, world!');
end.

[edit] Perl


print "Hello World\n";

[edit] As PL File


print "Hello World\n";

[edit] As CGI File


#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<H1>Hello World</H1>";

[edit] PHP


<?php
echo "Hello, world!\n";
?>

[edit] 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

[edit] Progress 4GL/ABL


display "Hello World!".

[edit] Python


print "Hello, World!"

[edit] Rexx


/* */
say "Hello, World!"

[edit] Ruby


puts "Hello, World!"

# OR
p "Hello, World!"

# OR
print "Hello, World!"

[edit] Scheme

(display "Hello, world!")

[edit] Seed7


$ include "seed7_05.s7i";

const proc: main is func
begin
writeln("Hello, world!");
end func;

[edit] Tcl

puts "Hello, World!"

[edit] Turing


put "Hello, World!"

[edit] Visual Basic


Console.WriteLine("Hello, World!")

[edit] Zsh

Three forms

echo "Hello, World\!"
print "Hello, World\!"
printf "Hello, World\!\012"