Language
Pascal
- First appeared
- 1970
- Paradigm
- Imperative, structured, object-oriented
- Toolchain
- Free Pascal 3.2.2
- Container image
debian:trixie-20261027-slim + fp-compiler-3.2.2 3.2.2+dfsg-46
Niklaus Wirth designed Pascal at ETH Zurich in 1970 to teach structured
programming: blocks with begin and end, procedures and functions, and a
type for every variable, declared before use. Through the 1980s it was a
common first language in schools and universities, and Turbo Pascal and
later Delphi took it into commercial programs. Free Pascal is an
open-source compiler for the modern dialect, compiled here with every
warning treated as an error.
Its run-time library is larger than the language’s reputation suggests:
SysUtils has string helpers such as Split, Math has Mean and
Variance, and Generics.Collections has growable lists and sorting. The
Free Component Library and Lazarus packages aren’t installed here.
Quirks
- The dialect depends on a mode switch. Without
{$mode objfpc},Integeris 16 bits and tops out at 32767; with it,Integeris 32 bits. Every program here starts with that switch. - Without
{$H+}, aStringholds at most 255 characters and silently cuts off the rest. /always gives a real number, so7 / 2is 3.5.divis integer division, and-7 div 2is −3: it rounds toward zero.- Strings count from 1, but dynamic arrays count from 0, and a fixed
array counts from whatever its type says, such as
array[1..4]. - Range checks are off by default. With
V: array[1..4] of Double,V[0] := 5won’t compile, butI := 0; V[I] := 5runs with no error and writes outside the array. WriteLn(x)prints a real as2.9677500000000002E+001.x:0:6asks for width 0 and six decimals.TDictionaryfromGenerics.Collectionstriggers warnings in the library’s own code, so with warnings as errors, a program that uses it won’t compile.TListandTArrayHelpercompile cleanly.- Names aren’t case-sensitive:
LENGTH(S)andLength(s)are the same call.
Concepts in Pascal
- Cross-validation
- Decision tree
- Descriptive statistics
- k-means clustering
- k-nearest neighbors
- Linear regression
- Logistic regression
- Naive Bayes
- Principal component analysis
Run the examples locally
You need Docker and Python 3. The harness builds the pinned container and runs every Pascal example:
git clone https://github.com/qnixon/dswithx.git
cd dswithx
python3 harness/run_tests.py --language pascal