A world-building programming language designed to teach Object-Oriented Programming (OOP) and core simulation concepts to young storytellers through a plain-English, narrative-driven syntax.
Every feature in ForWhile is designed to serve a world-building and simulation philosophy:
- Teaches Real Programming Concepts: Maps directly to classes, objects, traits/properties, composition, methods, constructor methods, loops, and conditions.
- Easy to Understand: Reads like plain English narration.
- No Developer Jargon: Avoids being "Python with English words" by replacing technical keywords (like
def,class,return) with narrative concepts (likecreature,action,play scene). - Reinforces World-building: Code reads like a fantasy story or simulation setup.
Here is how ForWhile maps common programming paradigms to storytelling:
| Programming Concept | Traditional Language (e.g., Python) | ForWhile Narrative Syntax |
|---|---|---|
| Class / Blueprint | class Dragon: |
creature Dragon |
| Instantiation | Ember = Dragon("Ember") |
bring Ember to life as Dragon with ("Ember") |
| State Mutation | Ember.health = 100 |
give Ember the trait health to 100 |
| Composition (Mixin) | attach Fire to Ember |
attach Fire to Ember |
| Method / Action | def breathe(self): |
action breathe |
| Method Call | Ember.breathe() |
Ember does breathe |
| Constructor | def __init__(self): |
when born |
| Conditional Block | if condition: ... else: |
when condition: ... otherwise: |
| Objects Graph / Edge | alice.friend = bob |
alice knows bob as friend |
| Plural References | [x for x in env if type(x) == Dragon] |
the world's Dragon creatures |
| Event Callback | observer.on('die', callback) |
whenever anyone dies |
| Time-Step Loop | for _ in range(10): |
the world ticks 10 times |
For every single detail about the language, please refer to our dedicated documentation files:
- Language Specification: docs/LANGUAGE_SPEC.md — The ultimate reference for grammar, design decisions, complete syntax rules, and language capabilities.
- Educator's Guide: docs/EDUCATORS_GUIDE.md — CS concept mapping, teaching strategies, and 10 ready-to-use classroom exercises.
ForWhile is now available on PyPI! It requires Python 3.8+.
- Open Command Prompt or PowerShell.
- Install ForWhile via pip:
pip install forwhile
- Verify the installation:
forwhile --version
(Note: If forwhile is not recognized, ensure your Python Scripts folder is added to your system's PATH.)
- Open Terminal.
- Install ForWhile via pip3:
pip3 install forwhile
- Verify the installation:
python3 -m forwhile --version
(Note: If installed in ~/.local/bin or Library/Python/.../bin, you can run it via python3 -m forwhile or add the directory to your PATH.)
- Open your Terminal.
- Install ForWhile using pip3:
pip3 install forwhile
- Verify the installation:
forwhile --version # or python3 -m forwhile --version
For the best coding experience, we provide a Visual Studio Code extension with full syntax highlighting for .fw files!
How to Install:
- Open VS Code.
- Go to the Extensions view (
Ctrl+Shift+XorCmd+Shift+X). - Search for ForWhile in the Marketplace.
- Click Install.
Once installed, the forwhile command (or python -m forwhile) is available in your terminal. It supports four subcommands:
Launch the interactive storytelling environment.
forwhile startType help inside the REPL to see a visual cheat sheet of commands.
Bring a .fw story script to life and see the narration. Check out the 35+ examples in the /examples folder!
forwhile run examples/15_ecosystem.fwVerify a story file for syntax errors or invalid vocabulary without running it.
forwhile check examples/01_hello.fwPrint the current version of the ForWhile engine.
forwhile --versionForWhile/
├── forwhile/ # Core Source Code (interpreter, lexer, parser)
├── tests/ # Comprehensive Test Suites
├── examples/ # Over 35 Sample Story Scripts (.fw files)
├── docs/ # Documentation (Spec and Educator's Guide)
├── editors/vscode/ # VS Code Extension Source
├── pyproject.toml # Modern package manifest
└── LICENSE # MIT License