The runtime/std lib of the PL of your choice. Your text editor or a plugin that you use etc.
Ask HN: Where do I find good code to read?
111–120 of 216 posts
Re: Ask HN: Where do I find good code to read?
#112Earlier 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…
The problem with this “maintainability” argument is the presumption a) that it will be maintained (note I recommended rewriting frequently) or that b) it’s in conflict with meeting business objectives.
Seems not ideal for end users, unless you're working with microservices or something with well defined specifications that people are actually paying attention to.
Re: Ask HN: Where do I find good code to read?
#113Someone can tell you "This is good code." but good for what? Why is it good?
It is fast code? Is it highly maintainable? Is it well documented and kept up to date? Is it a code that is highly reliable? Is it code that solves and important problem?
My rule of thumb is: Ugly code usually comes from ugly problems. Ugly code can often be some of the most valuable code, because... it does the ugly things! It does what we want 99.9% of the time, using heuristics, and other nasty stuff.
So don't judge code on if it is "good" or not. Judge it on if it does what the author intended, and if it doesn't suck too badly to read with no reason.
Code bases I've worked in and have opinions on:
Samba: Good code base, but you MUST understand the idioms of the codebase, or it is absolutely horrible. It also alas, has the wisdom of 20+ years of existence in it... so it isn't always pretty.
Illumos/OpenSolaris: Nice codebase. Get the SmartOS distribution and you can literally type a few commands and build an entire OS and userland.
FreeBSD: See above. Great codebase, ans also, it can build userland + kernel, though it takes a few more commands. I'll admit I haven't read this one in 20 years. But I always found it a good codebase to work in back when :).
Grab the source for a library you use all the time, you know the useful one but the API feels a bit off... Download it and look at why the API is the way it is.
When looking at code, do NOT neglect looking at the history of a given file or piece of code, it often can teach you quite a bit. :)
Re: Ask HN: Where do I find good code to read?
#114Earlier 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?
Re: Ask HN: Where do I find good code to read?
#115Earlier 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?
I'm guessing solid and dry are a big part, but lack of cleverness, language choice that doesn't require cleverness, and heavy reuse with libraries and frameworks, and choice of feature complete libraries is probably a lot of the speed.
Something in C is going to be more work than JS or Python or Dart and work takes time. Code you write takes more time than code that already exists, unless the code that exists disappears one day.
Re: Ask HN: Where do I find good code to read?
#116Re: Ask HN: Where do I find good code to read?
#117There was a blog post from Peter Seibel recently called [Code Is Not Literature)]( https://gigamonkeys.com/code-reading/ ) which pointed out that although everyone seems to agree reading code is great, very few tend to do it regularly. I feel like I get a lot more out of messing with / hacking on code than I do from reading it. I'm sure people vary, but I've got loads more out of open source contributions to sometime…
Either way, have a goal in mind when reading code. If nothing else, take notes on what you learn.
Re: Ask HN: Where do I find good code to read?
#118Read your own code that you thought was good 6+ months ago. Do you feel like it's still good? How could it be improved?
Re: Ask HN: Where do I find good code to read?
#119Instead: write code for whatever fits your fancy, and request experts to give you feedback.