Documentation · 0.2 beta.36+

Learn Patch by building software.

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
1 · 5 minutes

First program

Create state, show output and run it in Patch Studio.

2 · 10 minutes

First GUI

Build a Counter window with a Button, event and explicit change.

3 · 20 minutes

Real app structure

Use Things, lists, conditions, recipes, Forms and the RAD Designer.

4 · ship it

Build software

Create Web and supported desktop artifacts, or use the Offline Studio beta.

Start here

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.

Fastest path: hosted Patch Studio

  1. Open Patch Studio. The editor and Designer are ready without installing a toolchain.
  2. Replace the sample source with the first program below.
  3. Press Run. Output appears in the result workspace.
  4. Switch to Designer when you start building a Window application.

Offline path

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.

Your first Patch program

create text message = "Hello, Patch!"
show message

create introduces persistent state. show prints a value. Nothing mutates the state in this example.

Command-line quick start

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.

Tutorials

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.

Beginner

1. Counter GUI

Window, Text, Button, event handling and explicit persistent mutation.

Build it
Beginner

2. Conditions and loops

Branch with if/else and repeat work with the built-in count.

Build it
Intermediate

3. Things and Change Contracts

Model structured data and constrain recipe authority by direction and magnitude.

Build it
Intermediate

4. Data controls

ListBox, Table and TreeView keep toolkit selection transient until source explicitly changes state.

Build it

Tutorial 1: build a Counter application

  1. Create a number named count. This is the application state.
  2. Create a Window containing a Text control and a Button.
  3. Add a clicked handler for the Button.
  4. Inside the event, mutate 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.

Tutorial 2: conditions and repeat

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.

Tutorial 3: Things, recipes and bounded authority

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.

Tutorial 4: data controls and transient selection

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.

Language guide

Values and state

Current product state includes number, text, boolean, list and Thing values. Things are finite own-field records with prototype-meta names rejected.

Explicit change

Persistent mutation is expressed inside change. Common semantic operations include set, add, remove and clear according to the target type.

Control flow

if/else and repeat structure execution while keeping nested mutation explicit.

Recipes

make declares reusable behavior and do calls it. Range-bounded parameters and capability checks are supported in the current language subset.

Quick syntax reference

GoalPatchMeaning
Create number statecreate number score = 0Persistent numeric binding.
Create text statecreate text name = "Ada"Persistent text binding.
Create list statecreate list items = ["A", "B"]Persistent list binding.
Create a recordcreate thing player:Finite named-field Thing.
Change statechange score:Opens a semantic mutation block.
Increaseadd 1Numeric increase inside a change block.
Conditionalif score > 10:Conditional execution.
Looprepeat 4:Literal repetition with count.
Outputshow scoreShows an expression.
Windowwindow "App" as main size 640, 480:Declares a named Form.
Eventwhen 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.

GUI applications and Patch Studio

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.

Typical visual workflow

  1. Create or select a Form from the Form selector.
  2. Add a control from the searchable Component Palette.
  3. Move or resize it in Designer, or edit geometry directly in source.
  4. Use Object Inspector for source-backed properties and Events.
  5. Press Run to compile and execute the current project.
  6. Use Build only for a target that the capability matrix reports as supported.

Current component families

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.

Open the generated component capability matrix

Forms and multi-window applications

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.

Designer performance model

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.

Run, build and distribute

Patch exposes different output paths rather than pretending every backend has identical capabilities.

GoalRecommended pathNotes
Learn and prototypeHosted Patch StudioFastest visual edit/run loop.
Work without internetOffline Studio Stage 1Offline authoring, Designer/Object Inspector and Run.
Standalone web apppatch build app.patch --target webProduces supported standalone Web output.
Local supported desktop artifactReady/offline compiler pathCurrent 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 backendC99 / direct Wasm where supportedThese 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.

Example programs

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.

Technical reference

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.

LanguageChange IR 0.10
Desktop GUINative GUI IR 1.9 · payload v19 · runtime v1.10
StudioProject bundle v4 · source-backed RAD Designer
Offline IDEmanifest v1 · offline-studio-v0.2 downloads
DeliveryToken-free local workflows · real Chrome and executable gates
Formal milestonebeta.32 assurance boundary

Language and compiler

Assurance and research

Native and release contracts

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.

Project and roadmap