3 ms·
> However, I do think that one should not arrive at the belief that this kind of > optimisation is warranted everywhere and that code simplicity can also be a
by tlamponi 4y ago
> However, I do think that one should not arrive at the belief that this kind of
> optimisation is warranted everywhere and that code simplicity can also be a goal
Definitively not warranted everywhere, especial if premature and at such detail, but core utils like `cat` and `yes` are IMO prime examples of where such optimizations are warranted:
- They're in use daily on a huge amount of setups, even small benefits add up much more than in some niche tool.
- They got a clear and small feature set that won't change anytime soon, so there won't be much code churn and thus maintenance effort will be relatively low.
> Similarly, there is the NSFW comparison between Plan 9’s cat and GNU coreutils’
> cat [3].
>
> [3]: http://9front.org/img/longcat.png
IMO that isn't an exactly fair comparison though, as the difference is not only in optimizations but a lot in boilerplate license/copyright comments and in features like line numbering, modes for showing (non-printable) special characters or whitespace and option parsing for said features.
Strip all that out, and you got (eye balled) 1/3 of that, and 200 lines for an extremely fast core util is really not much nor hard to maintain, as it won't get any new features soon anyway.
- pixelbeat__ 4y agoRight. Faster generally means less CPU used for a particular use. For example I made ls(1) a bit faster recently. Even though not really noticeable per run, given how often it is run I estimated this to save 9 tonnes of carbon emissions per year. https://twitter.com/pixelbeat_/status/1511030095011581953 https://twitter.com/pixelbeat_/status/1511030095011581953
- bipson 4y agoThis comment rubs me all the wrong ways possible. Is the posted link supposed to be a reference? That is your own tweet aka self-reference, boasting your own contribution. In the tweet itself you say "estimate"! How do arrive at such a grandiose estimate? How do you attribute a saved carbon footprint to an optimization in a command line tool? You cannot even approximate that. I would argue that such tiny optimizations make 0, nil difference in overall energy consumption on my local machine, all my laptops and all the servers in this building. I'm not saying that we shouldn't run optimized code, but everyone can scream around random numbers.
- rakoo 4y ago> and in features like line numbering, modes for showing (non-printable) special characters or whitespace and option parsing for said features. I remember a page somewhere saying plan9 people where very much against making cat be a generic tool for all those use cases, and it should do what it says in the name: concatenate files.