by version_five · 3y ago · 0 comments
My point was in part that it's valuable for even a simple utility to be well written and optimized and that it's nice to have these minimal examples to learn about how to, e.g. write output very quickly. The program is so short that presumably the number of lines is unimportant, and if the author knows how to do it they might as well make it as fast as possible so it's never in the way, and so we can learn from it. That's why I think it's a good example.
https://github.com/openbsd/src/blob/master/usr.bin/yes/yes.c https://github.com/freebsd/freebsd-src/blob/release/4.0.0/us...
package main
import "flag"
func main() {
yes := flag.String("m", "y", "message")
flag.Parse()
for {
println(*yes)
}
}https://www.reddit.com/r/unix/comments/6gxduc/how_is_gnu_yes...
* The fast version is still simple enough
* The general functionality being provided is to output arbitrary data repeatedly, and it can be useful to do this as fast as possible
With modern systems we can have 8 channel RAM and 128 PCIe lanes to feed a system stuffed with NVMe drives. The amount of throughput that can be obtained is nuts, and at that point all sorts of weird things can become an unexpected bottleneck.
This applies even in consumer systems. Suddenly your game loads far slower on a NVMe than it could because it never occurred to the programmer that instead of the disk, the JPEG decoder can become a bottleneck when you can read compressed data at 7 GB/s.
But for 'yes', I'd agree with you, though I guess the answer to "who cares?" is that whomever wrote it cared. They could have a legit performance reason or may just have done it to show they could.
https://news.ycombinator.com/item?id=27862463
I think this person is just mentally ill unfortunately.