First program
Create state, show output and run it in Patch Studio.
Documentation · 0.2 beta.36+
Start with a three-line program, build a real window, add state and events, then move into recipes, Change Contracts, multi-form applications and native builds. The reference material remains on the same page when you need the exact current product boundary.
create number count = 0 change count: add 1 show count
Create state, show output and run it in Patch Studio.
Build a Counter window with a Button, event and explicit change.
Use Things, lists, conditions, recipes, Forms and the RAD Designer.
Create Web and supported desktop artifacts, or use the Offline Studio beta.
You can learn Patch entirely in the browser. Open Patch Studio, edit the source, press Run, and watch the result. The visual Designer edits the same Patch source instead of maintaining a hidden form file.
The rolling offline-studio-v0.2 release provides the Stage 1 Offline Studio beta for Windows x64, macOS Apple Silicon and Linux x64. It provides offline authoring, Designer/Object Inspector and Run. Host-native Build directly inside Offline Studio is still the explicit Stage 2 gap.
Download Offline Studio or the standalone compiler
License: Patch is MIT-licensed. Copyright (c) 2026 Michel Nguyen. You may use, modify, distribute, sublicense and sell copies as long as the copyright and permission notice are retained.
create text message = "Hello, Patch!" show message
create introduces persistent state. show prints a value. Nothing mutates the state in this example.
patch check app.patch patch run app.patch patch build app.patch --target web patch doctor --json
check validates source, run executes supported programs, build creates a selected artifact, and doctor reports compiler/backend health. Machine-readable JSON contracts are available for supported commands.
These tutorials use syntax that is exercised by the repository test suite and current examples. For the full step-by-step handbook, open the dedicated Tutorials page; for a browsable program library, use Examples.
Window, Text, Button, event handling and explicit persistent mutation.
Build itBranch with if/else and repeat work with the built-in count.
Model structured data and constrain recipe authority by direction and magnitude.
Build itListBox, Table and TreeView keep toolkit selection transient until source explicitly changes state.
Build itcount. This is the application state.clicked handler for the Button.count only through an explicit change block.create number count = 0
window "Counter" size 420, 240:
text "Count: {count}" at 24, 24 size 220, 32
button "Add" as add_button at 24, 72 size 120, 38
when add_button clicked:
change count:
add 1
The text interpolation {count} reflects the new state after the event. In Patch Studio you can move and resize the controls in Designer and the geometry remains ordinary source.
Conditions are readable blocks. A literal repeat exposes the current 1-based iteration through count.
create number score = 0
repeat 4:
if count == 2 or count == 4:
change score:
add count
show score
This program adds 2 and 4, then shows 6. The persistent mutation remains visible even when it is nested inside control flow.
A Thing groups named fields. A recipe can be paired with an allow declaration that restricts which semantic effects are permitted.
create thing player:
name = "Mia"
score = 0
allow reward:
player.score may increase up to 10
make reward(player):
change player:
add 5 to score
do reward(player)
show player.score
The recipe requests an increase of 5 and the declared capability permits an increase up to 10. Patch can reason about the semantic direction and, where provable, its magnitude.
GUI selection is not automatically persistent state. A changed handler receives transient value, and persistence happens only when the handler performs a Patch change.
create list fruits = ["Banana", "Mango"]
window "Fruit Picker":
listbox "Apple", "Banana", "Cherry", "Mango" as fruits
when fruits changed:
change fruits:
set = value
Because fruits is list state, the ListBox uses multi-selection on supported targets and value is a transient text list.
Current product state includes number, text, boolean, list and Thing values. Things are finite own-field records with prototype-meta names rejected.
Persistent mutation is expressed inside change. Common semantic operations include set, add, remove and clear according to the target type.
if/else and repeat structure execution while keeping nested mutation explicit.
make declares reusable behavior and do calls it. Range-bounded parameters and capability checks are supported in the current language subset.
| Goal | Patch | Meaning |
|---|---|---|
| Create number state | create number score = 0 | Persistent numeric binding. |
| Create text state | create text name = "Ada" | Persistent text binding. |
| Create list state | create list items = ["A", "B"] | Persistent list binding. |
| Create a record | create thing player: | Finite named-field Thing. |
| Change state | change score: | Opens a semantic mutation block. |
| Increase | add 1 | Numeric increase inside a change block. |
| Conditional | if score > 10: | Conditional execution. |
| Loop | repeat 4: | Literal repetition with count. |
| Output | show score | Shows an expression. |
| Window | window "App" as main size 640, 480: | Declares a named Form. |
| Event | when save clicked: | Declares UI event behavior. |
For exact grammar and edge cases, use the language specification. The user guide intentionally teaches the stable current surface instead of reproducing every parser rule.
Patch Studio is a source-backed RAD environment. The editor, Designer, Object Inspector, Project Tree, Resource Manager and component tools operate on the same project source. There is no separate hidden persistent form model.
Patch includes source-backed Forms and current authoring/runtime paths for Text, Button, Input, Checkbox, Radio, ComboBox, ListBox, Table, TreeView, Tabs, Slider, Panel, Menu, dialogs, Picture, Shape, PaintBox, Timer, StatusBar and ImageList metadata. Target parity is explicit and conservative.
Named Forms can be opened and closed through Patch application behavior. The Designer materializes only the active Form's controls while preserving source-backed shells for the other Forms. Runtime events now reconcile keyed Forms so unchanged Form DOM can remain stable.
The primary Designer preview uses a declaration-only design snapshot instead of executing application behavior. Large projects use active-Form materialization. Current runtime rendering uses stable keyed Form/control identities, preserves bounded transient browser state around changed-Form replacement, and updates Tabs locally rather than rebuilding every Form.
Patch exposes different output paths rather than pretending every backend has identical capabilities.
| Goal | Recommended path | Notes |
|---|---|---|
| Learn and prototype | Hosted Patch Studio | Fastest visual edit/run loop. |
| Work without internet | Offline Studio Stage 1 | Offline authoring, Designer/Object Inspector and Run. |
| Standalone web app | patch build app.patch --target web | Produces supported standalone Web output. |
| Local supported desktop artifact | Ready/offline compiler path | Current Windows/macOS/Linux Window contract is Native GUI IR 1.9 / payload v19 / runtime v1.10. Explicit payload v17/runtime v1.8 remains a compatibility path. |
| Portable numeric backend | C99 / direct Wasm where supported | These subsets fail closed on unsupported language features. |
Signing status matters: Windows Offline Studio is currently unsigned by Authenticode, Linux is unsigned, and macOS uses ad-hoc signing only. Production Developer ID/notarization and Windows signing remain explicit open release work.
Use these as starting points instead of writing everything from an empty editor. The repository contains a larger compatibility and research corpus; these are the most useful entry points for application developers.
Minimal stateful Window application with a Button event.
counter-window.patchBest first GUI example.Small if/else program.
conditions.patchReadable branching.Thing state plus a bounded semantic capability.
change-capabilities.patchMagnitude-aware authority.Boolean state and a changed event.
checkbox-window.patchBoolean UI state.Text selection through a source-backed choice control.
combo-window.patchSelection event example.Seven Forms that run a ticket from quote to ready on the Current Ready surface.
workshop-desk.patchLarge reference application used by real Chrome and Ready tests.One current map of Patch. The current product line is Patch beta.36, Change IR 0.10, Studio project bundle v4 and Native GUI IR 1.9 / payload v19 / runtime v1.10. Current RAD/native product work does not widen the beta.32 formal runtime-correspondence claim.
Patch keeps the Current Ready Native GUI IR 1.9 / payload v19 / runtime v1.10 contract alongside explicit older compatibility contracts. Payload v17/runtime v1.8 remains an Offline Compiler compatibility path, while IR 1.2 / payload v12 / runtime v1.3 remains the frozen TreeView line. Newer features never silently reinterpret older contracts.
No documentation matches this filter. Press Escape or clear the search field to show everything.