[ 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 37 minutes ago:
1
2
3
4
5
6
#include<stdio.h>
int main()
{
printf("Hello World");
return 0;
}
view (6 lines, 1 line of output)
pasted 2 hours ago:
1
2
3
4
5
#include<stdio.h>
void main()
{
printf("hello world");
}
view (5 lines, 1 line of output)


C++:
pasted 36 seconds ago:
1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;

int main()
{
cout << "Hello World" <<endl;
return 0;
//yay it worked
}
view (9 lines, 1 line of output)
pasted 1 minute ago:
1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

int main()
{
cout << "Hello World" <<endl;
return 0;
}
view (8 lines, 1 line of output)


D:
pasted on Sep 5:
1
2
3
4
5
void main()
{
  printf("Hello world\n");
  
}
view (7 lines, 1 line of output)
pasted on Sep 3:
1
2
3
4
5
 
void main()
{
    writefln("Hello, World!");
}
view (5 lines, 1 line of output)


Haskell:
pasted on Sep 11:
import Data.Map as Map
import Data.Map ((!))

data Cache a b = Cache (a -> b) (Map a b)

insert :: (a -> b) -> Cache a b
insert fun =
	Cache fun Map.empty

apply :: Ord a => (Cache a b) -> a -> b
apply (Cache fun m) x =
	if Map.member x m
		then m ! x
	else
		fun x

applyMutate :: Ord a => (Cache a b) -> a -> (Cache a b, b)
applyMutate cache@(Cache fun m) x =
	(Cache fun (Map.insert x out m), out) where
		out = apply cache x

mapCache :: Ord a => (Cache a b) -> [a] -> [b]
mapCache _ [] = []
mapCache cache (x:xs) = out : (mapCache cache1 xs) where
	(cache1, out) = applyMutate cache x


main = putStrLn "Hello World"
view (28 lines, 1 line of output)
pasted on Sep 11:
1
main = putStrLn "Hello, world!"
view (1 line, 1 line of output)


Lua:
pasted on Sep 9:
1
print("Hello World");
view (1 line, 1 line of output)
pasted on Sep 9:
1
print("Hello World!")
view (1 line, 1 line of output)


OCaml:
pasted on Aug 8:
1
2
let x = "hello world";;
Printf.printf "%s" x;;
view (2 lines, 1 line of output)
pasted on Aug 8:
1
2
let x = "hello world";;
Printf.printf "%s" x;;
view (2 lines, 1 line of output)


PHP:
pasted yesterday:
1
<?php echo 'Hello, world'; ?>
view (1 line, 1 line of output)
pasted yesterday:
1
2
3
4
5
<?php

    echo "Hello World";

?>
view (5 lines, 1 line of output)


Perl:
pasted 36 minutes ago:
1
2
3
4
#!/usr/bin/perl
#badnums.plx
use warnings;
print "Hello World \n";
view (4 lines, 1 line of output)
pasted 36 minutes ago:
1
2
3
4
#!/usr/bin/perl
#badnums.plx
use warnings;
print "Hello World \n";
view (4 lines, 1 line of output)


Python:
pasted 38 minutes ago:
1
print "Hello world!"
view (1 line, 1 line of output)
pasted 2 hours ago:
1
2
str = "hello world"
print str
view (2 lines, 1 line of output)


Ruby:
pasted 1 hour ago:
1
2
#! /usr/bin/ruby
puts "hello world" 
view (2 lines, 1 line of output)
pasted yesterday:
1
puts "hello world!"
view (1 line, 1 line of output)


Scheme:
pasted on Sep 15:
1
(display "hello world!")
view (1 line, 1 line of output)
pasted on Sep 11:
1
(display "Hello, World!")
view (1 line, 1 line of output)


Tcl:
pasted on Jul 31:
1
puts -nonewline "Hello world!"
view (1 line, 1 line of output)
pasted on Jul 16:
1
puts -nonewline "Hello world!"
view (1 line, 1 line of output)