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

main(){
   printf("Hello World");
   return 0;
}
view (6 lines, 1 line of output)


C++:
pasted 3 hours ago:
1
2
3
4
5
6
7
8
9
#include <iostream>

using namespace std;

int main()
{
cout << "Hello World";
return 0;
}
view (9 lines, 1 line of output)
pasted 3 hours ago:
1
2
3
4
5
6
7
8
9
#include <iostream>

using namespace std;

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


D:
pasted yesterday:
1
2
3
4
5
int main()
{
printf("hello world!\n");
return 0;
}
view (5 lines, 1 line of output)
pasted on Aug 30:
1
2
3
4
5
6
int main()
  {
    printf("Hello, World\n");

    return 0;
}
view (6 lines, 1 line of output)


Haskell:
pasted on Aug 27:
1
2
3
4
-- hello.hs: Hello World Example
main :: IO ()
main = do
       putStrLn "Hello, World!"
view (4 lines, 1 line of output)
pasted on Aug 26:
1
main = putStrLn "Hello World"
view (1 line, 1 line of output)


Lua:
pasted on Aug 30:
#!/usr/bin/lua

People = {}
function People:new (obj)
	obj = obj or {}
	setmetatable (obj, self)
	self.__index = self
	return obj
end

function People:get (attr)
	return self.attr
end

function People:set (attr, value)
	self.attr = value
end


gecko = People:new()
gecko:set (say, "Hello World");
print (gecko:get("say"));
view (22 lines, 1 line of output)
pasted on Aug 28:
1
2
3
local formats = string.format
local draw = formats("%s", "Hello world!")
print(draw)
view (3 lines, 1 line of output)


OCaml:
pasted yesterday:
1
print_endline "Hello world!"
view (1 line, 1 line of output)
pasted on Aug 30:
1
2
let printHello = print_string "Hello World";;
printHello;;
view (2 lines, 1 line of output)


PHP:
pasted 5 hours ago:
1
2
3
4
<?php
$txt="Hello World";
echo $txt;
?>
view (4 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
<?php 

echo "Hello World";

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


Perl:
pasted 5 hours ago:
1
2
#!/usr/bin/perl
print "Hello World!";
view (2 lines, 1 line of output)
pasted yesterday:
1
print "Hello, World!"
view (1 line, 1 line of output)


Python:
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)


Ruby:
pasted on Aug 31:
1
print('hello world')
view (1 line, 1 line of output)
pasted on Aug 29:
1
print "Hello world!"
view (2 lines, 1 line of output)


Scheme:
pasted on Aug 29:
1
2
3
(begin
  (display "Hello, World!")
  (newline))
view (3 lines, 1 line of output)
pasted on Aug 24:
1
(display "Hello, World!")
view (1 line, 1 line of output)


Tcl:
pasted on Jun 15:
1
puts -nonewline "Hello world!"
view (1 line, 1 line of output)
sllide - pasted on Jun 3:
1
puts -nonewline "Hello world!"
view (1 line, 1 line of output)