Live data from Hacker News

Ask HN: Where do I find good code to read?

news.ycombinator.com

171–180 of 216 posts

Re: Ask HN: Where do I find good code to read?

#171
post #27

Earlier quoted context omitted.

I disagree. The problem with believing that "good code" is good enough to deliver business value is short-sighted. Good code is highly maintainable so that you can continue to meet business objectives in a timely manner without regressions. Often this means (ironically) taking a little bit of extra time early on to think about how to make your code readable and "simple enough" for someone else to be able to jump in a…

"maintainable" code is disposable. Modern web stacks are built on the idea that you can delete a file and re-implement its interface with a different service behind it later on. Instead of writing code which will be easy to modify, write a good interface which solves your problems in a way that's easy to reason about, and feel free to write garbage implementations that will get "refactored" (thrown away) every year o…

>Modern web stacks are built on the idea that you can delete a file and re-implement its interface with a different service behind it later on.

and that paradigm is exactly why my domain is the start opposite of front end web development. Code I write may be used by thousands of other engineers over decades. I can't take into account every edge case, but I do try to write with the assumption that one day some archeologists will uncover that code as some Rosetta Stone. Of course, modern demands never let me reach that ideal, but it teaches care and good documentation.

Re: Ask HN: Where do I find good code to read?

#172
post #35

Earlier quoted context omitted.

> Focus instead on writing code you can throw away easily, code that you are wholly unattached to and is isolated enough that rewriting it won’t cost absurd hours. > Good code is highly maintainable so that you can continue to meet business objectives in a timely manner without regressions. I think you essentially agree on what people should do, regardless of whether you call this 'good code' or just maintainable cod…

> Don't copy and paste the same implementation x times because that way there's only one place to fix it. But also sometimes it makes more sense to copy and paste over trying to fit an abstraction where it shouldn't be. :) I think the purpose of questions like the ones by OP is not to figure out "rules" (which are useful only for beginners) but to figure out where and why rules were broken. Sometimes (often) the answ…

>But also sometimes it makes more sense to copy and paste over trying to fit an abstraction where it shouldn't be. :)

depends on goals. diverging modules should be copy-pasted, two modules that rely on the same functionality should be consolidated (not necessarily abstracted, but synchronized somehow). Those are both two common cases, so there's no general advice on which is better.

>Good intermediate (I suppose Sr. in our industry) level code is notoriously difficult to find examples of and mentor toward.

so much industry code and knowledge is proprietary, so I imagine that is by design. even intermediate code has a bunch of value to a company, even if the company lets go of that engineer to make their earnings report 0.1% higher.

Re: Ask HN: Where do I find good code to read?

#173
post #159

Earlier quoted context omitted.

I understand you're characterizing the word "good" as some bad definition of "good" used by some subset of others, but your quotation marks are doing a Herculean amount of lifting (i.e. it's hard to tell what you're saying). I think most people would consider "engineers who value solving problems" as "good" and vice versa.

I'm just using "good" here as defined by the parent comment I replied to, to make the point that I believe the engineers as he described wouldn't value solving problems as much as they value "good" code.

It goes hand in hand. We're still talking about engineers here, not pure computer scientists. And if we want to call them "engineers" they should understand short and long term ramifications of any decision they make, something reflected in the code they are responsible for. Few other engineers would ever accept a paradigm of "make fast, re-implement fast", but since that's a luxury a software engineer has, it comes more down to understanding what the business needs and using the right tools.

Re: Ask HN: Where do I find good code to read?

#174
post #158
post #75

Earlier quoted context omitted.

Please send me your juniors, I'd like to hire them.

I’m not sure if this is an insult or compliment…

I took it as a compliment. Some value "productive" engineers, while others value "curious" ones. curious ones are probably for companies that want to retain talent and invest a lot into R&D. productive ones are for when you need to get a product out fast before anything else.

Not saying one is better than the other. Sometimes being first across the line is make or break for a company. But I wish companies could be more honest about what they want.

Re: Ask HN: Where do I find good code to read?

#175

Earlier quoted context omitted.

Writing good code doesn't necessarily take more effort than writing bad code; in fact, my experience tells me otherwise. Teams that write good code iterate faster.

What property of the "good code" allows them to iterate faster? Is it because it's perfectly abstracted and encapsulated and SOLID and DRY? Or is it because it's written in a manner, easy to understand, easy to extend, and easy to throw away and rewrite if necessary?

>Or is it because it's written in a manner, easy to understand, easy to extend, and easy to throw away and rewrite if necessary?

This. But IME when you write for this purpose you tend to end up with code that is in fact confusing, not documented, and not test covered. So you need to slow down even if your goal is to one day completely re-write that module.

Perfect abstractions are never perfect unless you completely architect out the product, down to every single edge case. That's virtually impossible with a large codebase, be it due to an API or even compiler level bug.

Re: Ask HN: Where do I find good code to read?

#176
post #57

Earlier quoted context omitted.

>because I missed the market This is not relevant to the vast majority of developers, realistically (and is an important caveat to your original comment).

It absolutely is, though many people would agree with you.

Statistically speaking, most developers are not working for startups. And of course, large companies have the sway and politics to go around not being first. e.g. Apple isn't worried about missing the market, they are trendsetters and they light a market up even when 10 years late to it.

Re: Ask HN: Where do I find good code to read?

#177
post #88

Earlier quoted context omitted.

it's strange seeing someone with absolutely no pride in their craft.

The craft is solving the problem, not endlessly circling around it. perfect is the enemy of good

My craft is not leaving a dumpster of a solution to the next people to look at my code when business logic inevitably changes. If someone's solution to seeing my code is "we gotta re-write it", I have either failed or a much more novel solution was discovered that makes my code irrelevant. I hope it's not the former.

Re: Ask HN: Where do I find good code to read?

#178

Earlier quoted context omitted.

Yes, and it also is the point I think most people here are missing.

This is uncharitable. The GP's comment is short. What people have an opinion about is, "Give up on 'good code'" and, "working code, code that pays the bills ... code you can throw away easily, code that you are wholly unattached to".

big claims require big justifications. I can't just go out and say "C++ is better than Javascript" and expect people to not scrutinize me because "well it was a short comment".

But hey, they do justify it in responses. So maybe they are indeed playing to their philosophy of "work fast"

Re: Ask HN: Where do I find good code to read?

#180
Rather than seeking an impossible ideal (>2 people who agree on what 'good' code is)-- instead read ALL sorts of code. This will then help you learn to distinguish between what is good and not good, and what makes it so. Simplicity, clarity, and lack of surprise come to mind as concepts for 'good'. Others will have different ideas.
Post reply on HN