Ask HN: What code do you frequently read?
41–50 of 64 posts
Re: Ask HN: What code do you frequently read?
#42In terms what I return to, I refer to the LZ algorithm quite often. LZ77 and LZ78 are beautiful in the simplicity and power of their logic. I used to like to look at PRNGs, for example the one in RC4, and hashes. I like the question -- "How do they get so much entropy from so few lines?"
Occasionally I'll look at a one or two line functional programming routine in Python to see about the question, "How can this be done more neatly, elegantly, simply or quickly?"
Algorithms are beautiful, not the code. Code is just worldly forms, which are all an illusion.
Re: Ask HN: What code do you frequently read?
#43So, about once every 6 months I read through it to see if there are any obvious features I can add. Then I read through it to see if there are features I can collapse. It's been interesting to see the features grow linearly, but the code base grow logarithmicaly.
People have asked me why I didn't just use LINQ to SQL or Entity Framework or whatever, but I don't think they understand that A) those things didn't exist at the time, and B) there's something about having a tool that you know inside-out.
Re: Ask HN: What code do you frequently read?
#44I haven't gotten to it yet, but hope to!
Re: Ask HN: What code do you frequently read?
#45Golang stdlib is an excellent reference for how to write idiomatic Go code https://github.com/golang/go/tree/master/src
Re: Ask HN: What code do you frequently read?
#46Usually you don't just go read source code for the heck of it. You read the source code either to contribute a feature or fix a bug. There's no point in reading the src otherwise because you won't find a good enough reason to try to fully understand it.
I beg to differ. For example, reading the Go source is extremely useful both to learn idiomatic Go, and for reference.
Re: Ask HN: What code do you frequently read?
#47I pretty much read the code for every dependency I use. It helps me understand how it works and what the docs are fibbing about. If I can't read the code because it's proprietary, I always strace it to see what it's doing. For me, it makes it easier to reason about the behavior of my program. Currently my favorite code to read includes: key/value databases written in C and other "lower level" languages, and the golan…
Would you mind going into detail about how you use strace in that context? Or about how you learned to do that? That's a very handy skill which I need to learn.
When you launch htop, you will see a list of all your running procs. If you select a proc with the arrow keys, you can hit "s" to start a strace and then hit f4 to follow the strace as it dishes output.
This won't work for all procs, you will need root to strace certain procs.
This is a good place to start as it's visual and easy to follow. Later you can start traces from the shell with proc IDs and even get system call info from GDB.