Hello world programs in various languages
1. Ada
===================================
With Ada.text_io;
Procedure Hello is
Begin
Ada.text_io. Put_Line ("Hello world!");
End Hello;
2. ALGOL68
===================================
/' begin/'
Print ("Hello world!")
/' end/'
3. Amigae
===================================
PROC Main ()
Writef (/' Hello world!/')
Endproc
4. awk
===================================
BEGIN {print "Hello, world!"}
5. Bcpl
===================================
GET "Libhdr"
Let START () is
$(
Writes ("Hello, World!*n")
$)
6. Boo
===================================
Import System
Console.WriteLine ("Hello world!")
7. Brainfuck
===================================
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++. +++.>++.<<
+++++++++++++++.>.+++.------.--------. >+.>.
8. C
===================================
#include <stdio.h>
int main ()
{
printf ("Hello world!/n");
return 0;
}
9. C + +
===================================
#include <iostream.h>
int main ()
{
cout<< "Hello world!" <<endl;
return 0;
}
Ten. Clean
===================================
module Hello
Start:: String
Start = "Hello, World"
One. COBOL
===================================
Identification Division.
Program-id. Hello-world.
Environment Division.
DATA Division.
PROCEDURE Division.
DISPLAY "Hello world!".
STOP RUN.
Common Lisp
===================================
(Format T "Hello world!")
D
===================================
Import Std.c.stdio;
int main (char[][] args)
{
printf ("Hello world!/n");
return 0;
}
Eiffel.
===================================
Class Hello_world
Creation
Make
Feature
Make is
Local
Ibasic_io
Do
!! Io
Io.put_string ("%N Hello world!")
End--Make
End--Class Hello_world
. Erlang
===================================
-module (hello).
-export ([hello_world/0]).
Hello_world (), Ifwrite ("Hello world!/n").
Forth.
===================================
." Hello world! " CR
-Fortran
===================================
Program Hello
Write (*,*)/' Hello world!/'
End
Haskell
===================================
Module HelloWorld (main) where
Main = putstr "Hello world!/n"
. Icon
===================================
Procedure Main ()
Write ("Hello world!/n")
End
Intercal.
===================================
Please do, 1 <-#13
Do, 1 SUB #1 <-#238
Do, 1 SUB #2 <-#112
Do, 1 SUB #3 <-#112
Do, 1 SUB #4 <-#0
Do, 1 SUB #5 <-#64
Do, 1 SUB #6 <-#238
Do, 1 SUB #7 <-#26
Do, 1 SUB #8 <-#248
Do, 1 SUB #9 <-#168
Do, 1 SUB #10 <-#24
Do, 1 SUB #11 <-#16
Do, 1 SUB #12 <-#158
Do, 1 SUB #13 <-#52
Please READ out, 1
GIVE up
Iptscrae.
===================================
On ENTER {
"Hello," "world!" & SAY
}
. Java
===================================
Command line interface:
Class Hello
{
public static void Main (String ars[])
{
System.out.print ("Hello world!/n");
}
}
Graphical interface:
Import java.awt.*;
Import java.awt.event.*;
Class HelloWorld extends Frame
{
public static void Main (String args[])
{
HelloWorld hello=new HelloWorld ();
Label Lbl=new label ("Hello world!");
Hello.settitle ("Hello World");
Hello.setsize (300,200);
Hello.setbackground (New Color (224,224,224));
Hello.add (LBL);
Lbl.setalignment (1);
Lbl.setfont (New Font ("Arial", font.plain,24));
Hello.setlocation (260,180);
Hello.show ();
Hello.addwindowlistener (New Windowadapter ()
{
public void windowclosing (WindowEvent wet)
{
System.exit (0);
}
});
}
}
. Lua
===================================
Print "Hello world!/n"
Mixal.
Term EQU The MIX console device number
ORIG-Start Address
START out msg [term] output data at address msg
HLT Halt execution
MSG ALF "Mixal"
ALF "HELL"
ALF "O WOR"
ALF "LD"
End START end of the program
. MSIL
===================================
. Assembly Hello
{
. ver 1:0:0:0
}
. method public static void main () Il managed
{
. entrypoint
. maxstack 1
ldstr "Hello world!/n"
call void [Mscorlib]system.console::write (class System.String)
Ret
}
OCaml.
===================================
Print_endline "Hello world!";;
OPL.
===================================
PROC Hell
PRINT "Hello, World"
Endp
. oz
===================================
Functor $
Import
Application
System
Define
{system.print/' Hello world!/'}
{Application.exit 0}
End
Pascal
===================================
Program Hello;
Begin
Writeln (/' Hello, world!/');
End.
Perl
Print "Hello world/n"
Pike.
===================================
Command line interface
int main ()
{
Write ("Hello, world!/n");
return 0;
}
Graphical interface
int main ()
{
GTK.SETUP_GTK ();
Gtk. Alert ("Hello world!")
->signal_connect ("Destroy", Lambda () {exit (0);});
return-1;
}
pl/i.
===================================
Test:procedure options (main);
Declare my_string char (() varying initialize (/' Hello, world!/');
Put skip list (my_string);
End Test;
PostScript
===================================
/font/courier Findfont Scalefont
Font SetFont
MoveTo
(Hello world!) Show
ShowPage
PowerBASIC.
===================================
#COMPILE EXE
FUNCTION Pbmain () as LONG
MSGBOX "Hello world!"
END FUNCTION
Prolog.
===================================
Predicates
Hello
Clauses
hell-
Write ("Hello world!/n"). % or write ("Hello world!"), NL.
Goal Hello.
Python
===================================
Print "Hello world!"
. Rexx
===================================
Say "Hello, world!"
Notoginseng. Ruby
===================================
Print "Hello world!/n"
Sather.
===================================
Class Hello_world is
Main is
#OUT + "Hello world/n";
End
End
Scheme
===================================
(Display "Hello, world!/n")
-SED
===================================
Sed-ne/' 1s/.*/hello, world!/p/'
A. Self
===================================
/' Hello, world!/' uppercase print.
Smalltalk.
===================================
Transcript Show:/' Hello, world!/'
SML
===================================
Print "Hello, world!/n";
Snobol.
===================================
OUTPUT = "Hello, world!"
END
A. TCL
===================================
Puts "Hello world!"
In. TeX
===================================
/font/hw=cmr10 Scaled 3000
/LEFTLINE{/HW Hello World}
/bye
Turing.
===================================
Put "Hello, world!"
VB
===================================
Sub Main
MsgBox "Hello world!"
End Sub
. VC + +
===================================
#include <windows.h>
LRESULT CALLBACK WndProc (Hwnd,uint,wparam,lparam);
int WINAPI WinMain (hinstance hinstance,hinstance hprevinstance,lpstr lpcmdline,int ncmdshow)
{
HWND hwnd;
MSG msg;
Wndclass Wndclass;
Char lpszclassname[]= "window";
Char lpsztitle[]= "Hello World";
wndclass.style=0;
Wndclass.lpfnwndproc=wndproc;
wndclass.cbclsextra=0;
wndclass.cbwndextra=0;
Wndclass.hinstance=hinstance;
Wndclass.hicon=loadicon (null,idi_application);
Wndclass.hcursor=loadcursor (Null,idc_arrow);
Wndclass.hbrbackground= (Hbrush) getstockobject (White_brush);
Wndclass.lpszmenuname=null;
Wndclass.lpszclassname=lpszclassname;
if (! RegisterClass (&wndclass))
{
MessageBeep (0);
return FALSE;
}
Hwnd=createwindow (lpszClassName,
Lpsztitle,
Ws_overlappedwindow,
Cw_usedefault,
Cw_usedefault,
Cw_usedefault,
Cw_usedefault,
Null
Null
HINSTANCE,
NULL);
ShowWindow (hwnd,ncmdshow);
UpdateWindow (HWND);
while (GetMessage (&msg,null,0,0))
{
TranslateMessage (&MSG);
DispatchMessage (&MSG);
}
return msg.wparam;
}
LRESULT CALLBACK WndProc (HWND hwnd,uint message,wparam wparam,lparam LPARAM)
{
Paintstruct PS;
HDC hdc;
Char hello[]= "Hello world!";
TCH (Message)
{
Case WM_PAINT:
HDC = BeginPaint (hwnd, &PS);
TextOut (hdc, 0, 0, Hello,lstrlen (Hello));
EndPaint (hwnd, &PS);
Break
Case Wm_destroy:
PostQuitMessage (0);
Break
Default
return DefWindowProc (Hwnd,message,wparam,lparam);
}
return 0;
}
WIN32 compilation
===================================
; Graphical interface Hello World
.386
. Model Flat, StdCall
Option Casemap:none
Include/masm32/include/windows.inc
Include/masm32/include/user32.inc
Include/masm32/include/kernel32.inc
Includelib/masm32/lib/user32.lib
Includelib/masm32/lib/kernel32.lib
. Code
Start
JMP @F
Szdlgtitle db "Hello World (Assembly Edition)", 0
Szmsg db "Hello world!", 0
@@:
Push MB_OK
Push offset Szdlgtitle
Push offset szmsg
Push 0
Call MessageBox
Push 0
Call ExitProcess
End Start
51. Compilation
===================================
. MODEL Small
. STACK 100h
. DATA
Hello DB/' Hello world!/', 13,10,/' $/'
. CODE
mov ax, @data
MOV Ds,ax
MOV ah,9
MOV Dx,offset Hello
int 21h
MOV ah,4ch
int 21h
END
ASP.
===================================
Response.Write "Hello world!"
. C #
===================================
Using System;
Class Hello
{
public static void Main ()
{
Console.WriteLine ("Hello world!");
}
}
FOXBASE.
===================================
? "Hello world!"
@0,0 say "Hello world!"
. Groovy
===================================
Print "Hello world!/n"
. PHP
===================================
echo "Hello world!"
57.VB. MET:
===================================
Imports System
Module Hello
Sub Main ()
Console.WriteLine ("Hello world!")
End Sub
End Module
58.JScript:
===================================
Import System;
Console.Write ("Hello world!/n");
Or
Print ("Hello world!");
59. Easy language:
===================================
Standard output (, "Hello world!")
Or
Information box ("Hello world! ", 0,)
60.Delphi:
===================================
Program HelloWorld;
Uses
Dialogs;
Begin
ShowMessage (/' Hello, world!/');
End.
61.DOS Batch:
===================================
@echo Hello world!
62.UNIX Shell
===================================
echo/' Hello world!/'
A Java version of the Hello World program without the Main method:
===================================
Class Hello
{
Static
{
System.out.println ("Hello world!");
System.exit (0);
}
}
63.Xaml:
===================================
<canvas
Xmlns= "Http://schemas.microsoft.com/2003/xaml"
Background= "Lightcyan"
Width= "100%" height= "100%" >
<text canvas.left= "canvas.top=" "fontsize=" >hello world!</text>
</Canvas>
64.SQL:
===================================
Print/' Hello world!/'
65.SML:
===================================
Print "Hello world!/n";;
66.Heron:
===================================
Program HelloWorld;
Functions
{
_main ()
{
Print_string ("Hello, world!");
}
}
End
67.Scala:
===================================
Object HelloWorld with Application
{
Console.println ("Hello, world!");
}
68.SPARK:
===================================
With Spark_io;
--# inherit Spark_io;
--# Main_program;
Procedure Hello_world
--# Global in Out spark_io. Outputs;
--# derives spark_io. Outputs from Spark_io. Outputs;
Is
Begin
Spark_io. Put_Line (Spark_io. Standard_output, "Hello world!", 0);
End Hello_world;
69.PureBASIC:
===================================
Openconsole ()
PRINTN ("Hello world!")
Closeconsole ()
Or
Messagerequester ("Purebasic-hello", "Hello world!", 0)
70.MediaBASIC:
===================================
Sub Main ()
Console
Writeconsole ("Hello world!")
End Sub
Or
Sub Main ()
ShowMessage "Hello world!"
End Sub
71.xpb! BASIC:
===================================
Console
Program
Print "Hello world!"
72.Liberty BASIC:
===================================
Print "Hello world!"
73.ScriptBASIC:
===================================
Print "Hello world!" & Chr & Chr (10)
74.blassic:
===================================
Print "Hello world!"
75.KBASIC:
===================================
Print "Hello world!"
76.Chipmunk BASIC:
===================================
Print "Hello world!"
77.BBC BASIC:
===================================
PRINT "Hello world!"
78.modula-2
===================================
MODULE Hello;
From Terminal2 IMPORT Writeln; WriteString;
BEGIN
WriteString ("Hello, world!");
Writeln;
END Hello;
79.Oberon
===================================
MODULE Hello;
IMPORT Oberon, texts;
VAR W:texts.writer;
PROCEDURE world*;
BEGIN
Texts.writestring (W, "Hello world!");
Texts.writeln (W);
Texts.append (Oberon.Log, W.buf)
END World;
BEGIN
Texts.openwriter (W)
END Hello.
80.vc++. NET
===================================
#include <stdafx.h>
#using <mscorlib.dll>
using namespace System;
int main ()
{
Console::write ("Hello world!/n");
return 0;
}
81.vj#. NET
===================================
Package Jhello;
public class Hello
{
public static void Main (string[] args)
{
System.out.print ("Hello world!/n");
}
}
82.XHTML 1.1
===================================
(Using UTF-8 character set.)
<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd XHTML 1.1//en" "Http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
<title>hello, world!</title>
<body>
<p>hello, world!</p>
</body>
83.XUL
===================================
<window xmlns= "Http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <box align= "Center" > <label value= "Hello, world!"/> </box> </window>
LaTeX
/documentclass
/begin
Hello, world!.
/end
Ruby with WxWidgets
See also TUI section.
Require/' wxruby/'
Class Helloworldapp < Wx::app
def On_init
Ourframe = Wx::frame.new (Nil,-1, "Hello, world!"). Show
Ourdialogbox = Wx::messagedialog.new (Ourframe, "Hello, world!", "Information:", wx::ok| wx::icon_information). Show_modal
End
End
HelloWorldApp.new.main_loop
84.SWT
===================================
Import Org.eclipse.swt.SWT;
Import Org.eclipse.swt.layout.RowLayout;
Import Org.eclipse.swt.widgets.Display;
Import Org.eclipse.swt.widgets.Shell;
Import Org.eclipse.swt.widgets.Label;
public class Swthello {
public static void Main (String [] args) {
Display display = new display ();
Final Shell shell = new shell (display);
Rowlayout layout = new Rowlayout ();
Layout.justify = true;
Layout.pack = true;
Shell.setlayout (layout);
Shell.settext ("Hello, world!");
Label label = new label (Shell, SWT. CENTER);
Label.settext ("Hello, world!");
Shell.pack ();
Shell.open ();
while (!shell.isdisposed ()) {
if (!display.readanddispatch ()) display.sleep ();
}
Display.dispose ();
}
}
85.RTML
===================================
Hello ()
TEXT "Hello, world!"
QT Toolkit (in C + +)
#include <qapplication.h>
#include <qpushbutton.h>
#include <qwidget.h>
#include <iostream>
Class Helloworld:public Qwidget
{
Q_object
Public
HelloWorld ();
Virtual ~helloworld ();
Public Slots:
void handlebuttonclicked ();
Qpushbutton *mpushbutton;
};
Helloworld::helloworld ():
Qwidget (),
Mpushbutton (New Qpushbutton ("Hello, world!", this))
{
Connect (Mpushbutton, SIGNAL (clicked ()), this, SLOT (handlebuttonclicked ()));
}
Helloworld::~helloworld () {}
void Helloworld::handlebuttonclicked ()
{
Std::cout << "Hello, world!" << Std::endl;
}
int main (int argc, char *argv[])
{
Qapplication app (argc, argv);
HelloWorld HelloWorld;
App.setmainwidget (&helloworld);
Helloworld.show ();
return App.exec ();
}
Hello World in all languages