frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

I wrote a ray tracer in Brainfuck

https://epestr.com/blog/writing-a-ray-tracer-in-brainfuck/
15•epestr•13h ago

Comments

throwaway99e2•11h ago
Isn't this just a ray tracer in python/c that spits out brainfuck? By this logic gcc writes all my programs in assembly lol
Retro_Dev•1h ago
Well the proper analogy would be that you write your programs in assembly. I think the more impressive thing here isn't the ray tracer, but the C (or was it C++?) to brainf** transpiler. That would be equivalent to you writing both C code and the C compiler. Pretty impressive, but depending on the complexity of the program not as impressive as writing whatever it is in assembly directly. A raytracer would be PAIN to write directly in brainf** - I think I'd want to use fixed precision everywhere rather than emulated floating point. (on second glance, it does look like the author of the article is also using fixed precision arithmetic, but confusing the label for the layout of the number with the type of number representation itself?)
epestr•3m ago
Pretty much, though the interesting bit is clearly the abstractions and work involved. Writing 22MB of code doesn't sound very maintainable :)
shoo•50m ago
brainfuck is unpleasant to write directly - e.g. the language doesn't have variables, so you need to manually do the bookkeeping of which memory offset is storing what 'variable'. & if you need to refactor your program slightly, in a way that changes the memory layout, maybe you need to manually rework the absolute & relative offsets. So I can appreciate why the author didn't roll up their sleeves to directly write BF - that's neither a productive nor interesting exercise.

Interesting to see how the author decomposed the problem:

- C raytracer https://github.com/mTvare6/rayfuck/blob/master/ray.c

~~ LLM refactor of the C code ~~>

- SSA-style C raytracer code https://github.com/mTvare6/rayfuck/blob/master/ray_ssa.c

~~ c2dsl.py helper script (compiler) ~~>

- DSL raytracer https://github.com/mTvare6/rayfuck/blob/master/ray.dsl

~~ dsl2bf.py helper script (another compiler) ~~>

BF raytracer https://github.com/mTvare6/rayfuck/blob/master/ray.bf (~22 mb of unreadable nonsense)

The dsl2bf compiler has a bunch of examples of implementing slightly higher level abstractions atop BF primitives. E.g. "go" to move the pointer to a different offset, destructive & non-destructive copies, all the way up to things like division -- BF only natively offers unary addition/subtraction.

If we have a read of the code of the final compiler, dsl2bf.py, the abstractions used in that code are relatively simple: global variables, local variables, lists, dicts, for loops, function definitions & function calls. It is feasible to implement a simple compiler like dsl2bf in BF itself, with sufficient head scratching. Again, quite unpleasant to try it directly in BF, but a next step could be to implement the dsl2bf compiler in the DSL itself - extending it if necessary, then compiling it with itself to produce a dsl2bf compiler implemented in BF.

epestr•9m ago
That does sound like a fun step, I'd already begun experimenting with some optimizations after having received suggestions in reddit to add fork/join primitives. Adding a compiler with these added performance gains sounds reasonable and something which will run quickly. dicts certainly involve some thought there.

I hadn't considered self-hosting the compiler, but having put it into works, I probably will.

This was the render the speed up version gave: https://paste.c-net.org/SpikingCarbs

Ollaya – Ollama for open-source, Jev-style decision models

https://ollaya.dev/
282•Ardakilic•4h ago•85 comments

Revealing the details of how OpenAI agents hacked Hugging Face

https://swarmtraces.org/
89•specked-citrus•2h ago•54 comments

Excel now supports multiple values in a single cell

https://techcommunity.microsoft.com/blog/excelblog/excel-now-supports-multiple-values-in-a-single...
46•luispa•2h ago•32 comments

What even is an OS now?

https://sockpuppet.org/blog/2026/09/25/what-even-is-an-os-now/
35•fratellobigio•1h ago•34 comments

Show HN: Jev Plays Pokémon Red

https://jev-pokemon.vercel.app/
114•pancomplex•9h ago•56 comments

