PGP Demo Examples

Each paradigm lesson names a small set of representative languages — the ones that make that paradigm's ideas most visible. Every one of those languages gets a short, self-contained example here, syntax-highlighted for that specific language in the code viewer, so you can see the paradigm's shape in real code without installing anything.

How to use: click View to open a file in the code viewer and read its comments. These are teaching snippets, not runnable projects — most need only a standard interpreter/compiler for that language if you want to try them yourself (a Prolog demo needs SWI-Prolog, a Lisp demo needs any Common Lisp, and so on).

Linear

#LanguageDescriptionLink
1XMLA data-oriented document, read top to bottom, no branching.View
2BASICClassic line-numbered BASIC, written without GOTO to show pure linear flow.View

Structured

#LanguageDescriptionLink
3PascalDecision, repetition, and selection — the three block shapes, in the language designed to teach them.View
4FortranThe same three shapes in the language that made structured programming famous alongside Algol.View

Object-Oriented

#LanguageDescriptionLink
5SmalltalkThe language that defined OOP's vocabulary — everything is an object, responding to messages.View
6JavaEncapsulation, inheritance, and polymorphism, in the language that made OOP mainstream.View

Functional

#LanguageDescriptionLink
7LispThe first functional language (1960): functions as data, recursion instead of loops.View
8HaskellPure functions, immutability, and laziness, taken to their logical conclusion.View

Logic

#LanguageDescriptionLink
9PrologFacts and rules instead of steps — you describe relationships, the engine searches for answers.View

Aspect-Oriented

#LanguageDescriptionLink
10AspectJA logging aspect that crosscuts every matching method call, without editing those methods.View

Component-Oriented

#LanguageDescriptionLink
11JavaScript (Web Components)A self-contained, reusable <counter-button> element with its own encapsulated state.View
12C#Interchangeable components composed entirely through an interface, never a concrete class.View

Hybrid

#LanguageDescriptionLink
13PythonStructured, object-oriented, and functional style mixed freely in one small file.View
Practice move: pick one demo whose language you've never touched — Prolog and Smalltalk are the least familiar to most readers — and try to explain, line by line, what makes it feel different from the language you use daily. That difference is the paradigm.