eternal
technology
Let's Talk

Thoughts on AI-Generated Code

A collection of reflections on methodology, best practices, and the future of software development with AI teammates.

Why should I include automated code generation practices in my team?

While incorporating automated code generation into a development team has a high degree of difficulty, the maturity of current tools makes it almost essential. It's often easier for a solo developer to adopt these practices than for an entire team to align on the same goal. However, several barriers can lead a team to frustration without achieving real improvements, especially on complex or long-term projects.

Success is not in the tools themselves but in how they are operated. AI is a sophisticated tool that requires experienced developers and a proper methodology. When implemented correctly, teams can see significant benefits:

  • Growing Efficiency: As the team gains experience and improves its methodology, good results become more frequent, reducing frustration and motivating further use.
  • Increasing Quality: By adopting practices like design, prompting, context preservation, and code validation, the generated code becomes more robust and efficient.
  • Enhanced Creativity: Good practices like brainstorming and quick concept validation open up new ways of building software.
  • Rapid Prototyping: Teams can generate low-effort prototypes that are easy to discard, aligning better with business needs.
  • Secure Code: Practices like automated checklists and code scanning help minimize common security risks.
  • Better Support: Automated generation of tracing and logging improves error diagnosis and correction.
  • Faster Learning: A team no longer needs to study every detail of a new library. It's enough to know the basics and use cases to guide the AI, which can then generate and even explain the code.
  • Leveling Up Junior Developers: Formalized practices help junior developers gain experience and skills more quickly.
  • Improved Documentation: Good automated documentation practices reduce dependency on specific individuals.

This process requires the guidance of someone with experience and a methodical, gradual approach to accumulate good practices.

Should I use AI for testing, documentation, code snippets or full code generation?

You can and should use it for all of them, but with nuances.

If your team works with mainstream languages and tools to implement standard architectures, incorporating AI at all levels will be easier. Conversely, if your team develops niche, low-level, or highly optimized solutions, using AI across all stages will be more challenging.

It's crucial to evaluate how, where, and why the team wants to use AI, considering any limitations of their specific use case. In all scenarios, a gradual adoption is the best strategy, mastering a few practices before moving on to the next.

What programming languages should I choose for AI-generated projects?

The simple answer is to use the languages that Large Language Models (LLMs) know best. LLMs gain their "experience" from sources like high-quality code examples, public repositories, official documentation, educational content, and discussion forums. Therefore, they are most effective with languages that are widely used, discussed, and documented globally.

Python is typically the language where LLMs have the most expertise, due to its prevalence in AI research and the vast amount of high-quality code available. Following the same logic, you can expect very low exposure to quality code for languages like Cobol, as it's a niche language and its quality code is not usually public.

For high-quality results and less frustration, consider this list:

  • Python: For backend (Django/FastAPI/Flask), scripting, Data Science, and ML pipelines.
  • JavaScript/TypeScript: For frontend (React, Vue), backend (Node.js), and full-stack applications.
  • HTML/CSS: For responsive design and modern features.
  • SQL: For query optimization and database design.
  • Bash/Shell: For automation and DevOps scripts.

You can also get good results with certain limitations using Go (for APIs, standard library use), but you should avoid complex multithreading patterns. For Java and C#/.Net, stick to traditional functional code and avoid modern frameworks. Before starting, always evaluate if AI is the right fit and choose compatible tools, but never disregard your team's current expertise. Learning a new language ecosystem takes a lot of time. A gradual introduction is always best.

Why isn't it a good idea (yet) to use AI for legacy projects?

The primary reason is that LLMs have more exposure to quality examples from modern, popular languages than from languages that were popular in the past. But there are other factors:

  • Availability of Libraries: Modern languages simplify logic by reusing high-quality libraries and frameworks, which makes programs easier to explain to the AI, generate, and validate.
  • Level of Abstraction: High-level languages like Python and JavaScript reuse the same development patterns across different industries. Low-level languages like C can have patterns as diverse as the domains they are used in.
  • Domain-Specific Knowledge: Low-level languages are often specialized. Modifying a Cobol program for a bank requires knowing specific banking regulations. Similarly, a Fortran program from a university might require understanding specific mathematical models. This is often compounded by a lack of complete, quality documentation.
  • Explicit Memory/Thread Management: Low-level languages like C or Rust might use complex patterns for memory management or thread synchronization where an LLM's training may not be sufficient.

