Post

I've been in the deep end on the Radiance AST -> IR lowering pass, but I'm starting to see the light of day. I did things a bit differently this time in terms of code production, and I'm not sure it was worth it: I had Claude generate this compiler pass from scratch, which resulted in...

... a 6000 LOC Radiance module which I've been reviewing and simplifying for the last two weeks. The code it generated is mostly correct and well tested, but I've been able to reduce it to 4300 LOC while keeping functionality intact and simplifying things that could be simplified. It's been...

... an interesting exercise. Could I have written this myself in less time? Maybe, I'm not sure. The biggest issue with getting Claude to write code like this is that it doesn't *think*. For instance, it's happy to work within the given constraints without asking "why do these constraints exist?" --

Sometimes, adding 10 lines of code in another module (something it wasn't instructed to do) would allow for removing 50 lines in the module it was working on. It's not clear whether this is solvable via prompting due to unknown unknowns at the time of prompting.

Another issue is that it seems to forget code it's written, so it doesn't diligently factor out similar behavior the way a human would. You would think that it's good at noticing patterns in the code, but it isn't, even when specifically prompted to review its code and simplify it...

I've done multiple passes (and even with Gemini 3), essentially asking it to find patterns and factor them out, or maximize code re-use, and yet through manual review have noticed dozens of obvious simplification opportunities it did not point out to me. This is quite unfortunate.

0 reposts0 likes

It does seem like focusing specific code leads to better results, eg. if I ask it to simplify the function `lowerFieldRef`, it would find opportunities to simplify the code which it wouldn't if I asked it to do that for a set of functions which includes that one.