Hello, World
Hello, World refers to a trivial program printing Hello, World!
to some standard means of output.
It is used to illustrate some basic characteristics of a programming language.
This page elaborates a Hello, World in Pascal.
standard source code
The following source code is a minimal, yet complete Hello, World fully-compliant to Standard Pascal (ISO standard 7185):
program helloWorld(output);
begin
writeLn('Hello, World!')
end.
Compilation with the FPC is as simple as that:
$ fpc helloWorld.pas
Target OS: Linux for x86-64
Compiling helloWorld.pas
Linking helloWorld
4 lines compiled, 0.1 sec
line-by-line description
header
Every Pascal source code file starts off with a word identifying the kind of source code.
Here, this kind is program
.
In Extended Pascal (ISO standard 10206) module
is possible, too.
As of 2022, the FPC supports, beside program
, only two other kinds: unit
and library
.
The next word provides an identifier for this program
(or module
).
As per ISO standards, this identifier has no significance.
You could reuse the identifier helloWorld
in the following lines.
The FPC, however, reserves this identifier for use in fully-qualified identifiers.
After that comes a parameter list.
Here this parameter list enumerates one item, output
.
Parameters of the spelling input
and output
have special meaning.
They refer to an implementation-defined standard means of accessing the user interface, that means usually the console.
The header is separated from the following block by a semicolon.
definition
Following the header comes the program
definition.
A program
is defined with a block.
Every block has to have exactly one begin … end
frame.
The FPC also accepts asm … end
(assembly language) frames for routines.
In our program this frame contains one statement:
A call of the built-in procedure writeLn
, short for write line.
Thereafter follows a non-empty comma-separated list of actual parameters.
Here we have one string literal 'Hello, world!'
.
String literals are delimited by typewriter straight quotes.
The program
definition concludes with a period.
degenerate examples
These examples are meant to demonstrate a point. They do not appear in production programs.
whitespace
White space (blanks or newlines) has no significance to the meaning to the program, as long as it does not interfere with words or literal values (i. e. number or string constants):
program helloWorld (output) ;
begin
writeLn ( 'Hello, world!' )
end .
case-insensitive
Pascal is case-insensitive. This program has exactly the same meaning and effect as the standard source code:
PrOgRaM HeLLoWorLd(oUtpUt);
begIn
wRiTelN('Hello, world!')
EnD.
see also
- Using resourcestrings for an internationalized (= translated/translatable) Hello, World
- Hello, World in the Basic Pascal Tutorial
- Hello, world in the Rosetta code project
- Programming in Symbian OS for Hello, World using the Symbian OS API
- Howdy World: Hello, World-inspired tutorial for using a graphical user interface and the Lazarus integrated development environment (IDE)
- Video: Hello, World in Pascal on YouTube