{"slug": "rewriting-code-with-ai", "title": "Rewriting Code With AI", "summary": "A developer used AI agents Gemma 4 12B and Qwen 3.6 35B to rewrite Rust code without doc-comments, but found direct rewriting unreliable. Instead, the developer had Qwen 3.6 generate a Python script that successfully rewrote 43 Rust files, missing only about 20 multi-line function cases, concluding that using an LLM to write a script is more reliable and faster than direct code rewriting.", "body_md": "It has become **trendy** to **rewrite code** using **AI agents**. In my ongoing quest to become more trendy myself, I decided to try to fix a nagging issue in my Rust code base. I had written the Rust code without doc-comments; for some reason I just used inline comments instead.\n\nI tried to use Gemma 4 12B and Qwen 3.6 35B to **rewrite** the code **directly**. With recent changes in `llama-cpp`\n\n, this worked fairly well, but files were too large and the AI agents made mistakes.\n\nEventually, I changed my approach.\n\n• I had Qwen 3.6 generate a Python script that would perform all the rewrites.\n\n• The script, as Qwen 3.6 wrote it, used line-by-line parsing of Rust files to move comments and edit them.\n\n• The script worked correctly on all 43 Rust files, although it missed about 20 multi-line function cases.\n\nThis task made me realize that using an LLM to **rewrite code directly** is not always the best approach. Instead, it might be better to have the LLM write a **Python script** that rewrites code files. This may be more reliable, and much faster.", "url": "https://wpnews.pro/news/rewriting-code-with-ai", "canonical_source": "https://www.dotnetperls.com/2026_7_13_rewriting-code-ai", "published_at": "2026-07-13 07:00:00+00:00", "updated_at": "2026-07-20 15:27:39.204267+00:00", "lang": "en", "topics": ["large-language-models", "ai-agents", "developer-tools"], "entities": ["Gemma 4 12B", "Qwen 3.6 35B", "llama-cpp"], "alternates": {"html": "https://wpnews.pro/news/rewriting-code-with-ai", "markdown": "https://wpnews.pro/news/rewriting-code-with-ai.md", "text": "https://wpnews.pro/news/rewriting-code-with-ai.txt", "jsonld": "https://wpnews.pro/news/rewriting-code-with-ai.jsonld"}}