[ create a new paste ] login | about

Listed below are example programs that print "hello world", written in the following languages:
[ C | C++ | D | Haskell | Lua | OCaml | PHP | Perl | Python | Ruby | Scheme | Tcl ]

C:
pasted 14 minutes ago:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
 
int main()
{
  char string[] = "Hello World";
 
  printf("%s\n", string);
 
  return 0;
}
view (10 lines, 1 line of output)
pasted 24 minutes ago:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
 
int main()
{
  char string[] = "Hello World";
 
  printf("%s\n", string);
 
  return 0;
}
view (10 lines, 1 line of output)


C++:
pasted 10 minutes ago:
1
2
3
4
5
6
7
#include <iostream>
 
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
view (7 lines, 1 line of output)
pasted 13 minutes ago:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
 
int main()
{
  char string[] = "Hello World";
 
  printf("%s\n", string);
 
  return 0;
}
view (10 lines, 1 line of output)


D:
pasted 2 minutes ago:
1
2
3
4
5
import std.stdio;

void main() {
    printf("Hello World!");
}
view (5 lines, 1 line of output)
pasted on Apr 16:
1
2
3
4
5
int main()
{
printf ("Hello world");
return 0;
}
view (5 lines, 1 line of output)


Haskell:
pasted on Apr 21:
1
main = putStrLn "Hello, World!"
view (1 line, 1 line of output)
pasted on Apr 12:
module Main where

-- we are going to calculate pagerank today

type Vertex = Integer
type Edge = (Vertex, Vertex)

type AssocList = [Edge]

data DigraphVertex = DigraphVertex { source :: Vertex , dest :: [Vertex] }

type Digraph = [DigraphVertex]

{-
insert :: AssocList -> Digraph -> (AssocList, Digraph)
-- nothing left to insert
insert [] ds = ([], ds)
-- reached the end of ds, unique item
-- make a new entry for x
insert (x:xs) [] = insert xs
-}


enDigraph :: AssocList -> Digraph
enDigraph [] = []
enDigraph x = map (\(a,b) -> DigraphVertex {source = a, dest = [b]} ) x




data PageRankGraph = PageRankGraph { reversed :: DigraphVertex }



main = putStrLn "Hello, World!"
view (35 lines, 1 line of output)


Lua:
pasted 4 hours ago:
1
print("Hello world")
view (1 line, 1 line of output)
pasted yesterday:
1
2
3
#!/usr/local/bin/lua

print("Hello World!")
view (3 lines, 1 line of output)


OCaml:
pasted on Mar 7:
1
print_string "Hello World!\n";;
view (1 line, 1 line of output)
pasted on Feb 20:
1
 print_endline "Hello, world!"
view (1 line, 1 line of output)


PHP:
pasted 4 hours ago:
1
2
3
<?php
  print "Hello, World!";
?>
view (3 lines, 1 line of output)
pasted yesterday:
1
<?php echo 'Hello, world'; ?>
view (1 line, 1 line of output)


Perl:
pasted yesterday:
1
print("Hello world")
view (1 line, 1 line of output)
pasted yesterday:
1
print("Hello world")
view (1 line, 1 line of output)


Python:
pasted 23 minutes ago:
1
2
3
4
5
def myFirstFunction(myInput):
  print myInput


myFirstFunction('Hello World')
view (5 lines, 1 line of output)
pasted 29 minutes ago:
1
print 'Hello World'
view (1 line, 1 line of output)


Ruby:
pasted yesterday:
1
puts "Hello World"
view (1 line, 1 line of output)
pasted yesterday:
1
puts "Hello World"
view (1 line, 1 line of output)


Scheme:
pasted on Apr 9:
1
(display "Hello World!")
view (1 line, 1 line of output)
pasted on Apr 4:
1
2
3
4
5
6
7
(define hello-world
  (lambda ()
    (display "Hello, World!")
    (newline)
    ))

(hello-world)
view (8 lines, 1 line of output)


Tcl:
pasted on Apr 12:
1
2
3
4
puts -nonewline "Hello world!"
set a 10
expr $a + 1
set y [expr $a + 1]
view (4 lines, 1 line of output)
pasted on Mar 28:
1
2
3
4
puts -nonewline "Hello world!"
set a 10
expr $a + 1
set y [expr $a + 1]
view (4 lines, 1 line of output)