Browser Playground
The Nilakan playground is a focused environment for a program that starts in main.nlk
and can grow into several files. It runs entirely in your browser: source code, diagnostics, program
output, drafts, and share payloads are not sent to a Nilakan backend.
Commands and keyboard shortcuts
Section titled “Commands and keyboard shortcuts”The header keeps Run and the program’s name in words; its other buttons are icons, and pointing
at one names it and shows its shortcut. The search button opens the command palette, which finds
every action, example, and setting. Press Ctrl+K on Windows and Linux, or Command+K on macOS, to
open it while editing; Ctrl+Shift+P and F1 open it too. Type an action or example name and press
Enter to select it. Commands whose name starts with, or has a word starting with, what you typed
come first, then name substrings, then keywords, and examples list after commands. The palette also
runs editor actions: Go to line, Go to symbol, Find, Replace, Toggle line comment, Fold all and
Unfold all. On a phone, the palette is also where examples and sharing are found.
The program’s name, such as My Draft or an example’s title, opens actions on the whole program: saving it as My Draft, opening or downloading a file, and resetting it. More options contains word wrap, the theme selector, documentation, and Keyboard shortcuts. The status bar shows whether your work is saved, how the last run finished, and the cursor position. Screen readers hear when a run finishes, but not each autosave while you type.
| Action | Windows and Linux | macOS |
|---|---|---|
| Run program | Ctrl+Enter |
Command+Enter |
| Stop program | Shift+F5 |
Shift+F5 |
| Open command palette | Ctrl+K, Ctrl+Shift+P, F1 |
Command+K, Command+Shift+P, F1 |
| Show or hide Results | Ctrl+B |
Command+B |
| Show or hide Problems | Ctrl+J |
Command+J |
| Save or offer Save as My Draft | Ctrl+S |
Command+S |
These shortcuts work in the editor and main workspace. While a dialog is open, only the command
palette shortcut is handled by the playground. The editor also provides Find, Undo, comment
toggling, and selection of the next matching word; Keyboard shortcuts lists their keys. To make
Tab move focus out of the editor, press Ctrl+M on Windows and Linux or Ctrl+Shift+M on macOS;
the status bar shows Tab moves focus while that mode is on.
Run And Stop
Section titled “Run And Stop”Choose Run or press Ctrl+Enter on Windows and Linux, or Command+Enter on macOS. The open
file is the entry point. The Run tooltip names it. Stop terminates the execution worker and
keeps any output already printed. Shift+F5 does the same. Focus moves to the Run button when
you stop with the button. Pressing the Run shortcut during a run stops that worker and starts the
latest source revision.
On desktop, code stays on the left, with Problems below the editor. Results opens on the right with Output above Trace. Drag the divider between them or focus it and press the arrow keys to resize. That size is saved in this browser. Select either section’s heading to fold it and give the other section more room. The Results button beside Run shows or hides the whole pane.
On phones, use Code, Output, and Trace to switch views. A run opens Output and switches to Trace if the program finishes without printing or drawing. Before the first run, Results shows the Run shortcut and links to Examples and the tour. Dismiss the hint to hide it.
Analysis runs in a separate worker and diagnostics keep updating while your program runs. After you edit the code, both sections dim and show Edited since this run. Run again to refresh them.
Output
Section titled “Output”Output streams text, charts, and windows in program order. On desktop, Output grows with its content and scrolls when it runs out of room. The default layout reserves at least 40% of Results for a recorded Trace. Use Copy output to copy the text with a label for each chart or window. Clear output clears this section while keeping the run’s trace and diagnostics.
Printing a plot figure draws a chart that follows the playground’s theme. Hover a bar or point to see its value. Use the chart’s buttons to enlarge it or download an SVG named after its title.
A raylib window uses its original size when there is room. The canvas can shrink to half size to fit the width. Scroll Output if the window still needs more space. Click the canvas to give it the keyboard, and press Tab to move focus out. Escape or the window’s close button asks the program to close it. Stop ends the run.
While a raylib program runs, the canvas updates and Trace follows the drawing loop. After the window closes or the run ends, select a Trace round to see its frame with the two previous frames faintly overlaid. Use the slider, its arrow keys, or the previous and next buttons to move between frames and update the Trace selection. Output shows the saved range, and a dot marks each Trace round with a saved frame. The playground keeps the last 240 frames of the run. If you select an earlier round whose frame is gone, you can jump to the first saved round.
Raylib windows need shared memory, which browsers give to cross-origin isolated pages. The
playground is served with Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers.
The playground limits each run to 100,000 attempted commit rounds and 1 MiB of output. Source files and shared payloads are limited to 256 KiB. A figure counts toward the output limit by the size of its data.
Trace identifies the function and while statement that ran. The Go to line button reveals that
loop in the editor and opens its source file when needed. On phones, the line button also switches
to Code. Closing Results preserves the selected execution and scroll position. If a run fails
inside a loop, Trace opens on the failing loop’s Error row and the editor marks the source of
the error.
A round marker such as r12 beside a printed line, chart, or window opens the round that produced
it. Select a Trace row to highlight and reveal its output. Output from outside a commit round has no
marker.
Variables form columns and successive states form rows. The ungrouped columns show values at the
start of each round. Within round contains local calculations. cond shows T to continue or
F to stop; the Exit row marks termination. If the loop exits before a round, its calculation
cells show —.
Use the loop picker to choose a source loop and Execution to distinguish repeated executions of that same loop. A parent row’s Nested loops links open the inner executions it ran. The Parent link returns to that enclosing round and selects its row. Nested state columns retain the prime marks used at that loop boundary. Function traces also show the argument values and source line for the call that produced them.
Guards using primed values also show Proposed state so the condition can be understood. An F
row rejects that proposal and retains the current state. A notice identifies nested executions whose
changes were rolled back by an enclosing loop.
Format trace values
Section titled “Format trace values”Trace values use Pretty formatting by default. Numbers show at most seven decimal places, with very small non-zero values shown in scientific notation. Pretty formatting applies recursively to lists, tuples, sets, and dictionaries, so floating-point noise is also removed inside containers. Nested or long containers use multiple lines. Use Show raw values when you explicitly want the exact Nilakan representation; it replaces the formatted values rather than showing both versions.
Each variable heading has a configuration button with three modes:
- Pretty uses the default formatting described above.
- Raw always shows that column’s exact Nilakan representation.
- Custom evaluates one JavaScript expression for each recorded value and displays its result.
A custom formatter is only an expression: there is no function declaration or return statement.
For example:
value.toFixed(2);The following values and helpers are available:
| Name | Meaning |
|---|---|
value |
The current value, converted to a convenient JavaScript type. |
kind |
"number", "boolean", "string", "list", "tuple", "set", "dict", or "error". |
row |
Row context with column, iteration, and phase ("current", "proposed", or "temporary"). |
pretty(value) |
Applies the normal recursive Pretty formatter to a value. |
number(value, places) |
Formats a number with at most places decimal places; the default is seven. |
Nilakan numbers, booleans, and strings become their JavaScript primitive equivalents. Lists and
tuples become arrays, sets become Set objects, and dictionaries become Map objects. Errors
become an object with name, message, and code. Use kind when an array might be either a
Nilakan list or tuple. The expression must produce text, a number, or a boolean.
Display a decimal as a percentage:
`${number(value * 100, 1)}%`;Join a flat list with arrows:
value.map((item) => number(item, 2)).join(" → ");Put each row of a list of lists on its own line:
value.map((row) => row.map((item) => number(item, 2)).join(" ")).join("\n");Put each dictionary entry on its own line:
[...value].map(([key, item]) => `${pretty(key)}: ${pretty(item)}`).join("\n");The config panel previews the first three recorded values and offers Reset to Pretty. Custom formatting applies after execution stops. If an expression throws, returns an unsupported value, takes more than 250 milliseconds, or produces too much output, the entire column falls back to Pretty and displays a failure notice. The failed expression remains suspended until you edit and save it again.
Formatter settings are stored in this browser only. They belong to the local document and source loop, survive line insertion and guard edits, and are not included in share URLs. The Show raw values control temporarily overrides every column; Show formatted values restores the configured modes.
Custom formatters are trusted local JavaScript. Only code entered or already stored in your browser is evaluated. It runs in a disposable, time-limited worker so a loop cannot hang the playground, but it is not a security sandbox and can use APIs available to that worker. Do not paste formatter code you do not trust.
The table initially shows 100 rows plus the final recorded state. Use Show next 100 rows for more. Long containers show a structural summary and expand on demand. Extremely large values are explicitly marked as exceeding the display limit, and custom output is limited to 10,000 characters per cell and 100,000 characters per column.
Scroll within the table to read more rows or columns. Round and condition stay visible during horizontal scrolling. Expand a long value to read it in full. A failing round is recorded as an Error row with its last current state and its condition when the condition had already run. A value wider than 14rem ends in an ellipsis; its title and the expanded view show it whole. The trace keeps at most 5,000 events, so a long loop is marked “partial” and a notice says the trace shows only the first N rounds; the program itself runs on, so the round count in a round-limit error can be larger. On phones, the Round and cond columns narrow. Current shows the last known state. A dash means a value or condition was never recorded. If a run fails, Trace offers a View problems button.
Diagnostics
Section titled “Diagnostics”Monaco displays live Nilakan markers, hover details, error navigation, and supported quick fixes. The Problems bar under the editor shows the current count as you type. It stays folded while there are no current problems and opens when a problem appears, unless you folded it yourself in this session. Select a problem to reveal its source range. Open the bar to find diagnostics from a stale failed run in the Previous run problems section.
A runtime error also appears in Output after what the program printed or drew before it failed. Choose Go to line to reveal the error’s source. Syntax and check errors show Your program didn’t run when they prevent execution.
Multiple Files
Section titled “Multiple Files”The file bar above the editor has a tab for each file of My Draft. The new-file button adds a file;
its path is how other files import it, so shapes/circle.nlk is imported as shapes.circle from a
file in the same folder. New files start in the open file’s folder, and typing a trailing .nlk is
fine. The open file’s menu renames or deletes it. A dot on a tab marks a file with problems.
main.nlk comes first, then the other files by path. A tab shows the file name with its folder
beside it; the full path is its tooltip and accessible name. The mouse wheel scrolls the tabs
sideways, and with more than three files a N files button at the end of the bar lists every file
grouped by folder. The command palette offers the same actions and Go to for each file. See
Modules And Imports for import rules.
Run runs the open file. Diagnostics cover the open file and every file it imports. Problems names each problem’s file, and selecting one opens that file at the problem. Trace locations in another file name it and open it the same way. Each file keeps its own undo history and scroll position.
Shared programs and examples are single files. Save as My Draft replaces the saved draft with
the current program; you can then add more files. Open a file… adds the selected files (a notice
names them) when My Draft is open, and asks to replace the session when an example or shared program
is open. You can select several files at once. They are checked together, so if one has an unusable
name or the batch would exceed a limit, none are added. A file name that is not a valid module path,
such as my notes.nlk, is renamed to one that is, such as my_notes.nlk, and a notification names
it. A share link holds a single file, so Share is unavailable for a multi-file draft; download
the files instead. A multi-file draft keeps a clean address and reopens directly. A workspace holds
at most 100 files and 2 MiB of source.
Local Drafts
Section titled “Local Drafts”An ordinary playground URL opens the starter without saving it. When a local draft already exists, the playground shows when it was saved and the total number of lines. Choose Resume draft or Start fresh. Starting fresh offers Undo to bring the draft back. The first starter edit becomes the local draft and is then autosaved. Restored empty drafts are labeled as empty and offer direct starter and example actions instead of resembling a failed editor load. Once a draft is opened or edited, the address bar contains its exact source so copying the current URL reproduces the visible program without depending on local storage.
Word wrap, Results layout, and the draft editor view are stored locally as well. Shared snapshots and examples never overwrite that draft unless you explicitly choose Save as My Draft. Use Open My Draft to leave a shared snapshot or example without replacing the saved draft.
Draft saves across tabs use last write wins: the most recent save replaces the stored draft. A tab also saves its current draft when it closes. If browser storage fails, the editor shows an inline warning and protects against accidentally closing the page until saving recovers.
If a working copy cannot be saved, browser Back and Forward still navigate away.
Share Links And Examples
Section titled “Share Links And Examples”Share updates the address bar and copies a compressed URL containing the exact source. No
account or server storage is involved. Share URLs are immutable source snapshots. Examples use
readable ?example=<id> URLs while they still match the curated source.
Editing an example or shared snapshot replaces the current history entry with an exact-source share URL and creates a recovery working copy in the current browser tab. The program’s name then reads “(edited)”, and the status bar says Saved in this tab. Returning to the original route shows its canonical source and asks whether to restore the matching working copy or discard it and keep the original. Copying or reloading the exact-source URL restores the source directly from the address.
If the latest working copy cannot be saved, playground navigation returns to the current history entry and asks whether to stay, download the current source, or discard it and continue. Staying does not add or rewrite history entries, and choosing discard continues to the entry originally requested.
Browser and proxy URL limits vary. The playground rejects hashes longer than 32,000 characters and
offers a .nlk download instead. Invalid, unknown, ambiguous, or corrupted routes are removed from
the address bar before the starter or draft-resume choice is shown.
Files And Reset
Section titled “Files And Reset”The program’s file menu contains Open…, Download, and a reset action named for its origin.
Open… accepts .nlk and plain-text files that are valid UTF-8 and no larger than 256 KiB.
Download writes the open file’s exact UTF-8 source under its file name without formatting or
adding a newline. In My Draft, Open… adds the chosen file as a new file. Reset restores the
current session’s origin: the starter for a draft, the selected example, or the source originally
encoded by a shared link. Resetting a multi-file draft deletes its other files.
All destructive replacements require confirmation. Storage failures and recovery choices stay next to the affected playground state. Copying a share link and checking a draft’s save status also show brief notifications.
Reset and Start fresh offer Undo for 10 seconds. Save as My Draft and opening files over an example or shared program offer Restore if a draft was replaced. Restore previous draft in Commands also restores the whole previous workspace, including its folder paths.
Deleting a file offers Undo for 10 seconds, restoring its path and contents. Renaming a file preserves its editor undo history and view position.
Renaming an imported file offers to update its import paths and qualified uses of unaliased modules. The confirmation counts both imports and references, for example Update 2 imports and 1 reference. The delete dialog lists the files that import it. Imports are relative to each importing file’s folder; a move outside that folder cannot be rewritten automatically. Aliased module uses keep their alias.
Use Download all files (.zip) in the file menu to save an entire multi-file draft, including
folder paths. Recovery downloads after a local save failure also include all files. Single-file
downloads suggest the full path; browsers may replace / with _.
Closing a dialog returns focus to its opener, or to the editor when the opener is gone. Workspace shortcuts use physical keys so they work with Malayalam and Devanagari layouts, and do not fire while an input method is composing text.
The editor colours matching bracket pairs, shows bracket and indentation guides, and keeps the
enclosing function’s def line visible with sticky scroll. Use Ctrl+G (⌘G on macOS) to jump
to a line.
As you type, the editor suggests keywords, built-in functions, and the names you can use at the
cursor. Inside a function that means its parameters and variables, functions including imported
ones, and imported modules; top-level and imported data are left out, because functions cannot read
them. After import or from it suggests the files you can import, and after a module name and .
it suggests what that module defines. Press Ctrl+Space to ask for suggestions.
Hover over a name to see its signature or type and where it is defined. F12, or Ctrl+click (⌘-click on macOS), goes to a definition, opening its file when it is in another file. Press Ctrl+Shift+O (⇧⌘O) to jump to a function or variable in the open file.
Use Ctrl+P (⌘P) for Quick Open: type a fuzzy file path, then use the arrow keys and Enter.
As in VS Code, a prefix changes its job: > switches to the command palette, :12 goes to line 12
of the open file (:12:5 adds a column), and @ lists the open file’s symbols. With an empty
query, recently used files come first. F8 and Shift+F8 visit the next and previous problem
across all files, wrapping at either end, and show the problem’s message.
The trace remembers whether it is open and its desktop width. Dragging keeps it at a readable minimum width. On phones the trace covers the editor without discarding undo history. Tap an unavailable Share or New file control to see why it is unavailable.
If the editor, results, or trace cannot be displayed, the playground shows Download your files and Reload in their place. Your files are kept outside that area, so the download still works.
Typing ( in a function call shows its parameters and type hints, including imported functions.
Commas advance the highlighted parameter; nested calls and collection literals keep their own
position. Press Ctrl+Shift+Space (⌘+Shift+Space on macOS) to show signature help.
Press F2 to rename a local variable, parameter, or function within the open file. Rename follows the binding, including named arguments and primed state references, and rejects reserved or clashing names. It does not rename imports or update other files; check importing files when renaming an export.
Use Shift+F12 to find a symbol’s references in the open file, using the same bindings as Rename.
Hover over a builtin such as print or len to read its signature and a short description.
After a value and ., method suggestions use a declared type or the shape of its initial literal
(including init values). Direct string and collection literals work too. Unknown receivers keep
all methods, with common collection operations first; the editor does not infer expression types.
After a definition or reference jump, Alt+Left returns to the previous location and Alt+Right goes forward. The editor keeps up to 50 jump locations; deleted paths are skipped.
Unclosed bracket diagnostics point to the opening bracket. Function-scope errors explain when a
value must be passed as a parameter, and name quick fixes name both spellings, such as Change
totl to total. See Diagnostic Codes for examples.
While you type, syntax squiggles on the edited line wait until you leave that line or pause for about 1.5 seconds. Semantic errors remain visible. Problems always lists the current diagnostics, including syntax errors temporarily hidden in the editor.
Builtin conversion signatures include recoverable results: for example num(value) -> num | err.
The optional filters on is_err are passed by name.