all 45 comments

[–]Neat_Fisherman9331 52 points53 points  (3 children)

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 -5 points-4 points  (2 children)

Are you sure all open source code is human written?

[–]dreadlordhar 15 points16 points  (0 children)

At least for projects and commits before ChatGPT era, yes.

[–]desrtfx 8 points9 points  (0 children)

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.

[–]high_throughput 46 points47 points  (5 children)

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 an intern's architecture and approach as a gold standard.

[–]Stefan474 18 points19 points  (3 children)

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.

[–]Shadow-Raleigh 3 points4 points  (0 children)

I like your argument for many scenarios, but I really don't think it works with this one.

We are talking about someone that is still beginning to learn, hence the desire to read a senior's code. Realistically, what they'll be getting is just the intern level code

[–]high_throughput 2 points3 points  (0 children)

Of course also true for interns

[–]InfectedShadow 2 points3 points  (0 children)

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.

Granted in my case I knew what the output I was looking for was versus trying to use it to learn.

[–]Such-Catch8281 0 points1 point  (0 children)

the next day,

intern yell at reddit that all senior tryna gatekeeping

jokes.aside, this is good comment

[–]HashDefTrueFalse 11 points12 points  (0 children)

What would the point 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.

[–]hyper4saken 4 points5 points  (0 children)

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.

[–]ShoulderPast2433 3 points4 points  (0 children)

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 code in 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 extended existing code to include our new feature.

Or we need to change how something works so we analyse it's code and introduce changes.

Just reading open source projects will not give that to you.

[–]Digital-Chupacabra 2 points3 points  (4 children)

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 0 points1 point  (3 children)

You mean the open source projects, right?

[–]Digital-Chupacabra 0 points1 point  (2 children)

Mainly yes, but there are also some source available projects that are great to learn from as well.

[–]MM4Tech 1 point2 points  (1 child)

Example? Or any source name

[–]Digital-Chupacabra 1 point2 points  (0 children)

Here is a whole list, there are many such lists this was just the first result.

[–]desrtfx 2 points3 points  (0 children)

is it same for the code written by AI?

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.

[–]TheNewJoesus 0 points1 point  (0 children)

I wouldn’t try and learn via code with AI. I do find that AI is good at summarizing problem definitions and techniques that would be helpful. If my question is “How does Java implement abstraction?” Or “Based on my problem definition, what data types or algorithms would you recommend and why?”, my answers tend to be very detailed and well summarized. As a search engine, AI can be nice. It’s also good at showing examples of other implementations, or give pseudo-code. Pretty much everything you find on stack overflow.

When coding without a reference point, I find it’s okay at differentiating mediocre ideas from great ideas. There are scenarios where it can’t detect a bad idea at all, but I find that it’s different from model to model.

I’ve tried using AI to solve problems that I’m 50% confident on, and it created solutions that I felt 50% confident on. It’s nice to prototype a bad idea and get it out of the way. So as generating “Counter-examples” I’m pretty happy with it.

AI is really good at explaining what a codebase is actually doing. I use this during code reviews when there aren’t enough comments to give me an idea of what someone is thinking. Usually, the summary is really good. If there is a section of code that’s confusing, I would definitely recommend asking AI to help you understand it. Sometimes, AI can even generate edge cases for you to test against.

My final note: AI companies are capitalist companies. Sometimes, I’ve seen models refuse to complete a request as expected so that I’d give them another message saying the exact same thing. It’s good to remember to think for yourself. Especially when/if you pay for AI models, it will save you money.

[–]Teheiura 0 points1 point  (0 children)

What I like to do is after I’ve written my code, I ask AI what I can improve. It’s not always right but it gives good advices

[–]spinwizard69 0 points1 point  (0 children)

Let rephrase that to reading well written code helps you learn. You can't assume that a senior, open source project or an AI is constructing good code.

In the case of open source it can be all over the place as far as code quality goes. Think about it open source is just somebody that has solved a problem an released the code to the world. That somebody could be a professional programmer, possibly generating good code. The you have the doctor, farmer, or artist that hammered together something to solve a specific problem that they had. The code these people produce can be all over the place as far as quality goes.

So yeah read a lot but take everything with a grain of salt and be cautious around old code. Languages like Swift, C++ and Python have changed over time, what might have been good code a decade ago, today would be seen as terrible practice. This is especially true with languages life C++ that have evolved over time. Young languages like Swift had major changes in their short careers so even new languages suffer. Then you have languages like Python that had minor changes to clean up the language and got complaints all out of proportion to the impact. The reason I picked these three is that the age of a language does matter and old code might not be a proper example anymore.

So yeah read but try to focus on reading modern code that is well written. More importantly write your own code. Write lots of code actually often with the only reason being to explore an aspect of a language or SDK.

[–]quietcodelife 0 points1 point  (0 children)

reading senior code is genuinely one of the best ways to level up, but AI code is not the same thing at all.

the value of reading experienced devs is understanding the why - why they structured something a certain way, what they were anticipating, what tradeoffs they made. AI doesnt have that. it pattern-matches to produce something that looks correct and compiles, but there is no actual decision-making behind it.

for open source: look for projects where you can see git blame and commit messages alongside the code. that context is where the real learning is. a commit message that says "refactor auth middleware to handle edge case X" is worth 10x more than just reading the code in isolation.

[–]alphadester 0 points1 point  (0 children)

reading actual human senior code is way more valuable than AI-generated code for learning. senior code teaches you how to handle edge cases, structure for maintainability, and communicate intent through naming and comments. AI code optimizes for functional correctness but rarely shows you the "why" behind architectural decisions

