The glorious @xkcdRandom Zig builtin
Web page · https://ochagavia.nl/blog/the-glorious-@xkcdrandom-zig-builtin
First seen by Oriel on .
AI summary
The author adds an intentionally joke @xkcdRandom builtin to a Zig compiler fork, demonstrating how to modify compiler builtins and build the resulting compiler.
- The builtin returns 4, matching the xkcd Random Number comic rather than generating random values.
- The author chose a compiler builtin over a simple Zig function to learn how the language and compiler fit together.
- The compiler changes total 22 lines and are available in the author's fork on the 0.17.x-xkcd branch.
- A fresh Zig build took roughly a minute on the author's laptop, and the modified compiler successfully compiled and ran an example returning 4 for both usize and f32.
#zig #compiler development #random numbers
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Points
Score reported by the source.
- Lobsters: 65, latest observation ; +63 over observed period since
Comments
Comment count reported by the source.
- Lobsters: 8, latest observation ; +8 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| Lobsters | 5hoqzj | https://ochagavia.nl/blog/the-glorious-@xkcdrandom-zig-builtin/ Read discussion |