TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Does reading code actually make you a better developer?

57 pointsby saasinatorabout 8 years ago
I&#x27;ve been writing software for quite some time, and one piece of advice I hear a lot for improving is &quot;read lots of code, write lots of code, repeat&quot;.<p>I get writing lots of code-- but reading lots of code? I&#x27;m not so sure.<p>What are your thoughts?

26 comments

danyimabout 8 years ago
Short answer, yes. Long answer: Learning how to read other people&#x27;s code will help your literacy of the language and you may even learn a new trick along the way. It might seem like an arduous task now, but as you get into the habit of reading more code, you&#x27;ll be able to recognize patterns and processes much faster thereby improving your velocity.
neuroclineabout 8 years ago
The very short answer is - writing code makes you a better developer. But it&#x27;s incredibly rare for you to be able to invent every pattern, every useful trick, every readable style, so you read others&#x27; code. Your ability to understand what you see in others&#x27; code (and to judge it) goes up as you get better. So you write lots of code, read lots of code, write lots of code...<p>There is an analogy to writing in a human language. If all you do is read for 10 years, and then start writing, you&#x27;ll almost certainly be a bad writer. You learned to read and extract information (and get enjoyment), but you almost certainly didn&#x27;t understand how writers achieved those goals. This is even more sure for programming. Writing code over and over again helps teach you when and why to apply certain rules, because code has to work, not just look pretty.<p>But unlike writing human languages, there is far more to learn about computer programming - it&#x27;s not just grammar and style, there&#x27;s all levels of design, and architecture. So you read articles and books, but those are usually very hand-wavy. By reading the code for very large programs and then trying to copy what you see, you learn.<p>Also unlike writing human languages, you start by writing code. Reading code before you&#x27;ve written any is nearly pointless - you just won&#x27;t understand what you are looking at.<p>It also matters what code you are looking at, just like it matters what you are reading - but again, only once you get good. So until you think you are at the median level for software engineering, don&#x27;t worry too much about what you read.<p>The cool thing is that there&#x27;s so much code available to read now, as compared to 40 years ago when programming first started becoming a real thing. And especially with Google and a few others not just employing hordes of great engineers but releasing a lot of their source as open-source. Read the Chrome source, for example. Or the Linux source.
mvpuabout 8 years ago
Reading code <i>without judging</i> is a superpower, because it breaks your mental blocks and makes you versatile. You can work on others code comfortably, fix things, and learn the good parts quickly without getting frustrated. My biggest issue was that - I was expecting everyone to think like me :)
WalterSearabout 8 years ago
If you don&#x27;t read other people&#x27;s code, you are stuck understanding things in terms of the idioms of your own comprehension.<p>Moreover, reading code is a skill, and much of being a good developer involves working with other people code, which means being able to efficiently parse other people&#x27;s code.
评论 #13992121 未加载
dontreactabout 8 years ago
I think you are much more likely to get stuck in a local minima if you don&#x27;t get good at reading code.<p>-It lets you work effectively as part of a larger team or project<p>-Gives you a much larger surface area of material to learn from: you can learn new patterns and libraries by seeing how other people use them instead of having to find documentation or tutorials<p>-Sometimes there are bugs in libraries (open source or otherwise) that you depend on. You will find these much quicker if you are good at reading code.
weegoabout 8 years ago
It&#x27;s far too simplistic to say, yes or no.<p>If you are inclined towards self-motivated improvement and if you have a good internal monologue where you are able to be real honest with yourself and your own failings and limitations then reading good code opens up the possibility that you can apply the things you take away from it to your own code and become better.<p>Good code isn&#x27;t a gold ticket, it&#x27;s always on you.
roadfunabout 8 years ago
Being able to read someone else&#x27;s code is an essential skill. If enough time has elapsed it can even be a useful skill for code you wrote some time ago. It can make you a more effective developer because, for example, you will be able to read through open source code to understand what it does (since some have poor docs) as well as allow you to contribute fixes and enhancements. You can also find new techniques in code that you can add to your own &#x27;arsenal&#x27;. Another reason is it is a great way to learn a new language: you can start reading examples and mapping patterns from languages you know into the new one. So yeah, this is an essential skill.
espeedabout 8 years ago
Yes, just like reading research papers will expand your horizon and build your cognitive map, the more code you read, the more you&#x27;ll see concepts and patterns repeating. You&#x27;ll start to identity what&#x27;s important and how things are related in sometimes subtle ways. You&#x27;ll encounter the same idea expressed in different forms, in different languages. This will help reveal the essence of an idea as you begin to identify its invariants that persist from language to language and form to form. You&#x27;ll see contrasts between good code and bad code. Beautiful code and ugly code. Readable vs cryptic code. Clean lines vs nesting. Your sense of style and aesthetics will refine. But don&#x27;t just read code in your preferred language or domain of expertise. Learn to read code in multiple languages, in multiple paradigms. High level and low level, up and down the stack. Read to refine your thinking. You&#x27;ll develop fluency, and your code will evolve.
mamaniscalcoabout 8 years ago
The answer to this question will fall sharply upon two lines depending on how you interpret the definition of &quot;better&quot; developer.<p>I see one interpretation of better as &quot;can copy, repeat, fix, comprehend, maintain.&quot; And the other as &quot;comprehends and exceeds - often without explicitly &#x27;reading&#x27; that which is comprehended in the first place&quot;<p>The first group will argue that you have to read. The second will argue that it&#x27;s optional.<p>I am in the second group but would argue in favor of the first. It never hurts to stand upon the shoulders of the giants who came before you.<p>That being said, I never read other&#x27;s code unless its to fix it.
cpburns2009about 8 years ago
I wouldn&#x27;t say reading lots of code is necessary. Reading some code can definitely be beneficial though. If you&#x27;ve just moved to an existing code base, it would be helpful to familiarize yourself with the existing structure, idioms, and patterns. If you&#x27;re working on something new but don&#x27;t know how to approach the task, looking at code solving a similar problem or using a similar methodology can help. As with most advice, take it within reason. Don&#x27;t go to the extreme.
nudpiedoabout 8 years ago
No, at least not just &quot;reading code&quot;. You need to understand and identify the patterns that underly there... so debugging other people&#x27;s code and lear how other&#x27;s strategies are solving their problems should be the actual reason behind &quot;read code&quot;.
thomastjefferyabout 8 years ago
Does reading make you a better writer? Yes.<p>What does it mean to be a good developer? Do you simply want to write your own black-box undocumented software? Then there is a much lesser advantage to reading other projects&#x27; code. On the other hand, if you want to manipulate another codebase, or use another library, reading code is a necessity.<p>That leaves one final question: Is it beneficial to your own development skill to read others&#x27; code? Yes. Proficiently reading others&#x27; code is a very beneficial skill, even if you do not intend to write code to be read by someone else. Not only will you get better at reading your own code, you will learn idioms and practices that will improve your comprehension, and writing skill.
emmetcooperabout 8 years ago
Yes, that&#x27;s how I mostly improved my codes but learning how other people coded the function I wanted to do. And then write the code itself on how I understood it. By that, I also learn new things I haven&#x27;t tried before.
samblrabout 8 years ago
Like books: as one reads more one gets to know what is written better. Overtime, reading code has helped me in inculcating good practices of others in my own writing. But having said that, writing code is like playing sport. More we code - better we get atuned to (developer) environment - no amount of reading will help!
relaunchedabout 8 years ago
After learning a language enough to have an intermediate understanding of how it works, both conceptually and syntactically, I&#x27;d argue you learn more reading other people&#x27;s code than you do writing your own.<p>The way I like to do this is to think through how I would implement something. Then, reference code that does something similar to the problem I was trying to solve. Then, I compare their solution to mine.
katabout 8 years ago
Very much YES! Being able to read the code is a required skill for working on enterprise applications. Fixing bugs and adding features will have to play nicely with the old code. If you don&#x27;t understand the old code, your new code will make matters worse. You may accomplish your short term goal, but without the ability to read and understand the old code you will create a very brittle solution.
NHern031about 8 years ago
I am a C# (mostly WPF) developer at work. Most of the applications I write communicate with an API written by another developer in PHP. As much as I dread PHP I learned to read his code(which is poorly documentation) and it has helped me learn quite a bit. Reading code that isn&#x27;t yours opens your mind to a different style of thinking, it&#x27;s very powerful; I would recommend it.
forgottenacc57about 8 years ago
Working on code makes you better.<p>You don&#x27;t read it like a book, you read it to modify it and therefore you just understand it.
bougiefeverabout 8 years ago
For me, reading code, and then trying to implement my own version while resisting the urge to look at it again is the best way. I actually learn by doing, but reading other people&#x27;s code, either in a blog or at work is a good place to figure out what I want to learn.
tommymachineabout 8 years ago
Certainly yes! The chief reason is that you&#x27;ll learn the difference between code you like and code you don&#x27;t like. You&#x27;ll learn what makes up that difference, so you can build it into your own code in the future. You will develop taste, so to speak. Taste is important.
j45about 8 years ago
The better I learn to read, the better I write. Applies to coding as well, because the real world has so much more refactoring of code than always starting fresh to make a new mess. Love admitting you can get better and faster with practice and time
mattbgatesabout 8 years ago
Having worked and still working for years fixing other people&#x27;s code... it definitely teaches you how to code and how not to code. I&#x27;ve seen things that made me question the competency of the programmer, but I&#x27;ve also seen many codes doing the same thing, but written in different ways. There are also those times where you think: &quot;Wow, this code is so poetic!&quot;<p>So reading other code can surely help. I have seen some Github projects where I would have loved to have used the project for personal use, but I just couldn&#x27;t understand the coding style, or have had to incorporate my own coding style because I could not adopt the code as it was in the program.
y0yabout 8 years ago
Understanding other people&#x27;s code (for better or worse) makes you a better developer.
collywabout 8 years ago
Reading crap code should give you inspiration to rewrite it in a better more understandable way.
edimaudoabout 8 years ago
If you read code with the goals set in mind it can make you a better developer.
deepaksurtiabout 8 years ago
I read with a specific context&#x2F;goal in mind.<p>For a new code base, I start off with a high level design and one feature which touches the important parts. May be there is more knowledgeable with codebase around to ask and also decent documentation.<p>If I am in a Lisp like editing language, this [1] tracer is fantastic. Otherwise in non-live languages, I am a dead duck in the circus of breakpoints&#x2F;debugger to step through the code.<p>You may also have a look at this [2], the author of Coders at Work, Peter Siebel talking about decoding code and from the same book a very interesting discussion on reading code which I have reproduced here.<p>---<p>Seibel: I’m still curious about this split between what people say and what they actually do. Everyone says, “People should read code” but few people seem to actually do it. I’d be surprised if I interviewed a novelist and asked them what the last novel they had read was, and they said, “Oh, I haven’t really read a novel since I was in grad school.” Writers actually read other writers but it doesn’t seem that programmers really do, even though we say we should. Abelson: Yeah. You’re right. But remember, a lot of times you crud up a program to make it finally work and do all of the things that you need it to do, so there’s a lot of extraneous stuff around there that isn’t the core idea. Seibel: So basically you’re saying that in the end, most code isn’t worth reading? Abelson: Or it’s built from an initial plan or some kind of pseudocode. A lot of the code in books, they have some very cleaned-up version that doesn’t do all the stuff it needs to make it work. Seibel: I’m thinking of the preface to SICP, where it says, “programs must be written for people to read and only incidentally for machines to execute.” But it seems the reality you just described is that in fact, most programs are written for machines to execute and only incidentally, if at all, for people to read. Abelson: Well, I think they start out for people to read, because there’s some idea there. You explain stuff. That’s a little bit of what we have in the book. There are some fairly significant programs in the book, like the compiler. And that’s partly because we think the easiest way to explain what it’s doing is to express that in code.<p>---<p>Overall, I try to read in small pieces with some clear goal. Interestingly enough, I don&#x27;t know if we can read code from start to end like a book, may be literate programming makes that possible; but yes reading code is hard and that is simply because we don&#x27;t have good code reading tools, yet in the 21st century!<p>[1] <a href="https:&#x2F;&#x2F;www.cs.cmu.edu&#x2F;~dst&#x2F;Lisp&#x2F;dtrace&#x2F;dtrace.generic" rel="nofollow">https:&#x2F;&#x2F;www.cs.cmu.edu&#x2F;~dst&#x2F;Lisp&#x2F;dtrace&#x2F;dtrace.generic</a><p>[2] <a href="http:&#x2F;&#x2F;www.gigamonkeys.com&#x2F;code-reading&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.gigamonkeys.com&#x2F;code-reading&#x2F;</a><p>EDIT: link to the code is not literature article