Platform-independent SIMD in Go

https://go.dev/blog/simd-experiment
342•yurivish•11h ago•132 comments

Ask HN: Who's still keeping a DOS machine up because the business depends on it?

56•mlaux•3h ago•39 comments

Git-bug: Distributed, offline-first bug tracker embedded in Git

https://github.com/git-bug/git-bug
289•alentred•11h ago•94 comments

Tell HN: Codex Is Down

34•minimaxir•38m ago•13 comments

Gravity seems holographic. What does that mean for reality?

https://www.quantamagazine.org/gravity-seems-holographic-what-does-that-mean-for-reality-20260925/
95•ibobev•7h ago•95 comments

U.S. appeals court upholds designation of Anthropic as supply chain risk

https://www.cnbc.com/2026/09/25/pentagon-anthropic-ai-risk-appeals-court.html
348•cramer4next•8h ago•643 comments

First Principles Thinking

https://sunilsadasivan.com/writing/first-principles-thinking/
200•sunils34•9h ago•92 comments

Initial DIY Cleanroom Experimentation

https://www.jefftk.com/p/initial-diy-cleanroom-experimentation
11•luu•1d ago•2 comments

Remembering Johannes Doerfert

https://blog.llvm.org/posts/2026-09-24-rememberingjohannesdoerfert/
29•sdko•23h ago•1 comments

An airport cooled by natural ventilation

https://www.theguardian.com/environment/2026/sep/25/didnt-need-air-conditioning-airport-cooled-na...
12•Geekette•13h ago•10 comments

Show HN: Make math automatic with Mathy

https://gmays.com/making-math-automatic-with-mathy/
61•gmays•4d ago•12 comments

Loopjacking in A2A Implementations: Hijacking Human-in-the-Loop Approvals

https://adithyanak.com/loopjacking-in-a2a-implementations/
3•akoffsec•2d ago•0 comments

How video games inspire great UX (2019)

https://jenson.org/games/
84•andsoitis•5d ago•15 comments

Pentium II at 600Mhz with Voodoo 3 Emulated on 86Box with M6 Mac Mini

https://nyaa.sh/reviews/mac-mini-m6-emulation
262•hugh4life•16h ago•114 comments

Ink and Switch interactive homepage

https://www.inkandswitch.com/
221•iFreilicht•13h ago•25 comments

Alan Kay: Shannon gave us a way of dealing with noisy channels [video]

https://www.youtube.com/watch?v=Cjntrqhn8pk
108•behoove•4h ago•22 comments

Issues with Codex – Identified – Full Outage

https://status.openai.com/incidents/01M3DCNWMW57HYK8FJ5FBFPA39
18•xyzzy9563•25m ago•7 comments

Bwbach, My Guardian Goblin

https://robertmay.photography/journal/bwbach-my-guardian-goblin
20•robotmay•3d ago•14 comments

What happens when you analyze your favorite college football team like the CIA?

https://www.cultivatelabs.com/posts/what-happens-when-you-analyze-college-football-like-the-cia
28•adam•9h ago•17 comments

How we learned to stop worrying and love campus surveillance

https://fnl.mit.edu/how-we-learned-to-stop-worrying-and-love-campus-surveillance/
57•cdrnsf•3h ago•41 comments

Amiga Screens: A Primer

https://www.datagubbe.se/amscr/
125•msephton•15h ago•36 comments

Show HN: I discovered roads in the US across > 1000 themes

https://road-about-a-theme.pinedesk.biz/
7•91awebsi•7h ago•5 comments

Meta's Muse appears to use an OpenAI model labeled muse-special

https://mouse.dev/blog/muse-special/
95•Aeroi•5h ago•42 comments

Ask HN: Hypothesis: Cellular providers are deprioritizing voice calls?

10•tkdb•1d ago•19 comments

Show HN: Whiteboard (YC W26) – An open-source IDE for thoughtful software design

https://github.com/devdotfast/whiteboard
395•sidharthkmenon•1d ago•128 comments