Apps & websites

A pixel-art fixer ported from Rust to Bend with identical results

Astropulse had Claude convert their three-detector pixel-fixer to Bend 2 to test the new language's claims. All 18 test images gave the identical grid and decisions as the Rust core, at about 4x slower; Fable wrote a kernel generator just to keep it compiling.

View on X
450likes
14reposts
121saves
28Kviews
Made with
Claude Fable, Bend 2
Role
AI pixel-art tool maker
Posted
Astropulse@RealAstropulse

I was curious about the advantages/speed claims here so I put it to the test.

I had claude convert my entire python/rust pixel-fixer tool to bend.

Same algorithm: three grid detectors (autocorrelation + cepstrum, run-length lattice fit, self-similarity tiebreak) and the two-stage k-means repack that turns mushy AI "pixel art" into real 1:1 pixels.

Result: 18/18 test images give the identical grid, identical sub-pixel steps and the same consensus path as the Rust core. F32 only, no f64 in Bend, and it still didn't flip a single decision. The clean test image reconstructs pixel-for-pixel.

Speed: about 4x slower than Rust on the same box. Rust has rayon, rustfft and f64; Bend got ~2x from its fork-join on 6 threads. Honest number, not a blowout either way.

The conversion was a real fight though. Bend is affine, lazy and termination-checked: no loops, no mutation, no if, no mutual recursion. Every array read hands the array back, so a 3x3 median is nine chained continuation functions. Fable ended up writing a kernel generator and a topological sorter just to keep compiling. First port used lists everywhere: correct, but 3.6 minutes per image. Switching every pixel stage to Bend Arrays (~1 ns reads) made that 4.5 s. Two of the three real bugs were silent U32 wraparounds. Zero memory or concurrency bugs, which is the point of the language.

PROOF.bend gating the build is genuinely cool. Float math is opaque to the checker though, so the numerics could be wrong even if the 'laws' are correct.

What would make Bend great for this kind of work: f64, a shareable read-only array, loop/if sugar over what it already compiles to, checked integer arithmetic, and an FFT in the stdlib. With those it'd be a few hundred lines shorter and read like the Rust.

Highly recommend checking out Bend, its genuinely interesting and it will only get better I'm sure. Taelin is getting a lot of pushback now but I genuinely couldn't find a single false claim. It does what he says.

It's missing some things, sure, but it literally just got released. I didn't try the cuda path, since that would be a pain for the systems I use to run the pixel-fixer.

I'm really excited to see where this goes. The proofs and laws genuinely made this conversion easy. Just pointed fable pixel-fixer it and said to convert it from rust to bend.

View on X

More in Apps & websites