Is AI code generation actually new?
AI agents write most of the code now, but developers have been generating code for decades, and I did it with Yii's Gii. The value was never in the typing - it's in working out the right code to write.
Hardly any of the code I work on is typed by hand any more. I describe what I want, an AI agent writes it and I review what comes back, so if I need the model, controller and set of screens for a new database table in a Yii application, I ask for it in a sentence and it's written in seconds. It got me thinking about how long I've actually been getting tools to write code for me. I've been building web applications with Yii since 2010, and Yii has had its own code generator, Gii, for almost all of that time. It wasn't AI, but it did a surprising amount of the same job.
Haven't developers always used code generators?
From my own experience the answer is yes, starting with the oldest code generator of them all, copy and paste. Most business software is built around the same four jobs on a piece of data, adding a record, listing them, editing one and deleting one, which developers shorten to CRUD, and writing that code by hand for every table is repetitive enough that most frameworks have had a tool to generate it. Having a look around while researching this article, I found tons of them: Rails has its scaffold command and CakePHP has bake, and the idea goes back a good deal further than either of those. And if you didn't use generator tools, then simply copying a class and changing the class name and attributes saved a lot of painful repetitive typing.
Autocomplete in code editors has also been growing for years, in VS Code anyway, with plugins like PHP Intelephense, Pylance for Python and Tailwind CSS IntelliSense, which read the code you've already got and offer the next method or class name before you've finished typing it. Machine learning started creeping into autocomplete too, GitHub Copilot arrived in 2021, and from there it was a short step from finishing the line to writing the whole file.
What did Yii's Gii code generator do?
Gii arrived in Yii 1.1.2, taking over from the code generators in the yiic console. I definitely used yiic in the Yii 1 days, but whether I ever generated anything with it I honestly couldn't tell you - it was sixteen years ago. But Gii I did use. With Gii you design the database first, then point it at a table and it writes the "model" - that's the class the rest of the application uses to read and save that data. Then point Gii at the model and it writes the controller and a full set of screens to add, list, edit and delete those records. The model generator was the clever one, working out how the tables relate to each other, what counts as valid data and even what to label each field, all from the database itself. Over the years I used its model, CRUD, controller and form generators. Bootstrap UI being baked into views meant that you'd get a pretty good looking app (at the time!) for very little effort.
Gii generation could be customised, too. Every generator writes its code from a set of templates, and you could swap in your own so the output matched the way your team builds things, which is where I always suspected the real power was and never had the time to dig in. Customising it meant writing more code though, with PHP templates or even a generator of your own, and more often than not I didn't bother. By the time I'd switched the module on and filled in the form, I could have copied an existing model, changed the names and been halfway through the next one. It always felt like a powerful tool, and I had a feeling that if I could really go deep on it, without a client waiting for the software to actually get built, it would pay for itself many times over.
How is AI code generation different?
The biggest change is that the instructions are in plain English, so where customising Gii meant writing code, I now write a few lines of guidance on how we name things, which base classes to use and where the access control goes, and the agent follows them. I've found that with clear enough rules the output is about as consistent as a template.
An agent can also see far more than Gii ever could, since Gii knew one table and whatever was ticked in its form, while an agent can read the whole application, so it follows the patterns already there and carries on past the repetitive part into the business logic, the odd relation and the one screen that works differently from all the others.
It's quick, too, though I don't think the total time has changed as much as people think. The writing takes a fraction of what it did, but reviewing and testing what comes back takes a huge amount of time, so end to end a feature takes about as long as it used to. What's changed is how far that time goes. Automated tests that would often have been skipped under commercial pressure can now be written for every feature, because the agent writes them, and that makes an application more reliable over the years and cheaper to own.
The quality comes from the same place it always did, too. A software business output would be guided by its code review process and the principles its developers worked to. Now a lot of that lives in the harness the developer builds around the agent, meaning the rules it follows, the checks its work has to pass and what gets reviewed before anything is accepted.
What's still the developer's job when AI writes the code?
Gii could only start once the database existed, and designing the database was always the part I did myself. Before generating anything I'd be in a database GUI working out what developers call the information architecture: what the application needed to keep track of, like customers, orders or jobs, how those things related to each other, and what had to be filled in and what could be left empty. That design was what I handed to Gii. Get it right and Gii could write the relations, the rules and the forms for me. Get it wrong and it would generate a perfectly tidy set of files for the wrong application.
I think that's still mostly the human's job, even with an agent. It'll happily design the tables if I ask it to, but it only knows what the business does from what somebody tells it, and working that out means sitting with the people who'll use the thing and understanding how they actually work.
Developers have always reached for tools that write code for them, from the 4GL generators through Gii to the agents we use now, because the typing was never the valuable part. If you're paying for software to be built, the part worth paying for is working out the right code to write, the code that solves your actual problem and gets you the business outcome you were after, and most of that work happens before anything gets generated. It's the same thinking that goes into deciding when to replace a spreadsheet with software.
As for Gii, it's still sitting in most Yii 2 projects as a dev dependency, and it still works, but I can't see many of us opening it again now an agent will do the same job from a sentence. If you're still on Yii 2, it has end-of-life dates of its own coming up, and my Yii development page covers what comes next.