The most dangerous tool you can give to an AI is not a space laser. It’s something it already has access to, something that is inert to it, and the most dangerous weapon ever built by humans: Natural language. It cannot vaporise you from space, but it enables the AI to lie, cheat, make mistakes, and pitch bad ideas to you. One thing I have learned in decades of software development and long before AI is that comments lie, code doesn’t. It’s because comments are written in natural language. Natural language doesn’t need to “work”. It cannot be formally verified. Code can and MUST be formally verified by a compiler, it can be tested, and at the end of the day, it either works, or it doesn’t. Of all the ways I’ve tried (with mixed success) to control AI to write better code (and to clean up after it, AI assisted or manually, when it doesn’t), the most successful guardrails and harnesses were those written in code itself. And, ironically, some of those frameworks I’ve built that eventually made AI write better code were designed “by” or with the help of AI. Another irony is that no programming language I’ve ever used does this better than C++, with its strict type system and Turing complete generics. C++ is commonly considered as an “unsafe” language. You would think it’s the closest thing to a space laser among programming language when you hook it up to AI. The opposite is the case. C++ lets you build the strongest guardrails, not just red tape in markdown files. I have come up with ways to make certain kinds of AI slop and shortcuts literally not compile. The work I’m the most proud of is an entity component system (ECS) for a game with strict contracts that effectively makes it very difficult to store or pass around game state in any ways but the ones the framework allows (writing/reading components, pub/sub events, per frame snapshots, …). This makes it much easier to reason about where game state is and what modifies it, so you can safely run things in parallel and probably get some of the hard parts of multiplayer support for free (because you can generalise state replication). I can now prompt the AI to add (or design/spec) new game behaviors in simple natural language, and it will implement them in a clean way that fits into this framework without me having to explicitly tell it to, because designing within the framework IS the shortcut, and the easiest way to do things, and designing around it is nearly impossible (or at least very easy to catch in reviews, because the code required to do it goes way beyond adding some rogue pointer argument to a system constructor) And as a “bonus”, it not only makes the AI write better code, it also forces humans to code and design within the framework, because humans are no less prone to produce slop and take shortcuts. Humans may start with the perfect archtecture and gradually turn it into a mess when things just have to work, and they have to work fast. So the key to making AI write better code is to:
- Make the right way to do things easier
- Make all the wrong ways to do things harder or impossible (or easy to catch in reviews or detect mechanically)
- Build frameworks that formalize the patterns you want
- Build those frameworks into code, not just specifications or rules in natural language.
- If you have a choice (yes, I know, when do we ever?), pick a programming language with a strong type system. Failing that, at least use strong mechanical (non-AI) tooling for static code analysis. AI can fool people with language, but it can’t fool a mechanical tool, like a compiler, or a simple regex. This post was written by a human. I am not a game developer. I am a senior software developer who does boring web backend stuff for a living, and I treat making AI-assisted coding work for me as a “coding challenge”, because I’m being forced to. I see all the scepticism, fearmongering and failure stories from people in my industry as clear signs that AI isn’t going to take my job any time soon, but on the contrary, will make it more interesting. submitted by /u/EC36339
Originally posted by u/EC36339 on r/ArtificialInteligence
