MOGWAI - Embeddable Scripting for .NET
Give your .NET app a scripting engine in 4 lines of code. Embeddable, extensible, NativeAOT-friendly — small enough to drop into desktop, mobile, or IoT apps, to script workflows or expose safe, hot-swappable logic to your users.
▶ Try it now — run MOGWAI in your browser — no install, no signup, runs entirely client-side.
If MOGWAI looks useful to you, a ⭐ helps others discover it — thank you!
MOGWAI is a lightweight scripting engine you embed in your .NET applications — to script complex workflows, expose safe user-customizable logic, or design your own DSL, all without leaving the .NET runtime (NativeAOT included).
foo(45 "TOTO" 17) # classic-style call — reads like foo(45, "TOTO", 17)
foo[x: 10 y: 20] # named parameters, C#-style
45 "TOTO" 17 foo # the exact same call, written in MOGWAI's native RPN form
Note the spaces, not commas. MOGWAI parameters are space-separated —
foo(45 "TOTO" 17), notfoo(45, "TOTO", 17). It reads like a familiar function call, but there's no comma operator in the language.
Under the hood, MOGWAI is a stack-based, concatenative engine — which is what gives it clean, unambiguous semantics with no operator precedence to reason about. But day to day, you can write and read code in the classic-style syntax above; the stack form is always there when you want it (better performance, more composable), never a requirement.
For the curious — here's what's actually happening under the hood.
MOGWAI reads left to right. Values are pushed onto a stack; operators consume values from it and push the result back. There's no operator precedence and no parentheses — the order on the stack is the program.
3 → [ 3 ]
4 → [ 3 4 ]
+ → [ 7 ]
2 → [ 7 2 ]
* → [ 14 ]
The same calculation on a single line — 3 4 + 2 * — also leaves [ 14 ] on the stack. That's the whole idea: small pieces compose, and what you see is exactly what happens.
New to stack-based thinking? You don't have to convert every formula by hand. The calc primitive accepts a regular infix expression as a string — parentheses, operator precedence and all — converts it to RPN under the hood (Dijkstra's Shunting-yard algorithm), and runs it immediately.
"5 * X + (7 + sin(Y))" calc
Write formulas the way you already know them, and grow into RPN at your own pace.
- Classic-Style Syntax - Write
foo(45 "TOTO" 17)orfoo[x: 10 y: 20]— reads like C#/Java, no RPN required to get started - 354 Built-in Functions - Math, strings, lists, files, HTTP, and more
- Async/Await Support - Modern asynchronous execution
- Plugin System - Clean plugin contract via
MOGWAI.IPlugin— official plugins in development - Battle-Tested - 10+ years of real-world usage
- Extensible - Easy integration with .NET applications
- NativeAOT-Ready - Embed in ahead-of-time compiled .NET apps
- Cross-Platform - Windows, Linux, macOS, Android, iOS
- VS Code Extension - Syntax highlighting, autocompletion, run & debug directly from VS Code (install)
- Stack-Based RPN Core - Clean, unambiguous engine underneath, with
calcfor classic infix math formulas when you want them ("5 * X + 2", via Shunting-yard)
The quickest way to try MOGWAI — no .NET SDK required. Grab a ready-to-run CLI for your platform from the Releases page. Each release ships self-contained binaries for Windows (x64), Linux (x64 / arm64) and macOS (x64 / arm64): download the archive, extract it, and run the MOGWAI_CLI executable.
First run on Windows or macOS. The binaries are not code-signed, so the system will warn about an “unrecognized” app the first time — this is expected, not a problem with the build:
- Windows (SmartScreen): click More info → Run anyway, or right-click the downloaded file → Properties → Unblock before extracting.
- macOS (Gatekeeper): right-click the binary → Open → confirm, or run
xattr -d com.apple.quarantine MOGWAI_CLIin Terminal.
Clone the repository and build the CLI for your platform using the .NET SDK:
git clone https://github.com/Sydney680928/mogwai.git
cd mogwai/examples/Console/ConsoleExample/MOGWAI_CLI
dotnet runOr publish a self-contained binary:
# Windows x64
dotnet publish -c Release -r win-x64 --self-contained
# macOS x64
dotnet publish -c Release -r osx-x64 --self-contained
# macOS arm64
dotnet publish -c Release -r osx-arm64 --self-contained
# Linux x64
dotnet publish -c Release -r linux-x64 --self-contained
# Linux arm64
dotnet publish -c Release -r linux-arm64 --self-containedWrite, run, and debug MOGWAI scripts directly from Visual Studio Code with full language support:
- Syntax highlighting — static keywords + dynamic primitives from the connected runtime
- Autocompletion — all runtime primitives, color-coded by category
- Run & Debug — execute scripts and step through code without leaving VS Code
- Runtime panel — live view of the stack, local and global variables
- Error navigation — jump directly to the failing instruction
Install MOGWAI Language Support from the VS Code Marketplace
How to connect VS Code to the runtime: see MOGWAI_VSCODE.md for the step-by-step connection guide.
The core scripting engine, available as a NuGet package. Embed MOGWAI in your .NET applications.
- License: Apache 2.0
- Package: MOGWAI on NuGet
- Status: Production ready
API stability. MOGWAI follows Semantic Versioning. Scripts written today keep working — the language surface (syntax, primitives,
MW.xerror codes) stays stable within the 8.x line. The C# embedding API is still maturing; occasional breaking changes there are documented in the CHANGELOG.
Command-line interface for running MOGWAI scripts and interactive REPL sessions.
- License: Apache 2.0
- Source: built from the
examples/Consoleexample, in this same repository - Status: Functional
Build from source — requires the .NET SDK:
git clone https://github.com/Sydney680928/mogwai.git
cd mogwai/examples/Console/ConsoleExample/MOGWAI_CLI
dotnet runSyntax highlighting, autocompletion, runtime execution, step-by-step debugging, and live variable inspection — all directly inside VS Code.
- License: Apache 2.0
- Repository: Sydney680928/mogwai-vscode
- Marketplace: mogwai.mogwai-language
- Documentation: MOGWAI_VSCODE.md
- Status: Available — v1.3.4
A visual IDE for MOGWAI 8 (debugging, breakpoints, stack inspection, code editing), currently built with WinForms (Windows only). Details will follow on mogwai.eu.com when available.
- License: Proprietary (freemium)
Open source projects powered by the MOGWAI scripting engine:
| Project | Description |
|---|---|
| GIZMO | Build Terminal User Interface (TUI) applications with MOGWAI scripting — cross-platform, self-contained, Apache 2.0 |
New to MOGWAI? Start with these three:
- MOGWAI — The Origin Story — why MOGWAI exists and where it came from
- Anatomy of MOGWAI — the fundamentals of its concatenative design
- Embedding a scripting engine in a .NET MAUI app — the embedding value prop, end to end
- MOGWAI Snake — A Complete Game Written in RPN Scripting Language - a snake game with MOGWAI, it's possible !
All articles on coding4phone.com
- MOGWAI in Production: How a Scripting Language Powers an Industrial Test Bench
- MOGWAI Under the Hood: Syntactic Sugar and the RPN Canonical Form
- MOGWAI — The
-->Operator: Transforming a Variable In Place, Cleanly - Dynamic Variable Assignment in MOGWAI
- Loops in MOGWAI
- Timers in MOGWAI
- MOGWAI — The Origin Story
- Events in MOGWAI
- Tasks in MOGWAI
- Code editor in MOGWAI CLI
- Bytes aren't scary. Manipulating binary data with MOGWAI
- MOGWAI v8.6 — Objects and Assertions
- One Day, One Extension — The Story of MOGWAI Language Support for VS Code
- Embedding a scripting engine in a .NET MAUI app — dynamic logic, BLE commands, zero app updates
- GIZMO — Build TUI Applications with MOGWAI
- Evaluating a user-defined mathematical formula with GIZMO and MOGWAI
- MOGWAI 8.7: sorted identifiers, OOP introspection, and external processes
- MOGWAI meets Avalonia — A cross-platform REPL in a single session
- MOGWAI Language Support for VS Code — v1.0.3
- Anatomy of MOGWAI — the fundamental properties of a modern concatenative language
- Counting GitHub release downloads… in MOGWAI
Install the MOGWAI runtime via NuGet:
dotnet add package MOGWAIusing MOGWAI.Engine;
using MOGWAI.Interfaces;
var engine = new MogwaiEngine("MyApp");
engine.Delegate = this; // Your class implementing IDelegate
var result = await engine.RunAsync(@"
""Hello from MOGWAI!"" ?
2 3 + ?
", debugMode: false);# 1 — Print to output with ?
"Hello from MOGWAI!" ? # → Hello from MOGWAI!
2 3 + ? # → 5
# 2 — Store and recall ( value -> 'name' )
42 -> '$answer' # the $ prefix marks a global variable
$answer ? # → 42
# 3 — Define and use a function
to 'square' with [n: .number] do
{
n n *
}
square(5) ? # → 25 (classic-style call)
5 square ? # → 25 (same call, native RPN form)
# 4 — Transform a list
(1 2 3 4 5) foreach 'n' transform { n square } -> '$result'
$result ? # → (1 4 9 16 25)
# 5 — Structured data with records (space-delimited — no commas)
[name: "MOGWAI" version: "8.14.0"] -> 'info'
info ? # → [name: "MOGWAI" version: "8.14.0"]
# 6 — Conditionals
if ($answer 40 >) then
{
"The answer is greater than 40" ?
}
Note on variables: Variables prefixed with
$are global. When the engine is instantiated withkeepAlive: true, global variables persist across multiple script executions — making them the natural choice for interactive sessions like the REPL or the Blazor playground. Local variables (without$) are scoped to a single execution and are the recommended approach for one-shot embedding scenarios.// Global variables persist across executions var engine = new MogwaiEngine("MyApp", keepAlive: true); // Global variables are reset on each execution (default) var engine = new MogwaiEngine("MyApp");
MOGWAI is a focused tool, not a general-purpose language. It shines when:
- You want 354 built-in functions (math, strings, lists, files, HTTP, and more) without pulling in a heavier language runtime
- You're embedding a scripting runtime in a .NET application, including NativeAOT builds
- You need a lightweight, extensible runtime with a clean plugin contract
- You want to offer safe, hot-swappable scripting to your users — update logic without recompiling or redeploying your app
- You appreciate the concatenative programming model in the tradition of Forth, Factor, PostScript and HP RPL
- You want zero operator precedence ambiguity — the stack is the single source of truth
- .NET SDK 9.0 or later
- Git
# Clone repository
git clone https://github.com/Sydney680928/mogwai.git
cd mogwai
# Restore dependencies
dotnet restore src/MOGWAI/MOGWAI.sln
# Build
dotnet build src/MOGWAI/MOGWAI.sln --configuration Release
# Pack (optional)
dotnet pack src/MOGWAI/MOGWAI.sln --configuration ReleaseThe compiled assembly will be in src/MOGWAI/MOGWAI/bin/Release/net9.0/.
mogwai/
├── .github/
│ └── workflows/ # GitHub Actions (CI, GitHub Pages deployment)
├── docs/
│ ├── EN/
│ │ ├── use-cases/ # Use case articles
│ │ ├── MOGWAI_EN.md # Language reference
│ │ ├── MOGWAI_FUNCTIONS_EN.md # Function reference
│ │ └── MOGWAI_INTEGRATION_GUIDE_EN.md # Integration guide
│ └── FR/
│ ├── cas d'usage/ # Use case articles in french
│ ├── MOGWAI_FR.md # Language reference in french
│ ├── MOGWAI_FUNCTIONS_FR.md # Function reference in french
│ └── MOGWAI_INTEGRATION_GUIDE_FR.md # Integration guide in french
├── examples/
│ ├── Avalonia/
│ │ └── MogwaiRepl/ # Cross-platform REPL with Avalonia UI
│ ├── Blazor/
│ │ └── MogwaiPlayground/ # Blazor WASM interactive playground
│ ├── Console/
│ │ └── ConsoleExample/
│ │ └── MOGWAI_CLI/ # Command-line interface and REPL
│ ├── MAUI/
│ │ └── MauiExample/ # Cross-platform mobile app
│ ├── Scripts/ # Standalone .mog example scripts (games, tasks, web)
│ └── WinForms/
│ └── WinFormsExample/ # Turtle graphics demo
├── images/ # Screenshots and media
├── src/
│ └── MOGWAI/
│ ├── MOGWAI.sln # Main solution
│ ├── MOGWAI/
│ │ ├── Engine/ # Core runtime engine
│ │ ├── Objects/ # MOGWAI object types
│ │ ├── Primitives/ # Built-in functions (354 primitives)
│ │ ├── Interfaces/ # Public interfaces (IDelegate, IPlugin)
│ │ └── Exceptions/ # Exception types
│ ├── MOGWAI.Tests/ # Unit tests
│ └── MOGWAI_TEST/ # Lightweight CLI runner for in-solution testing
├── LICENSE # Apache 2.0 license
├── NOTICE # Copyright notice
├── CONTRIBUTING.md # Contribution guidelines
└── README.md # This file
- Language Reference - Complete MOGWAI language guide
- Function Reference - All 354 built-in functions
- Integration Guide - How to integrate MOGWAI in your .NET apps
- VS Code Extension Guide - How to use VS Code with the MOGWAI runtime
Examples are available:
-
MOGWAI CLI - Command-line interface and REPL
-
Avalonia Example - Cross-platform REPL with Studio mode (Windows, Linux, macOS)
-
WinForms Example - Turtle graphics with MOGWAI
-
MAUI Example - Cross-platform mobile app
-
Blazor Example - Blazor WASM app
-
Scripts - Standalone
.mogscripts (games, task patterns, a GitHub API example)
See CHANGELOG.md for a detailed history of changes.
Latest Release: v8.14.0
You can test it live on Blazor REPL
A full-featured REPL and script editor running natively on Windows, Linux and macOS — with Studio mode for live VS Code debugging.
# WinForms turtle graphics — classic-style
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
"Square complete!" ?
# same script, native RPN form
100 turtle.forward
90 turtle.right
100 turtle.forward
"Square complete!" ?
Illustrative example — how MOGWAI orchestrates hardware through plugins:
# Read sensor via BLE (requires MOGWAI_BLE plugin — coming soon) — classic-style calls
ble.connect("AA:BB:CC:DD:EE:FF") -> 'device'
ble.read(device "temperature") -> 'temp'
# Control based on value — comparisons stay in RPN, they read best that way
if (temp 25 >) then
{
gpio.on("fan")
}
Note: Official MOGWAI plugins (BLE, Serial...) are currently in development and not yet publicly available. Third-party plugins can already be built today by implementing the
MOGWAI.IPlugininterface.
Use Case #1 — Electronic Board Test Bench
Full version history lives in CHANGELOG.md. Highlights of the latest release, v8.14.0:
- Full HTTP verb coverage (
http.head/put/patch/delete) and UDP primitives (udp.send/receive/sendReceive) - Hardened HTTP internals (shared
HttpClient, consistent error reporting) sumon an empty list()now returns0instead of raising an error
Next up: a community plugins marketplace, additional language integrations, and an extended function library.
Older milestones (8.0 → 8.6)
- Complete rewrite with namespace organization
- 240+ primitives
- Apache 2.0 open source license
- Published on NuGet
- .NET 9.0 support
- Complete documentation
+/-primitive to negate a number- New error code:
OperationNotSupportedError(MW.7) - Convenience typed-object helpers on
MOGBaseItems(AddString,AddNumber,AddBoolean, …) andMOGRecord(SetString,SetNumber,SetBoolean, …) — no explicitEnginereference required foreach ... transform— transform items while iterating a list
- Classic-style call syntax as alternatives to RPN:
foo[x: 50 y: 20](named parameters) andfoo(2 3 4)(parameter list) - Parser now reports the source position on error (used by MOGWAI STUDIO)
- Fixed UI freezes and timer/event issues in the Blazor WebAssembly playground under long-running scripts
- Variable references with
&varname— mutate variable content in place instead of pushing a copy (+,set,get,butfirst,butlast,last,first,sub,size) - Explicit variable access with the
@sigil — significant performance gain on frequent variable access char->primitive — ASCII code from a single characterforeachloop over string characters- Performance work: host function detection at parse time, faster dictionary lookups, removed systematic primitive cloning during execution
- Plugin contract via
MOGWAI.IPlugininterface - AOT compatibility (
IsAotCompatible) - Major performance optimizations (O(1) primitive lookup, LINQ removal in hot paths)
bagprimitive!Aauto-eval sigil-->in-place pipeline operator- Binary data primitives (DATA/BIN families)
- Enhanced debugging protocol
- 280+ built-in primitives
- Additional examples and documentation
- OOP support (classes, instances, properties, methods, lifecycle hooks)
- MOGWAI STUDIO v2 (early private development — rebuilt from scratch for MOGWAI 8)
(8.7 through 8.14 — skill system, OOP introspection, math/string primitive families, calc, HTTP/UDP support — see CHANGELOG.md for full detail.)
Contributions are welcome! Bug reports, feature requests, and pull requests all start the same way — see CONTRIBUTING.md for the full guide (issue templates, branch/PR workflow, code style).
Created in 2015 to simulate Bluetooth Low Energy devices for IoT testing, MOGWAI evolved over 10+ years into a full-featured scripting language now used in industrial automation — see how it drives an electronic board test bench in production (read the story).
If you grew up on an HP 28S or HP 48, the stack engine underneath will feel like home — that's the lineage MOGWAI's RPN core comes from. Everyone else can just use the classic-style syntax shown above and never think about it.
- MOGWAI Runtime & CLI: Apache License 2.0 — see LICENSE and NOTICE
- MOGWAI STUDIO: Proprietary, freemium (Free + Pro) — not open source; details to follow on mogwai.eu.com
- Website: mogwai.eu.com · NuGet: MOGWAI · Author: Stéphane Sibué
- Found a bug or have an idea? Open an issue or start a discussion
- Using MOGWAI in production? We'd love to hear your story — even a simple "I tried it and it works!" helps.
Made with ❤️ by Stéphane Sibué






