Ask HN: What code makes you happy?

8 points by gonification ↗ HN
Perhaps a clean code sample? A library where the code seems to read as naturally as if you wrote it yourself?

11 comments

[ 3.2 ms ] story [ 28.2 ms ] thread
Code with few dependencies! I am not a fan of app-generators or specialized overweight package managers. Folks take enough advantage of yum/apt.
> I am not a fan of app-generators

Does a compiler count as a kind of app-generator?

No code is the only type of code that makes me happy.
Code that runs for a decade without issue
Code that replaces/relieves humans.
Forgive the narcissism but I quite like the main function here:

https://github.com/mbrock/klatch/blob/master/Klatch/Embassy/...

And also this (incomplete) test suite for a language interpreter:

https://github.com/lessrest/koko/blob/master/test/Tests.hs

Other than that I really love well-written shell scripts that do their job.

Narcissism forgiven. That is petty code.

Readable, followable code is definitely on my top sexy list. I want to be able to read it like a story and not have to guess at obscure conventions someone made up to keep their job proprietary.

I really like it when the entrypoint function itself tells the basic story of how the program works.

Too many entrypoints are a combination of verbose boilerplate and obscure setup of "handler managers" and "event factories" and god knows what.

Often I look at a main function and it just seems to kind of start... something... and I have no clear idea of where to look for the code that actually does anything.

Intuitive code, which tell itself what is supposed to do. When someone saw the code, they should be able to know what is happening. Another thing which will make me happy is to defines clear interfaces which can be extensible for any future change.