How Cresset compares
Cresset is young and these comparisons are meant to be fair, including where other tools are the better choice. If something here is wrong, please say so.
The idea in one sentence
Most languages let any code run anything. Cresset makes what each function may touch part of its signature, checked before the program runs and again while it runs, and lets you hand each imported package only the permissions it needs.
Permissions in other tools
| Where permissions are decided | Granularity | |
|---|---|---|
| Python, JavaScript (browser aside), Ruby, Go, Rust | Nowhere: any code you run can usually read files, use the network and run programs | None. You trust everything you import |
| Node.js permission model | One set of flags for the whole process, such as which folders may be read | The whole process, including every package you load |
| Deno | Flags like --allow-read and --allow-net, optionally limited to certain paths and hosts | The whole process: a dependency you import gets whatever the program was granted |
| Browser extensions, mobile apps | A manifest the user approves | One app or extension at a time |
| Cresset | In each function's needs list, and on each use line for a package | One function, one package |
The difference that matters is the last column. With a process-wide flag, giving your program --allow-net because your code needs the network also gives it to every library you depend on. In Cresset, a package gets only what you write on its use line, and a package can never pass on more than it received.
Effect systems in other languages
Cresset's idea has a long history, and the languages that explore it go further than Cresset does:
- Koka, Eff and similar research languages track effects in the type system, including effects you define yourself, with handlers that give them meaning. They are far more expressive than Cresset. Cresset trades that power for a short, fixed list of effects (
print,input,env,read,write,network,time,random) that a beginner can read at a glance. - Haskell marks effectful code with the
IOtype, which is a similar discipline: pure functions can't do I/O. Cresset aims for the same property with a Python-like feel, and lets you say which kind of effect. - Unison has abilities, a close relative of effects.
- Roc gives programs capabilities through the platform they run on.
If you want to explore effect systems seriously, those are worth your time. Cresset's bet is narrower: that a small, fixed, enforced permission list is enough to be useful and easy to learn.
What you get that others don't (today)
- Permissions you can read.
fn total(path) needs read:tells you, in the signature, what a function can reach. - Per-package grants.
use files from "files.crs" allow readhands one package one permission. - Record and replay. Time, randomness, files, network and typed input all pass through the declared permissions, so a run can be recorded and replayed exactly.
- Seeded randomness with no permission.
rng(seed)repeats exactly, from the seed alone. - A local redaction tool for removing secrets from text before you share it.
What you give up (today)
Be honest with yourself about these before choosing Cresset for anything that matters:
- It is an interpreter, and a young one. It is written in JavaScript and runs your program by walking a tree of pre-built steps. That is far slower than a compiled language, and it has had a small fraction of the tuning that mature interpreters have had. For heavy computing, use something else.
- Small ecosystem. There is a small official registry of pure packages and no community of authors. Almost everything you need, you will write.
- Few tools. There is a formatter, a REPL, a test runner, a language server and a VS Code extension, but no debugger, profiler or package manager UI.
- The permission list is fixed. You can't define your own effects, and
read, for example, doesn't say which files. - No concurrency, no native binaries, no foreign function interface.
- It can't protect you from everything. Permissions limit what Cresset code can do through Cresset's own functions. They are not an operating-system sandbox, and you should not run hostile code on a machine you care about just because it is written in Cresset.
When Cresset is a good fit
- Learning, and exploring what effect-checked code feels like
- Small scripts and tools where you want to see exactly what each part touches
- Running a helper someone else wrote, with only the permissions you choose
- Simulations and games that need exact, repeatable randomness
When it isn't
- Anything performance-sensitive
- Anything that needs a large library ecosystem today
- Anything where you need a hard security boundary rather than a language-level one
Next
The honest list of what is missing: FAQ and limits.