News for hackers. Stuff that matters.
Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU Coreutils Impl... by Zenst on Saturday February 21, 2015 @08:59PM (#9087861)
Wonderful to see the various flavours of the same simple command. Though GNU using a goto for what at quick glance is a non error situation does not sit well with me, but probably personal taste in code.

ALso surprised how many library's the FreeBSD and GNU flavours want to pull in.

Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU Coreutils Impl... by stock_toaster on Saturday February 21, 2015 @09:54PM (#9088006)
Looking at the history of echo.c in the freebsd tree[1] is pretty interesting too. Seems before this [2] commit (apparently fixes for performance with many arguments) it was pretty simple.

[1]: https://github.com/freebsd/freebsd/blob/master/bin/echo/echo...

[2]: https://github.com/freebsd/freebsd/commit/cbf5708f4336b824b8...

Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU Coreutils Impl... by userbinator on Sunday February 22, 2015 @01:02AM (#9088441)
To me this feels like a classic case of "premature optimisation" - by increasing the complexity of the code quite a bit (even adding dynamic allocation), they managed to save only 40 milliseconds on a benchmark involving the echoing of 1000 arguments.

Using 1000 arguments does not seem at all a typical use case for echo.

Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU Coreutils Impl... by jlarocco on Sunday February 22, 2015 @01:50AM (#9088544)
I'm not sure "premature" is the right word. I mean, they benchmarked, and maybe even profiled, and made it faster.

My guess is that somone had a weird use case for echo where the old version was slow. He benchmarked, profiled, made some changes, and submitted a patch. "The source code is too long," is a crappy argument, so might as well use the faster, longer code.

Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU Coreutils Impl... by ild on Sunday February 22, 2015 @01:28PM (#9090351)
Well 40 ms can be a lot or a little, depending on the number after optimization. If, for example the input was 1000 1-letter arguments, 40 ms to output 2kb is too much.