Retrieved article excerpt
Open article · Retrieved 2026-11-03T12:24:04.160021+00:00
# iyi
[iyi](https://github.com/iyilang/iyi/actions/workflows/iyi.yml)
[licence](https://github.com/iyilang/iyi/blob/master/LICENSE)
[site](https://iyi.dev)
[packages](https://packs.iyi.dev/)
**A language built for Developer & Agentic Experience, Portability, Performance,
and Efficiency.** (*iyi* is Turkish for "good".)
Install the latest release into `~/.local` (Linux x86-64, macOS arm64;
a program built for macOS runs on macOS 14.4 or later, whose public
futex its collector's helpers sleep on - GC\_DESIGN.md, "darwin's helpers
park"):
```
curl -fsSL https://raw.githubusercontent.com/iyilang/iyi/master/install.sh | sh
~/.local/bin/iyi run ~/.local/share/iyi/samples/hello.iyi
```
On Windows x86-64, with the Visual C++ build tools installed
([Getting it](https://github.com/iyilang/iyi#getting-it) says why):
```
irm https://raw.githubusercontent.com/iyilang/iyi/master/install.ps1 | iex
& "$env:LOCALAPPDATA\Programs\iyi\bin\iyi.exe" run "$env:LOCALAPPDATA\Programs\iyi\share\iyi\samples\hello.iyi"
```
Those four are one design decision seen from four sides. A module is the unit of
compilation and it is compiled against its dependencies' **declarations**, never
their bodies — so a build reads less, a program carries less, a tool can read an
interface without a repository, and a person waits less.
| | measured today |
| --- | --- |
| **Developer experience** | edit one module in a 7,207-line project and rebuild: **0.13 s**, against Crystal's 1.17 s and `go build`'s 0.16 s |
| **Agentic experience** | `iyi mod context` hands an edit the exact surface of every import at **52–59%** of the sources' size, and a model writing against it spent **31–43% fewer prompt tokens** (`bench/context_pack.py`, AI\_FIRST.md §5) |
| **Portability** | an iyi program compiles for **nine targets** and is **run** on five of them every build: x86-64 glibc, x86-64 musl, aarch64 under emulation, wasm32-wasi under wasmtime, and aarch64-darwin natively |
| **Performance** | native code through LLVM, and a front end that answers `hello` in **0.034 s**. At run time the two libraries are within noise where they do the same work |
| **Efficiency** | that `hello` is a **36 KB** binary that starts in **1.6 ms**; the same program with Crystal's library is 1,553 KB and 3.2 ms |
**iyi is its own language, and it is compatible with
[Crystal](https://crystal-lang.org).** The same compiler builds `.cr` files,
`iyi build --crystal` gives a program Crystal's standard library, and
`require "kemal"` in an iyi file serves HTTP. A `.iyi` file also has rules
Crystal does not have and refuses things Crystal accepts, and those rules are
the whole of what follows. The compiler is built on Crystal's, which is
recorded in the [licence](https://github.com/iyilang/iyi/blob/master/LICENSE) and [NOTICE.md](https://github.com/iyilang/iyi/blob/master/NOTICE.md).
## The edit loop
One script writes the same program three times, in iyi, in Crystal and in Go:
**30 modules**, 10 types each, **7,207 lines**, and one `main` that calls all
thirty and prints the total. The benchmark changes a single number in one
function of one module, then rebuilds. One of the thirty, as iyi, with nine of
its ten types left out:
```
module parts/mod0
pub struct Widget0
@a : Int32
@b : Int32
def initialize(@a : Int32, @b : Int32)
end
def score : Int32
((@a * 3) + (@b * 5)) % 1000
end
def blend(other : Widget0) : Int32
(score + other.score) % 1000
end
end
pub def total0 : Int32
edit_point = 0 # the line the benchmark changes, then rebuilds
w0 = Widget0.new(0, 0)
(edit_point + w0.score + w0.blend(w0)) % 100000
end
```
[rebuild after one edit: iyi 0.13 s, Crystal 1.17 s, go build 0.16 s](https://github.com/iyilang/iyi/blob/master/doc/assets/edit-loop.anim.svg)
The bars run in real time, and `…` is `--use-iyimod mods --emit-iyimod mods`.
Drawn by the run that measured it: `python3 bench/incremental.py --svg doc/assets/edit-loop.anim.svg`.
The Crystal column is this same compiler under the one rule iyi drops. A
Crystal class is open until the last line of the last file, so no build may
trust anything it read last time, and every rebuild reads all 7,207 lines
again. Take that rule away and the line you just changed costs **9x less**.
`bench/incremental.py` refuses to start the clock until all three programs
print the same total.
The design is in [SPEC.md](https://github.com/iyilang/iyi/blob/master/SPEC.md), which records what was measured, what was
thrown away and why. Every number in this README names the command that prints
it.
**Where it loses, and what is young:**
- A full build of 6,912 never-seen lines is 0.24 s against `go build`'s 0.09 s.
- iyi's own prelude is the small-tool floor — `puts`, stdin, whole-file
`File`, `Program.args`/`.env` — and no more. Sockets, format strings and
TLS are opt-in modules (`import std/socket`, `std/format`, `std/tls`).
`std/tls` has not been audited and is not to be called secure until it is;
[SECURITY\_REVIEW\_TLS.md](https://github.com/iyilang/iyi/blob/master/SECURITY_REVIEW_TLS.md) is an automated review,
not that audit.
- Concurrency (`group`/`spawn`, `spawn_parallel`, `Channel`, cancellation;
SPEC.md III.4) runs on Linux (x86\_64, aarch64), macOS arm64 and Windows
x86-64, and not on wasm32. `spawn` keeps a task on the thread that
spawned it, taking turns with its siblings: the choice for work that
waits on sockets and channels. `spawn_parallel` runs it on the pool's
workers, one per core, for work that computes, and its block may capture
only `Share` values. std/http's `Server.serve` puts each connection on
the pool by default; `workers: 1` keeps a server on one thread.
- Dependencies resolve and pin (`iyi.mod`, `iyi get`, `iyi.sum`; SPEC.md
III.7), but there is no registry and no artifact distribution yet, and
`--crystal` still leans on shards.
## The program that makes the argument
A web framework's DSL, with the Sinatra feel intact. The library exports names.
The program picks which ones it wants unqualified. Nothing gets injected into
anybody's namespace.
```
module samples/webapp
import kemal/dsl::* # get, post, mount: because this file asked
import kemal/router::{Router, Context}
get "/" do |env|
"home"
end
get "/count" do |env|
42 # anything implementing IntoBody, not just String
end
users = Router.new
users.namespace "/admin" do |admin|
admin.get "/dashboard" do |env|
"dashboard"
end
end
mount "/v1", users
```
That file is [`samples/iyi/webapp.iyi`](https://github.com/iyilang/iyi/blob/master/samples/iyi/webapp.iyi), a port of
[Kemal](https://kemalcr.com)'s router, and it runs. Now add a route whose
handler returns something a body cannot be made of:
```
get "/bad" do |env|
[1, 2, 3]
end
```
```
$ iyi build samples/iyi/webapp.iyi
In webapp.iyi:33:1
33 | get "/bad" do |env|
^--
Error: Array(Int32) does not implement Kemal::Router::IntoBody, required by `B` in `get`
```
**Kemal cannot say this.** It accepts the same block and serves an empty body,
on every request, forever. Here the handler's return type is a type parameter
bounded by a trait, so the framework's promise is checked at the line where
the mistake is, by a module that has never heard of your types.
The same program also builds when the framework's source is not on the machine:
```
$ iyi build --emit-iyimod mods samples/iyi/webapp.iyi # writes kemal/router.iyimod, ...
$ rm -rf samples/iyi/kemal # the library's source, gone
$ iyi build --use-iyimod mods samples/iyi/webapp.iyi # builds, links, runs, same output
```
## What it costs, measured
The project from [The edit loop](https://github.com/iyilang/iyi#the-edit-loop), best of 7, release compiler,
one idle Linux box (AMD Ryzen AI 9 465 under WSL2, LLVM 19.1.7, Go 1.25.2),
seconds:
| what changed | iyi | Crystal | `go build` |
| --- | --- | --- | --- |
| **one module's body** | **0.13** | 1.17 | 0.16 |
| the entry file only | **0.12** | 1.15 | 0.16 |
| nothing at all | 0.12 | 1.14 | 0.08 |
| nothing cached anywhere | 0.61 | 1.97 | 3.09 |
| the same edit, *without* artifacts | 0.23 | — | — |
The last row is R-1 with a price on it: with all thirty modules read from
source the edit costs 0.23 s; with the `.iyimod` files in hand the other
twenty-nine arrive as declarations and it costs 0.13 s. `go build` from nothing
also compiles its own dependencies once, so its 3.09 s is a first build on a
fresh machine rather than a claim about Go's compiler. Seconds are a machine,
not a language: other sessions on the same box read 0.16 / 1.29 / 0.19 and
0.22 / 1.81 / 0.27 on the first row. The ratios hold.
The *nothing at all* row was taken before `iyi build` learned to stop when
nothing changed: it now reads back what the last build read, finds it all as
it was, and says `out is up to date` without compiling (`--force` builds
anyway). On the machine SPEC.md IV.3a measures that on, the row went from
0.60 s to 0.01 s, with `go build`'s at 0.04 s.
The full build is the row iyi loses. `python3 bench/build_speed.py`, same
session:
| program | iyi | `go build` |
| --- | --- | --- |
| `hello` (149 lines) | **0.07 s** | 0.08 s |
| generated pair, 6,912 lines | 0.24 s | **0.09 s** |
Both counts are `wc -l`: 149 for `samples/iyi/hello.iyi`, of which 44 are
code and the rest the commentary that makes it a sample, and 6,912 for what
`python3 bench/build_speed/generate_pair.py 300 <dir>` writes. The Go side of
each row is 11 lines and 6,016.
Compiling code it has never seen costs roughly 25 ms per thousand lines. The
front end alone is 0.034 s for `hello`, and 0.018 s of that is the process
starting up before it reads anything.
### A web server's cores (issue #145)
Issue #145 ported a web API to iyi and found it never used more than 1.8
of twelve cores, while its Go port used 11. `Server.serve` now answers
connections on a pool of workers, one per core unless `workers:` says
otherwise. The table below compares it with `workers: 1` and a Go twin
that answers the same bytes. It covers the issue's kinds of endpoint,
without the issue's database: a bcrypt login, a `check_version` that
answers a few fields of JSON, and an `order` that reads, totals and
sorts sixteen items of JSON.
It was taken with `bench/web_cores.py`: wrk with 4 threads and 32
kept-alive connections, bcrypt at cost 10, `serve` on 1, 2, 4,
8 and 12 workers, best of 3 runs of 15 s (login) and 5 s (the others).
The machine was Linux on a twelve-thread VM, with other work keeping
about 2 of its cores busy. Each cell is requests a second over HTTP, with
the server's CPU in brackets:
| | login | check\_version | order |
| --- | --- | --- | --- |
| iyi `serve`, `workers: 1` | 27 (100%) | 46,241 (112%) | 33,665 (113%) |
| iyi `serve`, 12 workers | **247** (1,032%) | 205,879 (631%) | **131,160** (697%) |
| Go net/http | 242 (1,033%) | **216,298** (528%) | 90,732 (538%) |
| *the issue's iyi: Windows, with a database* | *9.9* | *5,308* | |
| *the issue's Go: Windows, with a database* | *108.2* | *21,099* | |
The login is now as fast as Go's: bcrypt takes the same CPU per hash in
both, and the gap was the number of cores in use. Past four workers, the
light endpoints are held back by the load generator, and in this table's
iyi also by the collector's allocation lock, since split by size class.
SPEC.md III.4.13 has every worker count, HTTPS, the latencies, the profile
behind both claims, and the split measured again.
## The rules everything follows from
| Rule | |
| --- | --- |
| **R-1** | A module is the unit of compilation. `import` forms a DAG. Compiling a module reads its dependencies' **declarations**, never their bodies. |
| **R-2** | Everything a module exports (`pub`) writes down full parameter and return types. Unexported code infers as usual. |
| **R-2b** | `import X::{a, b}` brings exported names into unqualified scope, `import X::*` every