I think the reason they're useful for writing code is that there's a third party - the parser or compiler - that checks their work. I've used LLMs to write code as well, and it didn't always get me something that worked but I was easily able to catch the error.