Give up on “good code”. Its pursuit is how junior devs pesters senior devs based on a delusion that such a thing is possible. Good code is working code, code that pays the bills. 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.
"write code that is easy to throw away" is generally a good piece of advice
Ask HN: Where do I find good code to read?
91–100 of 216 posts
Re: Ask HN: Where do I find good code to read?
#92Give up on “good code”. Its pursuit is how junior devs pesters senior devs based on a delusion that such a thing is possible. Good code is working code, code that pays the bills. 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.
This mentality is how you end up inheriting terrible codebases.
Re: Ask HN: Where do I find good code to read?
#93One thing to look for are programs that use advanced techniques as opposed to programs that are just simply clear or well-commented. For instance, instead of learning a new programming language, you should learn how programming languages are made. Most of the secrets that computer science majors know that you probably don't were learned in compilers class. (Unfortunately many people are chasing the Holy Grail of "fun…
Huh? What does this even mean? Both languages are very different from each other and the only thing they really have in common is having functions — how is one more “profound” than the other or any less worthy of being “functional programming”, for whatever that means to you?
Re: Ask HN: Where do I find good code to read?
#94Earlier quoted context omitted.
This mentality is how you end up inheriting terrible codebases.
I would rather write “bad” code that lasts long enough to be inherited than write perfect code that sits idle in a repo because I missed the market.
On the other hand, those aren't the only two choices, by a long shot.
Re: Ask HN: Where do I find good code to read?
#95Earlier 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.
Re: Ask HN: Where do I find good code to read?
#96Specifically something polished that also has complex UI elements like block indicators or embedded modals.
Re: Ask HN: Where do I find good code to read?
#97One thing to look for are programs that use advanced techniques as opposed to programs that are just simply clear or well-commented. For instance, instead of learning a new programming language, you should learn how programming languages are made. Most of the secrets that computer science majors know that you probably don't were learned in compilers class. (Unfortunately many people are chasing the Holy Grail of "fun…
> Unfortunately many people are chasing the Holy Grail of "functional programming" and never finding it because "functional programming" is a pale shadow of what's possible when you understand how compilers work: this is how Common LISP and scheme are so much more profound then, say, Haskell Huh? What does this even mean? Both languages are very different from each other and the only thing they really have in common…
Re: Ask HN: Where do I find good code to read?
#98Depends what good code is to you. Good code is different depending on your sense of aesthetics, but also it's purpose. Good code for an enterprise-life-blood type of system is terrible code for a "let's check if this is an idea" type of prototype (and vice versa). For a relatively large and mature project, someone might suggest Linux, but it's a bit hardcore in my opinion. FFmpeg is actually really nice, and you can…
I would posit that discarding github out of hand is not a great start. Pick one of the big projects on there and follow what is pushed in. You will notice how others interact with the code. You will start to notice who checks in good stuff. Follow them. Also pick your language. As a good style there could be a bad style in another for example C++ vs Python. Python styles in C++ would drive the C++ guys nuts and the other way around.
Re: Ask HN: Where do I find good code to read?
#99One thing to look for are programs that use advanced techniques as opposed to programs that are just simply clear or well-commented. For instance, instead of learning a new programming language, you should learn how programming languages are made. Most of the secrets that computer science majors know that you probably don't were learned in compilers class. (Unfortunately many people are chasing the Holy Grail of "fun…
> Unfortunately many people are chasing the Holy Grail of "functional programming" and never finding it because "functional programming" is a pale shadow of what's possible when you understand how compilers work: this is how Common LISP and scheme are so much more profound then, say, Haskell Huh? What does this even mean? Both languages are very different from each other and the only thing they really have in common…
As for something profound I'd point you to
https://github.com/cerner/clara-rules
which many people will struggle with because like many other production rules engines in LISP (and many other examples of simple compilers), there is hardly any code! Contrast that to the orders of magnitude larger rules engine Drools
https://github.com/kiegroup/drools
which is so crazy-complicated primarily because the Drools language is Java-based so you need all sorts of things that Clara or CLIPS don't need. Note that both of these systems use variations of this algorithm
https://en.wikipedia.org/wiki/Rete_algorithm
where a set of rules can be compiled to a network of transitions that can happen when facts are added to the knowledge base so it is very much an example of compiler technology. (That said, Drools supports a lot of features that Clara doesn't and also supports a very advanced RETE-like algorithm that can exploit parallelism that early versions couldn't.)
Re: Ask HN: Where do I find good code to read?
#100The question doesn't specify any language, so FWIW, I first learned "serious" programming by reading the sources for GNOME Glib, about 18 years ago. https://gitlab.gnome.org/GNOME/glib
The fact is someone programming languages - either by design or culture - just encourage unbelievable crap. Obviously, any code can be written well, but if one has to look for a needle in a haystack it's not worth it.