Computer Programming/Hello world
发布时间:2026-08-11 | 浏览:1
You can help by splitting this big page into smaller ones. Please make sure to follow the naming policy . Dividing books into smaller sections can provide more focus and allow each one to do one thing well, which benefits everyone.
The following is a list of Hello, world! programs.
Hello, world! programs make the text "Hello, world!" appear on a computer screen. It is usually the first program encountered when learning a programming language. Otherwise, it's a basic sanity check for an installation of a new programming language. If "Hello World" does not run, one must not try to develop complex programs before fixing the issues with the installation.
For even more languages have a look at the Hello World Collection .
It should be noted that the 4DOS/4NT batch language is a superset of the MS-DOS batch language.
ABAP/4 - SAP AG
ABAP Objects (NetWeaver 7)
The example below makes use of the singleton pattern and outputs the text in a message box instead of a classic list output.
ActionScript 1.0 and 2.0
This will output to the output window only, which an end user would not see.
This version will be visible to the end user.
The ALGOL 68 standard requires that reserved-words , types and operators are in a different typeface. Hence programs are typically published in either bold or an underline typeface, e.g.:
In the popular upper-case stropping convention for bold words:
or using a wikitext like quote stropping, this is especially suitable on computers with only 6 bits per character (hence only have UPPERCASE):
or minimally using the "brief symbol" form of begin and end .
This program sends the message out via the Diagnostics Interface after start-up.
The Del on the first line begins function definition for the program named HWΔPGM. It is a niladic function (no parameters, as opposed to monadic or dyadic) and it will return an explicit result which allows other functions or APL primitives to use the returned value as input.
The line labeled 1 assigns the text vector 'Hello, world!!' to the variable R
The last line is another Del which ends the function definition.
When the function is executed by typing its name the APL interpreter assigns the text vector to the variable R, but since we have not used this value in another function, primitive, or assignment statement the interpreter returns it to the terminal, thus displaying the words on the next line below the function invocation.
The session would look like this
While not a program, if you simply supplied the text vector to the interpreter but did not assign it to a variable it would return it to the terminal as output. Note that user input is automatically indented 6 spaces by the interpreter while results are displayed at the beginning of a new line.
Assembly language
Accumulator-only architecture: DEC PDP-8, PAL-III assembler
See the example program in the Wikipedia PDP-8 article .
First successful uP/OS combinations: Intel 8080/Zilog Z80, CP/M, RMAC assembler
Popular home computer: ZX Spectrum, Zilog Z80, HiSoft GENS assembler
Accumulator + index register machine: MOS Technology 6502, CBM KERNEL, MOS assembler syntax
Accumulator/Index microcoded machine: Data General Nova, RDOS
See the example section of the Nova article.
Expanded accumulator machine: Intel x86, DOS, TASM
ASSEMBLER x86 (DOS, MASM)
ASSEMBLER x86 (DOS, FASM)
Expanded accumulator machine: Intel x86, Microsoft Windows, FASM
Example of making 32-bit PE program as raw code and data:
Using FASM import macro, unicode (MessageBoxW is one of few unicode functions 'supported' by Windows 9x/ME) and section sharing, no relocation (not required for 32-bit Windows NT executables, recommended for DOS-based Windows, required for x64), no heap - Not a beginners example but only 1024 instead of 3072 bytes:
Expanded accumulator machine: Intel x86, Linux, FASM
Expanded accumulator machine: Intel x86, Linux, GAS
Expanded accumulator machine: Intel x86, Linux, NASM
Expanded accumulator machine: Intel x86, Linux, GLibC, NASM
General-purpose fictional computer: MIX, MIXAL
General-purpose fictional computer: MMIX, MMIXAL
General-purpose-register CISC: DEC PDP-11
RT-11, MACRO-11
Variant for Elektronika BK using BIOS function, MICRO-11
CISC Amiga (Workbench 2.0): Motorola 68000
CISC Atari: Motorola 68000
CISC Sharp X68000 (Human68K): Motorola 68000
CISC on advanced multiprocessing OS: DEC VAX, VMS, MACRO-32
Mainframe: IBM z/Architecture series using BAL
RISC processor: ARM, RISC OS, BBC BASIC's in-line assembler
or the even smaller version (from qUE);
RISC processor: MIPS architecture
RISC processor: PowerPC, Mac OS X, GAS
Sigma 6/7/8/9 METASYMBOL
(The comma after the command name is optional.)
Avenue (scripting language for ArcView GIS)
This is the first known Hello, world! program ever written: [1]
Also known as Triton Tools on older versions. On Baan ERP you can create a program on 3GL or 4GL mode.
On this last case you should press the Continue button to show the message.
or using the C preprocessor
The following example works for any ANSI/ISO-compliant BASIC implementation, as well as most implementations built into or distributed with microcomputers in the 1970s and 1980s (usually some variant of Microsoft BASIC):
Note that the "END" statement is optional in many implementations of BASIC.
Some implementations could also execute instructions in an immediate mode when line numbers are omitted. The following examples work without requiring a RUN instruction.
Later implementations of BASIC allowed greater support for structured programming and did not require line numbers for source code. The following example works when RUN for the vast majority of modern BASICs.
Again, the "END" statement is optional in many BASICs.
Note: In the "classic" Dark Basic the WAIT KEY command is optional as the console goes up when the program has finished.
To write to the main window:
Or drawn in a graphics window:
Microsoft Small Basic
or, the typical microcontroller Hello, world! program equivalent with the only output device present being a light-emitting diode (LED) (in this case attached to the seventh output pin):
StarOffice/OpenOffice Basic
Same for QBasic
On TI calculators of the TI-80 through TI-86 range:
Note: "!" character is not on the keypad. It can be accessed from "Catalog" menu, "Probability" menu, or "Math" menu (as factorial notation).
On TI-89/TI-89 Titanium/TI-92(+)/Voyage 200 calculators:
Alternatively, copy this into a New Form:
Visual Basic .NET
PICK/BASIC, DATA/BASIC, MV/BASIC
In addition to the ANSI syntax at the head of this article, most Pick operating system flavors of Dartmouth BASIC support extended syntax allowing cursor placement and other terminfo type functions for VDT's
X, Y positioning (colon ":" is the concatenation instruction):
Will display the string "Hello, world!" roughly centered in a 80X24 CRT.
Other functions:
Will clear the screen before displaying the string "Hello, world!" roughly centered in a 80X24 CRT.
Syntax variants:
Supporting the "@" functions above, the CRT statement ignores previous PRINTER statements and always sends output to the screen.
Some Pick operating system environments such as OpenQM support the DISPLAY variant of PRINT. This variant in addition to the "@" functions maintains pagination based upon the settings of the TERM variable:
or, with the newline
BITGGAL AgileDog
BITGGAL Jihwaja
See also GUI section .
Caché Server Pages (CSP)
This program will work on the Avasmath 80 online programmable calculator.
C/AL - MBS Navision
This program will work on the fx-9750 graphing calculator and compatibles.
The above C code can run in Ch as examples. The simple one in Ch is:
CintieFramework (VisualBasic.NET)
The above is a very abbreviated and condensed version, which omits the author name and source and destination computer types.
CoffeeScript is a language that compiles into JavaScript. Like JavaScript, it does not have native (built in) input or output routines, instead relying on the facilities provided by its host environment.
Using an alert that uses a standard Web browser's window object (window.alert)
or, from Firebug , Apple Safari , or Google Chrome debug console, or Node.js console
ColdFusion (CFML)
Concurrent Euclid
The '|' represents the separation of the two text fields in the Cube standard IDE.
C++, Managed (.NET)
See also GUI section .
In C# 10.0, the following would suffice:
In C# 2.0, the code is much larger:
DC, an arbitrary precision calculator
In the second example, DC stores the decimal number as a sequence of bits, and then the "P" tells DC to interpret those bits as a string and print it.
This would be a pure system call
Ed and Ex (Ed extended)
Ecstasy (xtclang)
See also GUI section .
or instead of compiling a new routine, one can type directly in the Forth interpreter console
See also GUI section .
GML (Game Maker Language)
In the draw event of some object:
Or to show a splash screen message:
Go (from Google)
(Handheld Hewlett-Packard RPN-based scientific calculator.)
(Handheld Hewlett-Packard RPN-based alphanumeric engineering calculators.)
HyperTalk (Apple HyperCard's scripting programming language)
See also GUI section .
(disassembler output of javap -c HelloWorld )
Java byte-code Jasmin Syntax
JavaFX Script was a scripting language formerly called F3 for Form Follows Function. It was discontinued by Oracle in 2010.
This program can also be written in this way:
A simple console output version would be:
Or even simpler (with a built-in function):
JavaScript does not have native (built in) input or output routines. Instead it relies on the facilities provided by its host environment.
Using a standard Web browser's document object
or with an alert, using a standard Web browser's window object (window.alert)
or, from the Mozilla command line implementation
or, from the Windows Script Host
or, from Firebug , Apple Safari , or Google Chrome debug console
JCL (mainframe Job Control Language)
KPL (Kids Programming Language)
Lexico Mobile (in Spanish)
Linden Scripting Language
Linden Scripting Language is the scripting language used within Second Life
Lisp has many dialects that have appeared over its almost fifty-year history.
or in the REPL:
(As a string (enclosed in quotes) it evaluates to itself, so is printed.)
In MSWLogo only
LuaDEV (PSP and Wii)
Macsyma, Maxima
MATLAB / GNU Octave
Maya Embedded Language
This requires that you be the player or a wizard:
This is specific to the implementation of the core used for the moo, but works on most well known moos, such as LambdaCore or JH-Core:
M# Fictional Computer Language
(with the standard command.com interpreter. The @ symbol is optional and prevents the system from repeating the command before executing it. The @ symbol must be omitted on versions of MS-DOS prior to 3.0.). It's very common for batchfiles to start with two lines of "@echo off" and "cls".
For MS-DOS 3.0 or lower
The easiest way to get Nemerle print "Hello, world!" would be that:
however, in bigger applications the following code would be probably more useful:
NXT 2.1 (the Lego Robot program)
Oberon is both the name of a programming language and an operating system.
Program written for the Oberon operating system:
Freestanding Oberon program using the standard Oakwood library:
Message to the user in the form:
Entry into the log:
Procedural C Version
Object-Oriented C Version
OPENSTEP/Cocoa Version
or without using course.lib
See also GUI section .
Parrot assembly language
Parrot intermediate representation
(the semicolon is optional)
PHP is a templating language and will echo any text not within PHP tags directly, so the simplest form is:
Using actual PHP statements, it can be written:
or use short-hand echoing, syntaxed as such:
this will also work:
See also page description language section .
As a script/module
Python 2 and earlier
This also works on Python 2.4 or later, but in an unintuitive way. In Python 3, it calls the print function with the string "Hello, world!" . In Python 2, it executes the print statement with the expression ("Hello, world!") , which evaluates to the string "Hello, world!" .
Any Python version
In Python 2.6 or later:
Two easter eggs
'Hello, world!' (with quotation marks) can be attained through:
As Python's Flask web microframework
See also GUI section .
See also GUI section .
(This works the same for Transcript or xTalk)
Printed in the message box
Shown within a dialog box
Printed on the main window interface
REXX, ARexx, NetRexx, and Object REXX
Free-Form Syntax
Traditional Syntax
With this syntax, a constant has to be used because the message must be placed in positions 12 to 25, between apostrophes.
Using the internal message window, a simple Hello, world! program can be rendered thus:
An additional way to render text is by using the built in text() function.
See also GUI section .
(On Hewlett-Packard HP-28, HP-48 and HP-49 series graphing calculators.)
See also GUI section .
App was introduced since Scala 2.1, and Application was deprecated since Scala 2.9.0. Use Application instead of App for versions below 2.1.
(Note: requires at least one line of input)
Spin is the high level language from Parallax Inc. used to program their Propeller multi-core micro-controllers.
The program assumes that the software UART object, provided with the Propeller IDE, is used to deliver the message over a serial line.
or (for EnterpriseDB's Stored Procedure Language (SPL))
or (e.g. Oracle dialect)
or (for Oracle's PL/SQL proprietary procedural language)
or (e.g. MySQL or PostgreSQL dialect)
or (for PostgreSQL's PL/pgSQL Procedural language)
or (e.g. T-SQL dialect)
or (for KB-SQL dialect)
Define program in script (.do-file) or at command line:
Or, interactively at the command line:
or, for interactive prompt,
Tcl (Tool command language)
See also GUI section .
Template Toolkit
Or the English version:
TOM (rewriting language)
or, simpler variations:
UNIX-style shell
or using an inline 'here document'
or for a curses interface:
or (a little more complicated)
Visual Basic Script
OR as a VBscript file
VRML (Virtual Reality Modeling Language)
X3D (Extensible 3D)
XC is a C like language from XMOS Ltd offering features supporting Communicating Sequential Processes on their multi-threaded, multi-core processors. This example shows some of those features.
Note: The semicolon is optional.
Programming language with commands in Polish. Webpage
Graphical user interfaces (GUIs)
ActionScript (Adobe Flash)
Functional equivalent of C# program below.
In C# 10, using the MessageBox class, with top-level statements enabled (default), the code is only one line:
Alternatively, one could write the dialog box from the scratch:
The simplest way to achieve this is with the built in message function that is similar to the windows messageBox().
A more real world example uses a Clarion structure to declare a window and the Clarion Accept loop to process events from that window.
Cocoa or GNUStep (In Objective C)
One way of invoking this would be to enter hello_world:hello(). in the Erlang shell; another would be to run from a command line:
MS-Windows only - basic.
MS-Windows only - using Win32Lib library
Using WindowsForms, at the F# interactive prompt:
GTK+ 2.x (in Euphoria)
IOC/OCL (in IBM VisualAge for C++)
JavaFX and FXML files
GTK (java-gnome)
This creates a window labeled "Hello, world!" with a button labeled "Hello, world!".
Microsoft Foundation Classes (in C++)
Adobe Flex MXML
This creates a message box saying "Hello, world!".
(On Psion Series 3 and later compatible PDAs.)
Patch as ASCII-art:
Patch as sourcecode:
Kivy multi-platform framework
Qt toolkit (in C++)
Robotic (MegaZeux)
(On Hewlett-Packard HP-48G and HP-49G series calculators.)
Ruby with WxWidgets
Evaluate in a workspace:
Using the Morphic GUI toolkit of Squeak Smalltalk:
Using wxSqueak:
and the same in one line
Visual Basic .NET 2003/2005
Note that the previous example will only work when the code is entered as part of a Form Load Event, such as the one created by default when generating a new project in the Visual Studio programming environment. Equivalently, the following code is roughly equivalent to the traditional Visual Basic 6 code by disabling the Application Framework and setting 'Sub Main' as the entry point for the application:
or using a class;
Visual Prolog (note box)
Windows API (in C)
This uses the Windows API to create a full window containing the text.
In the Open event handler of the default window:
Document formats
The following sequence of characters, expressed in hexadecimal notation (with carriage return and newline characters at end of sequence):
The following sequence of characters, expressed as binary numbers (with cr/nl as above, and the same ordering of bytes):
Page description languages
(Using UTF-8 character set.)
The <html> and <body> tags are not necessary for informal testing. Simply write it as text without tags.
HTML 4.01 Strict (full)
The first paragraph of the W3C Recommendation on The global structure of an HTML document also features this example.
HTML 4.01 Strict (smallest)
This is the smallest legal version, leaving out all optional tags
MediaWiki/Wikitext
This is a valid PDF only if the text file has CRLF line endings.
Media-based scripting languages
(Creates a video with default properties)
Lingo (Macromedia Director scripting language)
Outputs the string to the message window if placed in a single movie frame. Alternatively, to display an alert box stating the message you could use
Esoteric programming languages
This page shows the Hello, world! program in esoteric programming languages — that is, working programming languages that were designed as experiments or jokes and were not intended for serious use.
Binary lambda calculus
As documented at http://www.ioccc.org/2012/tromp/hint.html (any of the 16 ASCII characters from ' ' to '/' can be used at the start)
From Eric Raymond's interpreter package (changed to use upper case as in the book).
Hello, world! Souffle by David Morgan-Mar.
Later Mike Worth wrote tastier and actually functional recipe .
The newline before the terminating quote mark is necessary.
INTERCAL programming language
Malbolge programming language
P programming language
Not really an esoteric language, but this code uses obfuscation :
Piet programming language uses only colors.
Spoon (programming language)
Super NAND Time!!
Taxi programming language
T programming language
Unlambda programming language
Var'aq programming language
Note: actually prints "What do you want, universe?" in Klingon.
Note that whitespace has been highlighted ( Space , Tab )
XS programming language
Ya programming language
A code language that draws in binary on a braille plotter.
The OO language looks like C.
Copy this and paste in ChatGPT, on a new chat:
A longer version, which still prints "Hello, world!":
Note: The first method is tested and it's working. I don't know about the second one!
Book:Computer Programming
Pages using deprecated enclose attributes
Books to be broken into subpages