I Asked AI to Build the Same Feature in React and Plain JavaScript. The Difference Surprised Me

· Source: Artificial Intelligence in Plain English - Medium · Field: Technology & Digital — Software Development & Engineering, Artificial Intelligence & Machine Learning · Depth: Intermediate, short

Summary

An experiment compared an AI coding assistant's performance building a simple form feature in plain JavaScript versus a React setup. The plain JS version generated clean code on the first attempt, whereas the React version required three iterations to correct issues like missing imports, prop mismatches, and non-existent hooks. This increased friction in React is attributed to frameworks spreading logic across multiple files (e.g., component, validation schema, types, shared hooks), which forces the AI to infer conventions rather than "seeing" explicit logic. Additionally, React's flexibility in state management offers multiple valid patterns, leading the AI to make less predictable choices. The author notes that qualities beneficial for human teams, such as flexibility and distributed conventions, can complicate single-pass AI code generation.

Key takeaway

For software engineers or prompt engineers working with AI coding assistants on framework-heavy features, you should explicitly guide the AI to minimize ambiguity. Start by requesting the entire feature in a single file, then refactor it into your project's structure. Clearly state state-management choices and provide concrete examples from your codebase to improve accuracy. Always budget for a review pass, as the AI's initial output, especially with complex frameworks, is often a rough draft requiring refinement.

Key insights

Framework qualities beneficial for human teams can complicate single-pass AI code generation.

Principles

In practice

Topics

Best for: Software Engineer, Prompt Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Artificial Intelligence in Plain English - Medium.