Comment on Bell Labs 'Unix' Tape from 1974 Successfully Dumped to a Tarball
xthexder@l.sw0.com 15 hours agoHello World in 1974: echo.c
main(argc, argv) int argc; char *argv[]; { int i; argc--; for(i=1; i<=argc; i++) printf("%s%c", argv[i], i==argc? '\n': ' '); }
ZoteTheMighty@lemmy.zip 15 hours ago
Bloat, they wasted an extra integer operation with
argc–.xthexder@l.sw0.com 15 hours ago
I think it’s actually quite elegant. No matter what it has to skip over argument 0 which will be the executable name
echo.If the subtraction was removed and the loop changed to
<, it would then need to do an addition or subtraction inside the loop to check if it’s the last argument.palordrolap@fedia.io 15 hours ago
The real question might be whether the compiler was smart enough to change
var++andvar--into++varand--varwhen the initial values aren't needed.As compiler optimisations go, it's a fairly obvious one, but it was 1974 and putting checks like that in the compiler would increase its size and slow it down when both space and time were at a premium.
xthexder@l.sw0.com 15 hours ago
Well, good news, the source code is right there. Someone can go check (it probably won’t be me)
a_non_monotonic_function@lemmy.world 11 hours ago
I was going to guess the same regarding the time period.
surewhynotlem@lemmy.world 15 hours ago
Or they just drop the =