> the resulting code is always terrible, full with really obvious bugs and buckets of trivial security issues
That's pretty much the same as what you got from old school stackexchange. The LLMs are trained on poor example data (e.g. from stack exchange) and I presume it is a hard problem to filter for just the "good" training data.
Stack exchange answers make up a tiny fraction of LLM training data. They've dumped the source of every open-source project on the internet into those things. They've been trained on plenty of high-quality code; the trouble is that all that can teach is imitation.
The why behind a design decision is something an LLM can't understand simply by being fed the decisions themselves. Hence, though they often stumble into the right answer, they only ever do so because it "seems right based on context," and so they can easily apply a principle correctly one moment and then misuse it the next.
That's pretty much the same as what you got from old school stackexchange. The LLMs are trained on poor example data (e.g. from stack exchange) and I presume it is a hard problem to filter for just the "good" training data.