TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Where can I find easy to read code, that can be understood completely?

2 点作者 morbidhawk超过 7 年前
I only program my side projects on the weekends, when I come back to the code I realize how poorly it&#x27;s been written, especially if I&#x27;ve skipped a weekend. I&#x27;m really striving to make my code readable. A great book I read is &quot;The Art of Readable Code&quot;, and while it focuses on code readability from a micro-level (making a small code sample readable), I find more knowledge is needed to make a program readable when reading it from start to finish.<p>The code I find most readable is imperative code that can be read line-by-line. I find abstractions hide away important knowledge of understanding completely how things work. Additionally I prefer reading algorithmic code than reading a bunch of helper functions that are at a level of indirection away from understanding the code at hand. For this reason I try to write in more imperative style instead of OOP or functional. But I find that programs I write that can be followed line by line end up having a lot of variables that make it hard to keep track of everything.<p>I&#x27;ve tried to look for other projects that can be read line by line easily but I haven&#x27;t found one yet. I&#x27;ll end up spending way to much time trying to figure out what helper objects, functions, or structs are doing and they require jumping to a bunch of other files while trying to keep in my head what I read previously.<p>It seems these 2 things are at odds with each other: readable code vs code that can be read and understood completely. I don&#x27;t want algorithms hidden away but when they are right there in place with the other code it becomes too much.<p>Is completely readable code even possible? I&#x27;ve heard &quot;abstract just barely as much as you need&quot; or &quot;just use right level of abstraction&quot; but that doesn&#x27;t give me anything concrete I can do. Is there a project that you know about that was large but very easy for a new person to read and understand completely? Do you know how to write code like that?<p>Any ideas are appreciated. Thanks!

1 comment

oblib超过 7 年前
I know there&#x27;s a lot of code out there I cannot read and suspect we&#x27;re hardly alone with that issue.<p>I comment my own code very heavily so I don&#x27;t have to spend as much time studying it at a later date.<p>And I don&#x27;t try to get too tricky either. I don&#x27;t fret over converting a block of code into an obfuscated one liner. I avoid that instead.