Learning Programming by reading senior's code
Posted by Impossible_Recipe758@reddit | learnprogramming | View on Reddit | 16 comments
as said in the tittle, i've heard it from some professionals that we learn a lot when we read code written by seniors. i'm stlll a student and don't have job or internship rn so i have never done reading any senior's code but now i'm willing... i know i can through open source projects etc
but my question now is that: is it same for the code written by AI? like if i go through the code of some app made by any AI like Claude, KIMI etc?
Neat_Fisherman9331@reddit
Reading AI code is kinda different experience than human senior code tbh. AI usually writes very clean and predictable patterns but it lacks the "why" behind certain decisions that you get from experienced developers
Senior devs will leave comments about edge cases they discovered, weird workarounds for specific bugs, or architectural decisions that came from years of maintaining similar systems. AI just follows best practices without that context of real world pain points
I'd say do both - AI code is good for learning clean syntax and common patterns, but reading actual senior code in open source projects will teach you more about problem solving and dealing with legacy systems
MM4Tech@reddit
Are you sure all open source code is human written?
desrtfx@reddit
Anything older than 6 years, definitely, yes. And this makes the vast majority of open source code.
Further, already very many open source repositories outright forbid the use of AI, even for PRs.
desrtfx@reddit
No, absolutely not. A senior knows what they are doing and can reason with understanding about everything they wrote.
AI is just a statistical model that chooses the "best fit" according basically to probabilities. It has zero understanding of programming at all.
Also, just reading others' code will enable you to write it, as reading and understanding books will enable you to write a meaningful, fully developed, comprehensive novel. It won't.
It can improve your skills by giving you new "tools" and "tricks", but that's about it.
You first and foremost need to write code in order to improve, just like an author needs to write a boatton of bad books before they can eventually write a good one.
hyper4saken@reddit
Don’t just read senior developers’ code and expect to learn automatically.
Try to understand the logic—what problem they are solving, how they are solving it, and why they chose that approach.
If you don’t agree with it, try to think of a better solution yourself.
Digital-Chupacabra@reddit
Can you learn something? sure probably. Is that something worth learning? Probably not.
Why read slop in an effort to learn instead of any of the countless well regarded and well written projects out there?
MM4Tech@reddit
You mean the open source projects, right?
Digital-Chupacabra@reddit
Mainly yes, but there are also some source available projects that are great to learn from as well.
MM4Tech@reddit
Example? Or any source name
Digital-Chupacabra@reddit
here is a whole list
high_throughput@reddit
In my experience, AI currently writes intern level code.
You can definitely learn things from interns, especially when it comes to basic syntax and usage of unfamiliar APIs and such, but I would not want to study the architecture and approach.
Stefan474@reddit
It really depends how you direct it imo.
If you let it go wild with no elaboration it'll suck most of the time, but with a decent prompt if you know what you're doing you can get great code.
high_throughput@reddit
Of course also true for interns
InfectedShadow@reddit
This is my experience as well. When I started a portfolio project to show my usage of AI in architecting an application and gave it the instructions of using DDD, SOLID, VSA, unit and integration testing it produced code that I considered fairly good.
HashDefTrueFalse@reddit
What would the point would be? You want to read code from good programmers. You've pointed out where you can read code written by good programmers as part of real, battle-tested projects. Is there any point generating even more code, which may be of dubious quality, when you can just read some reputable codebases? I'm not aware of any well-established, well-reputed projects that have been LLM-generated that are known for having good code, but there are many such open source projects.
IME LLMs generate very average code. Most of the time it compiles. Some of the time it does what you want. Almost never is it the best way to do whatever you wanted. You can usually improve it, and you are often required to. Architecture what? In a vacuum you might consider small pieces good enough but collecting too much of it together would make for a pretty terrible codebase to subsequently read through. I wouldn't point beginners to anything like that to learn how programming should be done.
ShoulderPast2433@reddit
We learn by reading existing code, yes.
But not just by reading projects - this will not work as a learning method.
We learn by reading codeine context of our task - we know what we have to do so we try to find a way how to attach it to existing structure.
Or we need to find how something works so we analyse it's code.
Just reading open source projects will not give it to you.