Hacker News new | ask | show | jobs
by pie_flavor 244 days ago

    Do One Thing*†‡ And Do It Well⹋
    * Parsing text formats counts as zero things
    † UX counts as two things
    ‡ APIs that do multiple operations that people might want to split, with no individual APIs for the parts, count as doing one thing 
    ⹋ Something that relies on cooperation from every other process on the system but has no way to enforce it counts as done well
Nobody bothers with this argument when the library is for, like, HTTP clients, or PKZIP containers. Unix philosophy, like most philosophy, exists mostly to be debated, and to be related to the history of the world, rather than to be actually implemented in the modern day.
1 comments

Libraries make sense when the tool is limited by the text-only Unix philosophy. E.g. highly concurrent or just high performance HTTP requests will be limited by the overhead of spawning `curl` processes, parsing responses, and having to re-allocate memory since you can't just take over the memory curl already allocated. Also when the user is unlikely to care which one you use (I don't care much what HTTP library a given binary uses).

Pagers are practically the worst thing to make this argument about, because they mesh perfectly with the strings-only nature of Unix. They take a string and allow the user to navigate through it. They only need to be fast at human-recognizable speeds, there's little reason for them to be highly concurrent, and there's a lot of value in allowing the user to choose which pager they want they to use.

More broadly, there's also value in composable tools because users can use the one they're familiar with. I can learn how jq works and use it with anything that outputs JSON, rather than having to learn the syntax of 18 different libraries various app developers have chosen for querying JSON. I can pipe whatever I want into 'more' instead of having to learn the keybinds for each of the 5 popular paging libraries.

It's not perfect, but I do think it's better than the embedded alternative for a lot of things.