# 15. Compiling & Distributing

## Run vs. compile
- **Interpret** (full language): `stencil app.st` — supports everything in these tutorials.
- **Compile to native exe**: `stencil build app.st -o app.exe` — produces a standalone
  Windows executable that runs without STencil installed.

```
stencil build app.st -o app.exe
app.exe
```

### What native build supports
Numbers, strings, bools, arithmetic, comparison, logic, `if`/`elif`/`else`,
`while`/`for`/`for..in`, functions + recursion, ternary, lists, dicts, indexing &
their methods, classes/models, `in`.

### What native build does NOT support (use the interpreter for these)
`import`, `try/catch`, `stencil` stamping, and the library builtins
(file/JSON/regex/http/graphics/db/...). For programs that use those, ship the `.st`
file and have users run it with the interpreter.

## Distributing your program
1. **As a `.st` script** — share the file; users need STencil installed
   (run the installer). Simple and works with the full language.
2. **As a native `.exe`** — `stencil build` (subset only). No dependency for the user.
3. **Bundle in an installer** — put your `.st` (or exe) plus `stencil.exe` in an
   installer (e.g. Inno Setup) so users get a double-click install.

## Distributing STencil itself
- **Windows installer:** `STencilSetup.exe` (per-user; adds PATH, `.st` association,
  Start Menu, examples).

## Hosting a web app (e.g. Railway)
A web server written with `serve(...)` (lesson 12) can be deployed in a container.
Read `$PORT` from the environment and serve on it:
```stencil
serve(int(env("PORT")), route);
```
A Dockerfile that builds STencil from source and runs your `app.st` lets platforms
like Railway build and host it on Linux.

## Where to go next
- Re-read [Stencils](08_stencils.md) — the feature that makes STencil yours.
- Build something: a CLI tool (lesson 11), a web API (lesson 12), or a game (lesson 13).
