plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
1597c83
— Peter John
2026-11-04T20:32:38+05:30
docs: backlog: decide whether traits are still needed (notes and benchmark evidence)
- docs/backlog.md +3 -0
docs/backlog.md
CHANGED
|
@@ -12,6 +12,9 @@ Open work, in the order the user queued it, plus smaller items found during buil
|
|
|
12
12
|
3. **Benchmark** before FBIP (user: FBIP waits for it).
|
|
13
13
|
4. **FBIP: no heap mutation** — persistent std collections updated in place when unique, Koka-style `fip` functions as a checked in-place guarantee, a reference count used only as a uniqueness check if static proof falls short. Worklist = the `mut` fields left today (see below). (Decision record §9.)
|
|
14
14
|
5. **One product type, `struct`** — after FBIP, merge `record` into an immutable `struct` with compiler-chosen boxing (optional hint, shown by `--explain`). (Decision record §9b.)
|
|
15
|
+
- **Decide: do we still need traits?** (user 2026-11-04, decide with this item and item 2, since traits are lowered through the same hidden-union machinery). Today traits are used only by `std/game/imperative/Scene` (`trait Actor`, 14 fields), `std/game/pure/PureScene` (field-less `trait Actor` for `Custom` nodes) and three examples. The functional scene, the kids' games plan and `../kam_plum` use none. Their unique job is letting std hold user-defined kinds (a scene tree of the game's own `Ship`/`Orb`) with static dispatch.
|
|
16
|
+
- **User's proposal:** make `Actor` a plain struct/record and let embedding give inheritance-like behaviour: a record that embeds another *first* is a subtype of it (`Walker` is an `Actor`, so it can sit in a `Slice[Actor]`), with `override fun` dispatched on the concrete kind. Today record embedding only copies (`a World is not a Stage`), so this means embedding becomes subtyping. That is the box-free trait layout (wasm-gc base struct + subtypes, `isSubtypedTrait`) applied to records, which would retire trait fields, `__get_`/`__set_` accessors and the boxed-trait path. Open: whether behaviour-only traits stay (Rust-style, no fields) or abstract methods on the base record cover them; what `==` means on a subtyped value (identity today); whether only first-position embedding subtypes (the rule today).
|
|
17
|
+
- **Performance evidence** (BENCHMARK.md, 2026-11-03 benchmarks, M3 Pro headed): at 5.8k nodes the three styles are within about 3% (imperative trait Scene 1.70 ms, pure 1.71, functional 1.75, draw-dominated). Boxed trait field reads from outside the trait cost a dispatch over every actor kind (about 30-40 ns vs 10 ns), which made `stress_world` (20k nodes, y-sort) +92%; the box-free subtyped layout brought it back to closure speed (1.10 vs 1.09 ms). So the proposal keeps the fast path. Method dispatch is still a `ref.test` chain whose cost grows with the number of kinds. Not measured: a functional-style 20k-node world (no culling or sort fixture exists for it) and per-frame allocation/GC of `State` at that size. Add a `stress_world_state_view` fixture to the benchmark item (3) before deciding.
|
|
15
18
|
6. **Deterministic games** — fixed timestep, input recording and replay, seeded `Random` in game state, state checksums; port the design from `../kam_macroquad` (`main.rs` tick accumulator, `game/replay.rs`). The `Io` capability makes recording and replaying host input straightforward. (Decision record §10.)
|
|
16
19
|
7. **Kids' games (ages 4-7)** (user 2026-11-04: LAST, after all the refactoring is done) — review plan `docs/plans/2026-11-04-kids-games.review.md` (written, NOT approved; re-present for a fresh human approve). Seven functional-style games in `plum-examples/games/functional/kids/`: Balloon Pop (tap), Bunny Hop, Letter Bubbles, Caterpillar, Color Piano, Star Rocket (gentle Orb Run), Hoppy Frog (platformer); nothing can be lost. Draft `balloon_pop.plum` exists (untracked) and is blocked by the `List.length` bug below. Re-check the plan against the post-refactor APIs (explicit generics, `Io` primitive, crate paths) before approving.
|
|
17
20
|
|