3 ms·
He didn't write the first one with "printf()". https://www.bell-labs.com/usr/dmr/www/btut.pdf https://www.bell-labs.com/usr/dmr/www/btut.pdf
by kick 7y ago
He didn't write the first one with "printf()".
https://www.bell-labs.com/usr/dmr/www/btut.pdf https://www.bell-labs.com/usr/dmr/www/btut.pdf
- tptacek 7y agoBecause he didn't have it in B. The K&R C "Hello World" uses printf(), which itself does a whole bunch of crap other than printing out "hello world".
- saagarjha 7y agoMhm, like being recognized as constant by the compiler and turned into a call to puts?
- tptacek 7y agoSomething Kernighan's compiler didn't do.
- overgard 7y agoHow is a 40 year old compiler relevant?
- tptacek 7y agoKernighan had puts(3) available, but chose printf(3), which does a lot more than puts. The point is Kernighan, not the compiler.
- saagarjha 7y agoTheir libc probably put the characters out slowly one-by-one for both of them, so the difference was probably just a branch or two. Not a whole set of extra syscalls.