r/codereview • u/Top_Marionberry_4413 • 17d ago
Spectre - A design-by-contract programming language with an explicit allocator-centric API that outperforms Zig by up to 6x on General Purpose Benchmarks
https://github.com/spectrelang/spectre
2
Upvotes
1
u/Angelvin_Pinheiro 15d ago
curious how much of that 6x comes down to arena allocation vs standard heap allocations in the baseline tests. It's really easy to accidentally benchmark the memory strategy rather than the language semantics itself
1
u/jazzmyne_Rebela 15d ago
how does the contract verification interact with custom allocators when an invariant fails mid-allocation? curious if you unwind and let the allocator clean up or just trap immediately.
1
u/DickBrainTime 16d ago
The design-by-contract and explicit-allocation direction is interesting. For the "up to 6x faster than Zig" result, the biggest thing I'd want as a reviewer is a reproducible comparison rather than one headline ratio. Could you publish the exact benchmark sources/harness, compiler versions and release optimization flags for both languages, plus the machine/OS and whether bounds/contracts were enabled in each build? Ideally the two versions should do the same observable work (including allocation/lifetime behavior and error checks), and each benchmark should report more than the fastest run: e.g. median and spread across multiple independent runs.
With an allocator-centric API, I'd especially separate time spent allocating/freeing from the actual algorithm, and show allocations, peak RSS and any custom allocator differences alongside throughput. A microbenchmark with a tiny hot loop can exaggerate differences caused by inlining or dead-code elimination; including a realistic parse/transform workload and one case where Zig is faster would make the result much more persuasive. I'm not claiming to have built or benchmarked this repo; this is what I'd check before interpreting the performance claim. Is the suite runnable in CI from a clean checkout, and are individual results available rather than just the maximum speedup?