Bilibili Downloader: Is AI Programming Really That Great?
"TLDR: This article explores the practical integration of the Rust language with AI-assisted programming, analyzing AI's performance at different stages of development through the creation of a Bilibili downloader project. In the early stages, AI efficiently resolved syntax and basic logic issues, but as code complexity increased, problems emerged such as insufficient context understanding, reinventing the wheel, and patch-style coding. The article evaluates Rust's learning curve, the value of AI tools, and the evolving role of software engineers, noting that current AI is better suited for handling well-defined and limited task scopes."
Rust: The "Genshin Impact" of the programming world. Some praise it as the essence of over two decades of human software engineering, while others disdain its chaotic community culture.
AI Programming: From Copilot to Vibe Coding, some believe the "silver bullet" of software engineering has finally arrived, while others see it as nothing more than frantic marketing driven by capital's need for funding and stock prices.
When these two fields collide, what kind of sparks will fly?
Bili_download
https://github.com/Rpeng666/bili_downloader
This is a Bilibili video downloader written in Rust, supporting danmaku, regular videos, and anime series (multi-episode) downloads, with excellent safety features (Rust's reflex, if you will). This kind of project has been implemented countless times on GitHub in various languages—Python, C#, Golang, TypeScript, and more. Why would I reinvent the wheel?
-
Rust is being hyped up immensely, and I wanted to take this opportunity to learn whether it's actually as good as claimed.
-
When filtering through Rust language projects, I noticed the number of related GitHub repositories is noticeably smaller—this could fill that gap.
-
I wanted AI to lead this programming process while I served as the software architect, putting AI programming's capabilities to the test on a complete project (time to see if it's a horse or a mule—bring it out for a walk).
Project Development Process
This section defines the scope for AI development, highlighting the key features to implement, to prevent AI from spiraling into endless divergent thinking.
-
Requirements Analysis: Need to support downloading different types of content (regular videos, anime series), support selecting resolution, and finally provide good error reporting.
-
Architecture Design: The whole system is divided into three parts (a parameter parser that reads user command-line arguments, a type parser that analyzes video type from URLs, a downloader that fetches video and audio streams, and a final post-processing module).
-
Key Feature Implementation:
-
Video parsing and retrieval (parsing out the type, whether it's Dash stream or Durl stream)
-
User login information
-
Danmaku download and processing
-
Multi-episode management for anime series
-
Concurrent download optimization
-
The Honeymoon Period Within 2000 Lines
Syntax Level
At the very beginning of implementation, models like Claude performed remarkably well. Many of Rust's confusing error messages and syntax that's unfamiliar to beginners were quickly resolved by AI. Additionally, AI wrote the reverse-engineering code for Bilibili exceptionally well. For instance, with certain HTTP status code handling, I didn't even know what status codes might exist, yet Claude directly provided all the enums and the final code.
For junior engineers, this kind of engineering code might be considered "grunt work"—you could get it done by consulting Rust documentation and Bilibili API docs, but it might take an entire morning. Claude finished it in just over ten minutes—truly impressive!
Pattern Design Level
Claude tends to provide implementable code directly in a procedural style, but rarely considers broader architectural and pattern design aspects. This results in code that works but lacks extensibility and maintainability. For example, when I asked Claude to implement a complex feature (video downloading), it typically provided a solution that was functionally complete but structurally monolithic, rather than considering how to break it down into smaller, reusable components, or how to leverage Rust's ownership system and type system for more elegant design patterns. However, even without using more reusable design patterns, these issues were still manageable within 2000 lines of code—manually fixing them kept things usable, so I'd grudgingly give it a thumbs up.
The Pain Period After 2000 Lines
At this stage, problems began to surface. As code volume increased, the model's contextual understanding noticeably declined. Claude started confusing the functionality of different modules, had vague memories of previously designed interfaces, and even forgot features we had already implemented. It's like asking a programmer with short-term memory issues to maintain an increasingly complex system—efficiency plummets. Specifically:
-
Possibly due to context window limitations, Claude forgot modules it had implemented itself, leading to reinventing the wheel across multiple files.
-
As the code grew more complex, Claude tended to write code that ran but performed poorly. For example, when facing complex asynchronous operations and error handling, it would simply use
unwrap()rather than properly handling potential error cases. -
Claude began writing more and more "patch-style" code, struggling to grasp the big picture, understand, and maintain the entire codebase. The AI-generated code exhibited a "fragmented" character, lacking coherence and unity, resulting in loose code structure and excessive coupling between modules. This patch-style programming significantly reduced code maintainability. Sometimes, to solve a small problem, Claude would introduce completely unnecessary complexity, ultimately leaving the codebase bloated.
Reflections
-
Rust Language Learning Curve and Value Assessment
-
Rust is indeed a good language, and AI can significantly lower the barrier to learning its syntax;
-
But it has far too much syntactic sugar, and when AI is given free rein, it's easy to end up with code that's hard to maintain. I feel AI pairs better with Golang—simple syntax, strong typing, and even fewer tokens consumed.
-
-
The Real Value of AI Programming Tools: Hype or Revolution?
-
Revolution: It dramatically speeds up code writing. Bugs that used to take half a day of documentation research are compressed into a few minutes.
-
Hype: Not to mention large projects, even in projects exceeding 2000 lines, AI is likely to go off the rails, continuously writing patch-style code, causing a 500-line feature to balloon to 1000 lines or more, ultimately reaching a point where AI itself can't understand it, leaving human engineers to clean up the mess.
-
In conversation, it's difficult to describe every possible angle of a feature point comprehensively before submitting it to AI, so AI tends to complete the current prompt's requirements in the simplest way possible—well, it did follow the instructions, didn't it?
-
-
The Repositioning of Software Engineers: How to Stay Competitive in the AI Era
- Syntax isn't the focus.
-
Code Quality Analysis: Security, Maintainability, and Performance of AI-Generated Code
- Security, maintainability, and performance are all difficult to control—it mainly depends on what the prompt described in that particular conversation. But who can describe everything so accurately in one go?