#The playground on your computer
elucid8 playground is the playground in a window of its own on your computer (macOS, Windows and Linux), from release 0.26.0. Unlike the playground in your browser, it runs on your own data of any size and keeps every version in folders that elucid8 run works in as they are. Describe what you want to compute and the program is written for you, start from an example, or write it yourself; then ask for any value at any point and see why it came out as it did.
It comes with the elucid8 command: pip install elucid8, or download it from the Download page (how to open it). On Linux it opens with the desktop build, which needs WebKitGTK 4.1 (sudo apt install libwebkit2gtk-4.1-0 on Debian and Ubuntu); the install command and pip install elucid8 give you that build where it can run (Where it runs).
#Starting it
elucid8 playground
The first time, it opens on a blank program, its name shown as New program in the top bar. Start in one of two ways:
- Describe what you want to compute: click the box at the top left, say it in plain words, for example "a running total of daily sales, and its 7-day average", and press Generate program (Shift-Cmd-Enter on macOS, Shift-Ctrl-Enter on Windows and Linux). The program is written for you and arrives in the editor, ready to run.
- Choose an example: Examples ▾, beside Generate program, lists 34 programs ready to run under their group headings, from The basics: a running total, step by step to A fraud check that can't wait: a deadline on a call, each with its data, its question and the description that writes it. Press one, or move to it with the arrow keys and press Enter. Choose The basics and the question reads Ask for
totalatt = 4; press Run query (or Enter in the coordinate box) and the answer saystotal[t = 4] is 14.
Then everything can be explored and changed: ask for any value, see its picture and Why?, edit the program, its data or the description. The Next: line under the answer says what to try next (Hints: on shows it; press it to hide it).
The window has a bar along its top: the program's name, New program, Open ▾, Settings and Help. Under it, on the left, are the description's box with Generate program and Examples ▾, then the Program and Data In/Out tabs, the editor, Update and the version line. On the right are the question (Ask for, the value, its coordinates and Run query), the answer with Why? beside it, and the Visualize and Trace tabs. Every part keeps its place from the first moment: what is not ready yet is greyed, with a line saying what will be there ("The answer will appear here."). In a narrow window, or at a larger text size, the two columns become one: the description, the question, its answer and its picture come first, and the program is below them; scroll the window to reach it.
To keep your work somewhere else, give the folder:
elucid8 playground --dir ~/work/elucid8
#Your projects
Each program you make is a project, a folder of its own; everything is kept in the playground's folder:
eLucid8/
projects/
the-basics/
program.el8 the program, as last updated
deploy.json where its data comes from, where its outputs go, and its question
data/ its data files
prompt.md its description
versions/ every version: 1/, 2/, 3/ …, each with the description it was made from
out/ what its outputs write
templates/ the examples, copied there the first time
- New program (Cmd-N; Ctrl-N on Windows and Linux) saves the program you have, with all its work, and opens a blank one:
new_2,new_3, and so on, each shown as New program in the bar. A blank program is not written to your folder until you put something in it. A program copied from an example takes the example's name: its folder isthe-basics, shown as The basics, and a second copy is The basics 2. - Cmd-S (Ctrl-S) saves the program as it stands at any time: the description as you typed it, the program in the editor, the question and every version. It makes no version and needs nothing to compile.
- Open ▾ lists your saved programs (it is greyed until one is saved): each with its name, how many versions it has, when it last changed, the example it came from and its description's first line. Type in Search to find one by its name or description. Press a program to choose it, then Open, Duplicate or Delete… (which asks first).
- An example is never changed. Choosing one copies it: into the blank program you have, or, when your program has work in it, into a new one, after yours is saved. Your edits change your copy only.
- Update (Cmd-Enter on macOS, Ctrl-Enter on Windows and Linux), under the editor, applies your changes: it checks the program, saves it as the next version and asks your question again with it. While you have changes not applied, the line beside it says Changes not applied, and Undo changes puts back the version you had. A program that does not compile is not saved: its first error is marked at its line and column, and the status line says where; Cmd-' (Ctrl-' on Windows and Linux) takes you there. After an update, the question, the Data In/Out tab and the picture follow the new program: a question that names a value the program no longer has is cleared.
- The version line under Update says which version you have and how it was made ("Version 1: as the example came"). From version 2, Undo brings back the version before, its program, its data and its description, saved as the newest version. Changes you have not applied are kept as a draft, and come back when you open the program again.
- Closing the window saves a program that has work in it. The next time, the playground opens it again as you left it, with its question answered; New program starts a blank one, and your other programs are in Open ▾.
- A project that runs other commands (a
deploy.jsonthat starts programs) asks you first, in the window, and runs them only if you allow it, for that project only. - A project keeps its results on your computer, in its own folder: it never writes files elsewhere or sends its output over the network, even when a description or its data asks it to. To write elsewhere or send results to a service, run the project with
elucid8 run, where itsdeploy.jsonsays so explicitly. - Each project is a deployment, so it runs with no playground; so does each example, in its folder under
templates/:
cd ~/eLucid8/templates/the-basics && elucid8 run
{"name":"total","context":{"t":4},"outcome":{"kind":"value","value":14,"ts":0}}
#Your data
To use your own data, copy the file into the project's data/ folder and name the input after the file: data/sales.csv is read by input("sales", t : 12). The Data In/Out tab lists the project's files, each with the input that reads it, and opens the one you choose in the editor under the list. A file of up to 10,000 lines and 1 MB can be changed there: press Update to apply the change as the next version ("your data changed") and ask your question again. A larger file is shown read-only, its first 200 lines, and is read whole when you ask.
#Asking and seeing
- Ask for holds the question: a menu of the program's values by name, then a box for each of the value's coordinates (
totalatt = 4). Run query (or Enter in a coordinate box) works it out with the program as last updated: the answer saystotal[t = 4] is 14, and beside Why? under it are its timestamp and the work done ("timestamp 0 ms · computed 5 values, read 5 data points"). Cmd-Enter with no changes to apply runs the query too. Choosing another value keeps the coordinates of the dimensions the two share. - Visualize draws the answer and the values around it. A value over one dimension is a line chart, with the point you asked marked; ▶ Play over t (the dimension's name), under it, steps the question from the point shown to the last, then stops; ◀ and ▶ step once, and ❚❚ Pause stops it. A value over two dimensions or more is a grid of coloured cells, up to 256 by 256, with its colour scale, its key, ◀ ▶ and ▶ Play beside it: data in colour, eod (no data there) in grey, errors in red. Over three dimensions or more, Axes: x × y ▾ and Play over: t ▾ choose the dimensions drawn and the one played. Press a point or a cell to ask for that value.
- Why?, beside the answer, opens the Trace tab on how the answer was found, as a tree: its top row is your question, and under each row are the values it needed, each marked computed, read from your data, or reused, with its outcome. Press a row, or use the arrow keys, to open or close it; its details are under the tree.
- A question stops after 60 seconds; Stop, at the end of the question's row while it runs, or Esc, stops it sooner.
#Writing programs from a description
Describe what you want in the box at the top left and press Generate program: the program, with a check you can work out by hand, arrives in the editor as the next version, and the box keeps your description. The line under the box says how it went ("✓ Written and checked: …"), and In plain words ▸ opens what the program computes, in plain words. With a data file chosen in the Data In/Out tab, the writer is sent its columns and first rows too.
Generate program always writes the whole program anew from the description, so to change a program, change its description and generate it again. The version before stays: Undo brings it back, with its description. Changes in the editor that you had not applied are kept first as a draft. When nothing compiles, Open it anyway puts the last attempt in the editor with its error marked, to fix by hand.
An example's description writes that example's program: copy it into a blank program and press Generate program to see it written. These are answered with programs written for them earlier, so they need no key and cost nothing. (Right after you choose an example, Generate program is greyed: its program is there already. Change the description to generate another.)
This uses Anthropic's AI on your own account. Give your Anthropic API key once: in Settings, press Add key… and paste it (on macOS and Linux), or give it in a terminal:
elucid8 key set
Without a key, Generate program opens a note with Add key… in it; the examples work without one.
It is kept in a file only you can read (key in eLucid8's settings folder) and sent only to Anthropic, and the playground reads it only when you press Generate program. Settings says whether a key is set, and Remove deletes it. Once you have spent something, the line under Generate program says what you have spent since you opened the playground (a session). Spending is capped at $2 a session and $5 a day unless you change it:
elucid8 key limits --session 3 --day 10
elucid8 key status
While a program is being written, Esc stops it.
Help opens the playground's help: what it does and its keys.
#Settings
Settings holds the playground's choices, one to a row:
- Speed: Use every processor thread, checked, runs your programs on every thread of your computer; unchecked, on one. A program may use up to half your computer's memory; one that needs more is stopped, and the status line says so.
- Text size: makes the playground's text, buttons and panes larger or smaller, from 80% to 250%. Anywhere in the window, Cmd-+ and Cmd-− (Ctrl+Plus and Ctrl+Minus on Windows and Linux) do the same a step at a time, and Cmd-0 (Ctrl-0) goes back to 100%. The window keeps its size and the playground's layout fits it, and the playground opens at the size you chose last time, all of it on your screen.
- Appearance: Automatic follows your computer's light or dark appearance; Light and Dark keep one.
- API key: Set or Not set, with Add key… and Remove.
#The playground's own program
The playground is itself a program in eLucid8, built into the command. To read it, or to run a changed copy:
elucid8 playground --source my-playground
elucid8 playground --program my-playground
Is it safe to run? says what the playground can do on your computer, and the Command reference gives every option.