Shoddy Documentation
Highlighting, snippets, debugging and mill commands, with a Run button
This page covers everything about writing Shoddy in VS Code: installing the extension, its commands, native debugging (the perch, Shoddy's debugger), and the one environment detail worth understanding. An extension is an add-on package that teaches VS Code something new; here, a whole language. This one carries its own mill (the program that compiles and runs Shoddy) and machines, so the only prerequisite is the .NET 10 runtime: Setup, Track A, two steps.
Only two sections here ask you to do anything: installing the extension (required, once) and the smoke test (recommended, a minute). Everything else is either optional, with its trigger stated on the section, plain usage (§3 to §4, §6), or background (§5).
Key note. Shortcuts are written
Cmd+…/Ctrl+…: macOS usesCmd, Windows and Linux useCtrl. Everything else on this page is identical on every platform.
Shoddy has its own extension, and it provides:
Rem/' comments, all case-insensitive);def,
select, fn, ...);F5 (section 3);ctrl+r, plus the ▶ button), which runs the program in a
terminal window of its own, Weave File, Build Machine from
File, and Show Generated C#. Run File is the same
as Run → Run Without Debugging
(Ctrl+F5).It also carries a complete toolchain, every tool needed to build and run
Shoddy. A mill and every machine ship inside the package, so installing it is
the whole install. Download the latest .vsix from
the latest release
(one package, every platform), then in VS Code: Extensions view →
··· menu → Install from VSIX… → pick the file you
downloaded. Reload when prompted.
The bundled mill is portable .NET: mill.exe on Windows, and
dotnet mill.dll everywhere else, through the runtime
Setup had you install. The machines travel with it.
That is why a bare Include "seq.shoddy" resolves in any folder
you open, with nothing set.
Optional, only if you have edited the extension: repackage from the repo root, which stages a fresh mill and freshly built machines into the package first:
./build.sh vsix # ./build.ps1 vsix on Windows
Optional, only if you are developing the
extension: to iterate without packaging at all, open the
vscode-shoddy/ folder in VS Code and press F5. That launches an
Extension Development Host, a second VS Code window with your edited
extension loaded.
Tip If GitHub Copilot is in this
window too, spend five more minutes on
Grounding an Assistant. Copilot has never read
a line of Shoddy and will write you BASIC unless a
.github/copilot-instructions.md tells it otherwise. That page has
the file to copy.
The extension looks for a mill in four places, in order: the
shoddy.millPath setting; the mill your workspace has built, at
artifacts/bin/Shoddy.Mill/release/mill under the folder you have
open (mill.exe on Windows); its own bundled copy; then
mill on your PATH, the list of folders your terminal searches
for commands. The bundled copy means almost everyone can skip this
section.
The one ordering to know: a workspace's own built mill beats the
bundled one. That is deliberate. When the repo is your open folder, the mill
you just built is the one you want tested, not the one that shipped. Set
millPath explicitly in two cases: you keep several checkouts
(separate copies of the repository) and want the editor pinned to one
regardless of which is open, or something else named
mill hides the real one.
If you do set it, set it in User
settings, not per-workspace. Then every folder you ever open, inside the
repo or out, finds it with no per-folder setup:
Ctrl+Shift+P / Cmd+Shift+P →
Preferences: Open User Settings (JSON), then add:
"shoddy.millPath": "C:\\github\\shoddy\\artifacts\\bin\\Shoddy.Mill\\release\\mill.exe"
(macOS/Linux: the full absolute path to the built mill. Do
not rely on ~ expanding inside settings.)
Whichever mill answers, keep the editor at four spaces for
.shoddy files: Shoddy's blocks are indentation-based (a tab
counts as 4) and the whole corpus uses 4 spaces.
Start here: it is the fastest way to see the whole chain working, and it
needs no configuration. Shoddy has native debugging: running your program
one line at a time while you watch what it does. In mill vocabulary the
debugger is the perch, the place where woven cloth was
inspected for flaws. Open any .shoddy file and press
F5: no launch.json needed. The program compiles with debug
instrumentation (the extra bookkeeping that lets the debugger watch each
line). It is the same program mill run builds, machines and
all, and it runs until it reaches a breakpoint, as a C# program does under
the .NET debugger. If it would not compile, the launch fails
with the error the runner gives, rather than starting and dying part-way
through.
The program runs exactly as it does under mill run.
It gets a terminal window of its own, outside VS Code, named
shoddy debug: FILE. That is the operating system's own
terminal (Windows Terminal or the console on Windows, Terminal on macOS),
at its full size. To use a different one, set VS Code's
terminal.external.windowsExec,
terminal.external.osxExec or
terminal.external.linuxExec. The program
reads that window's keyboard (Input, InputLine,
InKey), draws on its screen (escape codes and all, so VT100 games
play), opens scribbler windows and plays sound. It runs from its own folder,
whichever folder the workspace is opened on, so a relative path such as
files/words.txt finds the file beside the program. That is true
in a checkout and out of one: the machines the extension ships are debugged
the same way as the ones in the repository.
Why a window of its own: VS Code's integrated terminal keeps
F1, F5 and the chord prefixes for the editor, and
a game that reads the arrow keys and the function keys through
InKey never sees them there. The
terminal checklist records, per mill, what each one asks of a terminal
and which terminals pass. The window is opened on the machine VS Code
itself runs on, so a remote, WSL or container session, where the editor's
window and the program's would be on different machines, cannot launch;
debug on the machine that has the terminal.
Under the hood, VS Code runs mill dap as the debug adapter.
The adapter asks VS Code for the window and starts the program's own
process in it, mill run --perch PORT FILE, which compiles the
program with the instrumented library and connects back to the adapter;
from then on the adapter relays between the two. Then:
.shoddy file: your own, or a machine's. A machine is Shoddy too,
and the debugger runs every machine your program reaches in its
instrumented build, so a breakpoint in seq.shoddy stops there.
To reach a machine's file, step into a call to it (F11), or open
it from the folder SHODDYLIB names: unless you set one, that is
the extension's own mill/machines folder, such as
~/.vscode/extensions/shoddymills.vscode-shoddy-2.10.0/mill/machines/.
One file per machine, named as you Include it. Stepping in asks
nothing. Opening the file with File → Open does: the folder is
outside your workspace, so VS Code asks Do you want to allow untrusted
files in this workspace? Choose Open. Open in
Restricted Mode opens a new window with the extension's features off,
where a breakpoint does nothing for the session you are debugging. Tick
Remember my decision for all workspaces only if you want that
answer for every workspace, not just this one.
A top-level Let is a line like any other. A line stops once
each time it runs, however much happens on it.
True or False, such as n = 3. A
condition that fails, or answers something else, stops the program and
says why in the Debug Console.>, >=, <, <=
or = before it compare, and % N stops on every
Nth hit. Only hits whose condition held are counted.n is {n}, doubled {n * 2}.mill run. Untick Runtime errors in the
Breakpoints view to let errors end the program without stopping.F6) stops a running program at the
next line it reaches, a program stuck in a loop included. A program waiting
in Input or InKey reaches its next line when you
give it the key it is waiting for, and pauses then.F10), into (F11), out (Shift+F11).
Step into goes into the Def a line calls, a machine's included, so you can
watch Sum or MatMul work. A tail-recursive def (one
whose last act is to call itself) loops in place without growing the stack,
exactly as it executes, and each pass is a new line to step to.UPDATEBINV ← SOLVE ← MAIN.Person(Name = "ANN", Age = 34) and expand into fields), Globals
(top-level Lets), and the Value Stack, half the story in a
stack language. Double-click any of them, a record's field or a list's
element included, to set it to the value of any Shoddy expression. The
program computes with the new value from the next thing it does.Twice(k) + Px(p),
IndexOf(names, "ANN"). It is compiled, as everything in Shoddy
is, and it leaves the program as it found it. A program running inside a
host (Hosting) is debugged by attaching, and
there the Debug Console, Watch and hover show a variable by name but cannot
evaluate an expression, because the host carries no compiler.None are needed. To give a program arguments, arm the network, or run it
from another folder, add a launch.json (Run → Add
Configuration… → Shoddy) and set any of these:
| Setting | What it does |
|---|---|
program | The .shoddy file to debug. Default: the one you are editing. |
args | The program's arguments, what Args() answers: ["words.txt", "42"] is mill run FILE words.txt 42. |
allowNet | true arms the network, as mill run --allow-net does. |
cwd | The folder the program runs from. Default: the program's own folder. A relative one is taken against the workspace folder. |
stopOnEntry | true stops on the first line that runs. That is a top-level Let in an included file when there is one, since those run before Main. Off by default. |
{
"type": "shoddy",
"request": "launch",
"name": "Burler, seeded",
"program": "${workspaceFolder}/burler.shoddy",
"args": ["files/words.txt", "42"]
}
There is no console setting. A program being debugged
always runs in a terminal window of its own, and a launch that names
console is refused with a message saying to remove it.
The extension's Run, Weave, Build Machine and Show Generated C# commands run from the program's folder too.
The extension's four commands work on the .shoddy file you
are editing, in any folder, inside a checkout or out of one. Right-click in
the file to find them, or open the Command Palette
(Cmd+Shift+P / Ctrl+Shift+P) and type
“Shoddy”.
| Command | What it does |
|---|---|
Run File (ctrl+r, or the ▶
button) | Runs the program with mill run in a terminal
window of its own. The same as Run → Run Without
Debugging (Ctrl+F5). |
| Weave File (compile) | Compiles the program
to FILE.dll beside the source, a program that later runs
anywhere .NET runs (the Toolchain page
says how). Scribbler-window programs run only under mill run,
so weave console programs. |
| Build Machine from File | Compiles a machine to
Shoddy.Machines.<Name>.dll in the bin/
folder beside its source. Run and weave link against it from then
on. |
| Show Generated C# | Opens the C# the weave produces, to read. |
Work on the mill itself happens at the command line, with the build
wrapper: ./build.sh build builds the mill under
artifacts/, and ./build.sh test proves it still passes
(./build.ps1 on Windows). The
Toolchain page lists every command.
Nothing to configure here. This section explains what the extension does
with SHODDYLIB on your behalf, and matters only if you decide to
set one yourself.
The extension invokes mill five different ways (Run, Weave,
Machine, Show Generated C#, and F5 Debug), and they do not all receive
environment variables the same way. (An environment variable is a named
setting the operating system hands to a program when it starts.)
Weave and Machine go through VS Code's integrated
terminal, which picks up terminal.integrated.env.* from
workspace settings. Run and F5 Debug open a terminal window of the
operating system's own, and Show Generated C# runs the mill directly from
the extension host (the background process that runs extensions). Those
three inherit only the environment the VS Code process
itself was launched with, plus what the extension adds. That split is a
trap: a SHODDYLIB set in workspace settings makes Weave work
while silently breaking Run and F5 on the first Include-using program.
The extension now closes that gap itself. It points SHODDYLIB
at its own bundled machines by both routes at once (a terminal environment
collection for the terminal commands, and an explicit environment for the two
processes it spawns), so all five behave identically with no setup.
If you set SHODDYLIB yourself, the extension uses yours
everywhere. Set it where the VS Code process
will see it: a User environment variable on Windows, a shell-profile
export on macOS (VS Code resolves your login-shell environment at
launch, Dock launches included). Then restart VS Code fully
(macOS: Cmd+Q, relaunch), because a program copies its
environment variables once, at launch. Setting it in a workspace's
terminal.integrated.env reopens exactly the split described
above, so do not.
One other environment variable the mill reads: SHODDY_LINT,
set to anything, turns on the weave-time accessor-shadowing warning. The same
launch rules apply: set it where the VS Code process will see it if you want
F5 and ▶ Run to lint alike. What it warns about, and why it is off by default,
is on the Toolchain page.
Run File and F5 both give the program a terminal window of
its own (section 3), so programs that use
Input or InKey work as they are. Run
tst/gradebook.shoddy with ctrl+r and type at the
prompts. To replay its scripted session
instead (a command-line matter, the only one on this page):
./build.sh run tst/gradebook.shoddy < tst/golden/gradebook.in
Do this once after installing the extension, and again whenever
SHODDYLIB or millPath changes, or a mill you build
yourself moves. Use a scratch folder outside any checkout. That is
the real test: it proves a program folder anywhere on disk will work, not just
files inside the source tree.
check.shoddy in a scratch folder:
Include "stats.shoddy"
Def Main()
Print(Sum({ 1, 2, 3 }))6, not unknown word: Sum or a “cannot
open” error.Editor-side symptoms. If the command line is broken too, start with Setup's troubleshooting instead. Fix the machine before the editor.
| Symptom | Likely cause |
|---|---|
| Works on Weave File but fails on ▶ (Run), F5 or “Show Generated C#” | A SHODDYLIB of your own was set only in a workspace's
terminal.integrated.env, which only the integrated terminal
sees. See section 5 |
unknown word: Sum (or any library word) on Run
and F5 alike |
A SHODDYLIB left over from an older install points somewhere
that no longer holds the machines. It overrides the bundled ones. Clear it
and fully restart VS Code (macOS: Cmd+Q). With it unset the
extension supplies its own |
macOS: works when VS Code is launched from a terminal
(code .) but not from the Dock |
Only possible with a SHODDYLIB or PATH of your
own: the login-shell environment was not resolved. Keep the
export in ~/.zshrc or ~/.zprofile and
fully relaunch, or drop it and let the bundled toolchain answer, which no
Dock launch can miss |
“The framework Microsoft.NETCore.App version 10 was
not found” |
The .NET 10 runtime is not installed, or VS Code predates the install. Setup step A1, then restart VS Code |
| Mill not found at all | All four lookups missed, which normally means the package was built
without its mill staged. Check shoddy.millPath is not set to a
stale path (it is checked first, and a wrong value beats the bundled copy),
then reinstall the .vsix from the Releases page |