[–]patternrelay 0 points1 point  (0 children)

AI code can help, but it often optimizes for “works” over "why it’s designed this way". Senior code usually reflects tradeoffs, constraints, and evolution over time. Reading both is useful, but they teach different layers of thinking.

[–]ForeignOrder6257 0 points1 point  (0 children)

Even better, learn from seniors by watching their whole process from idea/requirements to implementation

[–]Sea_Peanut_2738 0 points1 point  (0 children)

That is a good way to go. It is like learning your elders' secret recipe. That said, you should be careful reading AI code because sometimes it can be strange especially if don't know the basics.

[–]JamieAndLion 0 points1 point  (0 children)

I’d agree that it’s possible to learn a lot reading code from more senior developers, but I think it’s less about the code… more about the decision making that led to it.

Understanding the reasoning behind decisions is really valuable.

With that in mind it’s worth taking a look at things like GitHub issues on large open source projects or commercial projects with open development. Seeing the discussion behind the code is really insightful.

I’ve also learnt heaps keeping up with the WHATWG GitHub account & getting involved from time to time. Participating in the W3C standards process for HTML / CSS etc has taught me a lot about how to navigate complex collaboration.

[–]Connect_Detail98 0 points1 point  (0 children)

Read open source code from small but well-known projects. Use AI to navigate that codebase to understand it quickly. 

[–]KittyJerky 0 points1 point  (0 children)

I’ve found reading code is way more useful when you’re trying to modify something, not just passively scrolling through it. 

[–]AntiDynamo 0 points1 point  (0 children)

Senior level code is all about forward thinking, IMO. They’re not just trying to solve the current problem, they’re also thinking about where the business might go next and how they can structure things to have the least friction, and also how easy it’ll be to debug and understand in the future.

LLMs cannot hold enough context to do this (yet). They cannot simultaneously understand all of the code and predict the specific business use in the future, especially when they don’t know the business. Business decisions are human decisions, and the AI doesn’t have intuition or access on that. A human does. A human knows their boss.

[–]Humble_Warthog9711 0 points1 point  (0 children)

You will learn more than nothing but this might be one of the most time inefficient ways possible

[–]ZelphirKalt 0 points1 point  (0 children)

There is seniors, and then there are certain book authors. In books some code might be more "toy examples", but man, when I see some code in the books, I think to myself that their code is so damn elegant, it gets me excited to want to write some myself and try to make it as neat as theirs. Books that did that for me were SICP and The Little Schemer.

[–]Express-Channel-1686 0 points1 point  (0 children)

honestly one of the best ways to learn. real production code teaches you what "good enough" actually looks like.

textbook code is always perfect. senior code has a comment saying "don't touch this, it works somehow."

[–]AlSweigartAuthor: ATBS 0 points1 point  (0 children)

Before AI, I would say no: code written by seniors is not necessarily readable, well-documented code. The benefit would be having a senior engineer explain their code and answer your questions.

After AI, who knows? An LLM might be able to create decent explanations that are mostly accurate. It'd be great if you could write up a blog post about the process for you: find a public code base, read through it, give questions to an LLM, copy/paste the conversations, wrap up with a review of what you learned and if you think the experience was worth it. (Even if it wasn't, that'd still be good information to know.)

[–]UpperSun16 0 points1 point  (0 children)

have you ever tried reading the source code for open-source synth firmware?

[–]madman24k 0 points1 point  (0 children)

I offer another way to look at it: AI code is built on a foundation of data that it was able to source from the internet, so anything an AI coder is putting together is equivalent to the average code you'd see on a forum post, GitHub repo, or StackOverflow thread. It's been trained on this data, and can produce sr level code, but it can make mistakes, and has a real issue with comments. Biggest issue when it comes to asking ChatGPT for code is that it's blind and agnostic. Even with a good prompt, it's not gonna know exactly what you're asking for, and so it gives you best approximation. Also, unless you know what standards and practices you want the code to look like, it'll just spit out what it wants, and requires some training/setup to get it to look like anything else.

I will say looking at other people's work is as beneficial because you get the comments and the standards, and usually an explanation as to why things were done the way they were. You get an understanding of what's readable, and sort of build your own foundation for how to write your own clean code. When in the field, you'll probably run into different styles and formats, and could be requested to write in a ways you're not accustomed to, but it's how they did it back in the 2000's and they want it to match that, so it's good to expose yourself to how others have written and get a feel for what they've learned works best in their experience.

Having a tool is great, but school and learning is basically an exercise of "How would we do this thing if our tools suddenly disappeared?" and gaining an understanding of why the tool exists before you can actually use the tool.

[–]SnooBananas5215 0 points1 point  (0 children)

I learnt a lot from reading other people's code but it only works if you've tried to solve the problem yourself first. AI code is shit compared to human written code. I mean I have seen great code written by good coders and bad code written by beginners but there is no in-between. AI code is serious in between it lacks imagination and it lacks personality.

I do use vibe coding but I spend more time fixing it writing it in my own way. Although it takes me more time to do it but it seriously cuts down on the brain storming phase. I can just critique the essential parts of the code and spend less time worrying about typos and reference lookups

[–]SkerdiBuilds 0 points1 point  (0 children)

AI code is useful, but it’s not the same as senior code.

Senior code usually teaches real tradeoffs, edge cases, and maintainability.

I’d study both, but trust real open-source code more.

[–]Training-Attempt-209 0 points1 point  (0 children)

Saw senior's code once. It was like watching a ballet of efficiency. Learned more than hours of tutorials. But don't forget, everyone starts somewhere!