iyi

Playground

samples/iyi/files.iyi

Files — the missing piece between a demonstration and a tool.

samples/iyi/files.iyi · iyi-files.wasm · 121 KB
# Files — the missing piece between a demonstration and a tool.
#
#   ./bin/iyi run samples/iyi/files.iyi
#
# Writes a file, reads it back, checks `exists?`, then deletes it and proves it
# is gone. The path is next to the process and named so it is obvious.

module samples/files

path = "iyi-files-sample.txt"
File.write(path, "hello from iyi\n")
puts File.read(path)
puts File.exists?(path)
puts File.exists?("iyi-files-sample-missing.txt")
File.delete(path)
puts File.exists?(path)
output
Press Run.

recorded with iyi 0.18.0 (built on Crystal 1.22.0-dev [2a9653052] (2026-10-18)) · Linux 7.0.0-38-generic x86_64, QEMU Virtual CPU version 2.5+ · 2026-10-19

You can type in the pane: nothing here compiles, so what you type cannot run, and the page says which bytes it is running the moment the text stops being the recorded file. There is no standard input, no filesystem and no threads on this target, and one sample fails on purpose for exactly that reason.

Run executes iyi-files.wasm, the module the compiler built from this file, in your browser. How this works

Try it on your machine

Copy the program into files.iyi, change something, and run it. Only a compiler on your own machine can run what you wrote.

sh, after installing
$ iyi run files.iyi