Hello, World
한국어 · Deutsch · English · Español · Français · Italiano · Svenska · Български · Русский · 中文(中国) · 日本語
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 secline-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
From the Free Pascal wiki, page "Hello, World", as it stood on 2022-08-29 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Edited on wiki.freepascal.org by 1 person, 2022
From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.
| When | Who | What changed |
|---|---|---|
| Kai Burghardt | Kai Burghardt moved page Hello, World to Basic Pascal Tutorial/Hello, World: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778#Cluttering of mai... | |
| Kai Burghardt | remove redirect to Basic Pascal Tutorial/Hello, World and write an article that serves as a single entry point for newcomers | |
| Kai Burghardt | fix spelling mistake, explain the word “internationalize” |
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
