From Compsci.ca Wiki
Hello, world!
Turing
% This is a comment
put "Hello, world!"
C
/* This a comment */
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
C++
// This is a comment
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
Java
// This is a comment
import java.lang.*;
import java.io.*;
public static void HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
C#
// This is a comment
using System;
public class HelloWorld
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, world!");
}
}
D
// This is a comment
import std.stream;
void main()
{
stdout.writeLine("Hello, world!");
}
Perl
# This a comment
print "Hello, world!\n";
Python
# This a comment
print "Hello, world!"
Ruby
# This a comment
puts "Hello, world!"
O'Caml
(* This a comment *)
print_endline "Hello, world!"
Eiffel
-- This is a comment
class HELLO_WORLD
creation {ANY} make
feature {ANY}
make is
do
std_output.put_string("Hello, world!")
std_output.put_new_line
end
end
Pascal
(* This a comment *)
program HelloWorld;
begin
WriteLn('Hello, world!')
end.
Ada95
-- This is a comment
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello_World is
begin
Put_Line("Hello, world!");
end Hello_World;
Javascript
// This is a comment
document.write("Hello, world!<br/>");