Live data from Hacker News

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

news.ycombinator.com

141–150 of 216 posts

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

#141
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…

You can write good code behind well defined interfaces, too. There's no reason you have to pick one or the other. Bad implementations are still bad.

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

#143
post #4

Earlier quoted context omitted.

"Ask HN: What's the best source code you've read?" https://news.ycombinator.com/item?id=32793534

It's worth clicking for the top post.

> I generally wrote my algorithms in Pascal (later in Modula or Ada and by Borland days, in C++) and then hand compiled down to assembly

Beast mode. This is a great way to understand more about how the high level code we write actually performs. I learned the basics of compilers long ago but never though to apply it in this way, where you can have a reference implementation against which to test an assembly rewrite. Very cool!

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

#144
The best code is no code. I would stop chasing these kinds of rabbits and start looking harder at the actual information being processed throughout. I'd also focus more on the actual business & customers over any specific coding practice.

You would hopefully find that the most compelling aspect of well-designed software systems is the data. In "data-driven" applications, 100% of the application state and configuration can be made to live in a database somewhere. In these scenarios, seeking code examples is not going to tell you much of anything.

My advice is to look at a bunch of SQL schemas (ideally, ones you know to be under successful products) and compare them to the problem area they support. Think about how you would answer questions a reasonable person might ask of that business by way of a query. Then, consider how much code you just now did not write to answer a realistic business problem.

Relational modeling can eliminate entire repositories worth of bullshit code that should have never existed in the first place. Do you want to train yourself to rely upon something that a true wizard can walk in and disaparate at the snap of his fingers?

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

#145
post #133
post #9

Peter Norvig's Pytudes was recently posted here. I think that's some of the best code I've read, although they're only small problems and not a bigger project. Still very much worth a read, he goes through the whole problem solving through code process. https://github.com/norvig/pytudes

That's very interesting. I found his code to be unreadable

Same, actually. Perhaps some of it is due to the naming convention. For instance, in the Lisp interpreter, he tends to use "parms". Which I assume is short for "parameters".

That makes me think of parmesan cheese -- "params" would be a better fit.

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

#146
Chromium. I don't know how it looks right now, but several years ago lots of its parts were really good. Modular, with a lot of extensibility points, easy to read. (That may have changed, so another opinion would be useful). It was quite different from Firefox code, that looked surprisingly convoluted.

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

#148
I would suggest starting with reading a spec for your favorite language. I got a lot of value from spending time with the Ecmascript (JS) spec, as well as the Postgres manual. Take something like Generators that may be less familiar to you, then plunk those expressions into sourcegraph or github search and find them used in real codebases. Try to understand why the developers chose to use a generator instead of another pattern.

I think reading code itself is only valuable when you need to explore a specific domain. Trying to extract coding patterns from an unfamiliar domain very difficult; it comes with unseeable assumptions.

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

#150
My suggestion is to focus on some of these:

* Protocol implementations(e.g. TCP, HTTP, MIDI)

* Smaller compilers(PUC-Rio Lua, Forth-80)

* Commercial video game sources [0]

When studying protocols, you can compare apples-to-apples because the protocol has to work the same way by design, but the implementation can vary. With compilers, you're getting a look into programming in its maximally symbolic form - and every strategy a compiler uses is one you can directly apply to abstract your own code. And commercial video games have another mode of apples-to-apples in that the original release - the dirty, meets-deadline stuff - often can be compared with fan remakes and patches, which have the luxury of an exact specification and no deadlines. To actually ship in industry, you have to accept and know good dirty code hacks, but it's worth comparing them to their counterparts.

[0] https://en.m.wikipedia.org/wiki/List_of_commercial_video_gam...

Post reply on HN