Fork me on GitHub

tutorials.github.com

Decentralized polyglot tutorials

Hello, World!

Here are some examples of “Hello, World!” in various programming languages.

ActionScript

trace("Hello, World!");

Ada

with TEXT_IO;

procedure HELLO is
begin
 TEXT_IO.PUT_LINE ("Hello, World!");
end HELLO;

AppleScript

return "Hello, World!"

Awk

Befunge

>              v
v  ,,,,,"Hello"<
>48*,          v
v,,,,,,"World!"<
>25*,@

Boo

print "Hello, World!"

BrainFuck

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

C

#include <stdio.h>

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

C++

#include <iostream>

int main()
{
  std::cout << "Hello, World!\n";
}

C#

using System;

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

Clojure

(def hello (fn [] "Hello, World!"))
(hello)

CoffeeScript

alert "Hello, World!"

ColdFusion

<cfoutput>Hello, World!</cfoutput>

Common Lisp

(format t "Hello, World!~%")

or

(write-line "Hello World!")

or

"Hello World!"

Cython

print "Hello, World!"

D

import std.stdio;

void main () 
{
  writef("Hello, World!");
}

Dart

Delphi

program Hello_World;
uses 
 Windows;

begin
 ShowMessage("Hello, World!");
end.

Dylan

module: hello

format-out("Hello, World!\n");

Erlang

-module(hello).
-export([hello_world/0]).

hello_world() -> io:fwrite("Hello, World!\n").

Factor

"Hello, World!" print

Fancy

F#

Fortran

PROGRAM HELLO
PRINT *, 'Hello, World!'
END

Groovy

Haskell

module Main (main) where

main = putStrLn "Hello, World!"

Io

write("Hello, World!\n")

Java

public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, World!");
  }
}

JavaScript

document.write('Hello, World!');

Logtalk

?- write('Hello, World!'), nl.

Lua

print "Hello, World!"

Matlab

disp('Hello, World!')

MiniD

module test
  writeln("Hello, World!")

Modelica

model HelloWorld "A differential equation"
  annotation(...);
  Real x(start=1);
equation
  der(x)=-x;
end HelloWorld;

Modula-2

MODULE Hello;

FROM InOut IMPORT WriteLn, WriteString;

BEGIN
  WriteString ("Hello, World!");
  WriteLn
END Hello.

Modula-2 R10

MODULE Hello;

IMPORT PervasiveIO;

BEGIN
  WRITE("Hello, World!\n");
END Hello.

MuPad

t := plot::Text2d("Hello, World", [1, 1], TextFont = [24]):
plot(t)

Nemerle

Nimrod

Objective-C

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
  NSLog(@"Hello, World!\n");
  return 0;
}

Objective-J

document.write("Hello, World!");

Octave

printf("Hello, World!\n");

OCaml

print_string "Hello, World!\n"

Perl

print "Hello, World!\n";

PHP

print("Hello, World!");

PovRay

#include "colors.inc"

camera {
  location <3, 1, -10>
  look_at <3,0,0>
}

light_source { <500,500,-1000> White }

text {
  ttf "timrom.ttf" "Hello, World!" 1, 0
  pigment { White }
}

PostScript

(Hello, World!\n) print quit

PowerShell

Prolog

write('Hello, World!').

Python

print "Hello, World!"

R and S and S-Plus

cat("Hello, World!\n")

Rebol

print "Hello, World!"

Redcode

write   sts.a  hello,     0
        sts.b  }write,    0
        djn    write,     #7
 
hello   dat    72,        101 ; He
        dat    108,       108 ; ll
        dat    111,       44  ; o,
        dat    32,        87  ;  W
        dat    111,       114 ; or
        dat    108,       100 ; ld
        dat    33,        10  ; !\n

Reia

"Hello, World!".puts()

Ruby and JRuby

puts "Hello, World!"

Scala

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello, World!")
  }
}

Scheme

(display "Hello, World!")

Scilab

Smalltalk

Transcript show: 'Hello, World!'.

SNOBOL

Tcl

puts "Hello, World!"

Vala

void main ()
{
  print ("Hello, World!\n");
}

Verilog

VHDL

Visual Basic.NET

Module HelloWorldApp
  Sub Main()
     System.Console.WriteLine("Hello, World!")
  End Sub
End Module

XQuery

let $i := "Hello, World!"
return $i