Why is good software architecture a fundamental requirement?

A good software architecture is crucial when building complex projects with AI-generated code because it provides the structure and boundaries that guide the AI effectively. It allows you to break down a complex problem into smaller, self-contained, and well-defined units. For an AI, generating code for a small, isolated function with clear inputs and outputs is far more reliable and accurate than trying to generate an entire monolithic application in one go. A solid architecture acts as a blueprint, allowing an experienced developer to prompt the AI to create each component correctly, ensuring they all fit together seamlessly. It turns an overwhelming task into a manageable series of precise instructions, dramatically increasing the quality and maintainability of the final product.

Where AI-generated code can shine: From multithreading to message queues

For decades, systems have increasingly evolved toward asynchronous logic. While domains like telecommunications or developer tools require advanced multi-threading or non-blocking I/O, corporate software has seen a different evolution.

Decades ago, multithreading was common, but managing thread pools was complex and difficult to tune. The shift to non-blocking I/O patterns, famously exemplified by Node.js, simplified systems and drastically increased performance.

More recently, message brokers (like RabbitMQ) and asynchronous API solutions (like FastAPI) have further simplified asynchronous development for corporate solutions, allowing for modular, scalable, and distributed systems.

You should absolutely consider these modern asynchronous patterns for AI-generated code, especially in corporate software. Designing stateless services that leverage tools like caching (Redis) and message queues has several advantages that are highly compatible with AI code generation:

  • Better User Experience: Users get immediate feedback without waiting for long backend tasks.
  • Simplified Metrics and Scaling: It's easier to program automated actions based on queue length. Queues also help contain load peaks and manage priorities.
  • Better Isolation of Functionality: Working with smaller, self-contained logical units makes code generation easier. This also simplifies traceability and debugging, which is crucial for AI tools.
  • Easier to Automate: This modularity facilitates the integration of auto-checklists, self-correction mechanisms, and scaling tools like Kubernetes.
  • Technology & Security Isolation: A well-modularized system can use different technologies for different tasks and expose only the necessary services.

Analysis of Demo Projects

These demos reflect how to build a prototype to validate a business idea. They are of low to medium complexity but sufficient to show how a more complete version would be built, using production-ready asychronous patterns. All the code was 100% generated by AI, not a single line was written manually. The focus here is on functional aspects that can be extrapolated to other use cases.

AI Travel Planner

Web searches can be slow (5-100 seconds depending on the query), while API calls are much faster. The system is designed to minimize slow web searches. First, it performs a general web search to identify a destination's main themes and activities. An "inspirer" agent then creates varied and inspiring travel packages based on the user's request. When a user chooses a package, "researcher" agents use APIs to gather diverse tourist data. An agent then evaluates if this data is sufficient or if more targeted web searches are needed. Finally, a "curator" agent assembles the final itinerary, and a "writer" agent adds photos and descriptive text. The system uses complex, multi-step prompts and demonstrates the use of checklists to identify and correct potential LLM hallucinations in real-time.

FutureLearn School

This demo is a standard RAG (Retrieval-Augmented Generation) pipeline that answers queries about a specific body of knowledge—in this case, a fictional school. The implementation's strength lies in the information structure and prompt design. The way information is structured for a RAG system must be tailored to the specific use case. Key aspects include maintaining conversation context, knowing what information is available to deepen a topic, suggesting related topics, and choosing appropriate chunk sizes to enhance user experience. The bot is designed to understand context, offer relevant details about a course or instructor, and suggest related topics ("Do you want to know about the instructor?"). The prompt design also keeps the bot focused on its topic, handling off-topic questions or criticisms empathetically but firmly, always steering the conversation back to its purpose.

MovieLens Recommender

This demo addresses the "cold start" problem: what to recommend when you know little or nothing about a user. It uses two techniques. First, the user describes their taste, and the system performs a semantic search (based on meaning, not keywords) on a database of 90,000 movies to find initial matches. The user rates a few of these suggestions. In the second phase, the system finds other real users who also rated those same movies highly. It then recommends other movies that this group of similar users also liked, effectively inferring preferences without needing a large history from the new user.