I share the frustration the author describes. When I started out programming as a child, I used Turbo Pascal, but I was aware of Turbo C and that more people used that than Pascal. Nevertheless, I couldn't really wrap my head around C at the time, and it was partly due to linker errors that I couldn't understand; and it seemed that Turbo Pascal just didn't use a linker, so it was easier to understand and tinker with at age 9.
It's intriguing to think how different my experience could have been if educational material at the time had focused as much on full explanations of the compiler+linker process, including example error conditions, as it did on teaching the language.
30 years later, I like to claim that I have a reasonably workable understanding of how compilers work, but I'm still nebulous on how linkers do what they do. I'm much more comfortable with higher-level compilers such as C# that compile to a VM bytecode (IL) and don't worry about linkers.
lynx97 · 4h ago
Nitpick: Almost all Hello World C examples are wrong. printf is for when you need to use a format string. Hello World doesn't. Besides:
> puts() writes the string s and a trailing newline to stdout.
int main() { puts("Hello World!"); }
PhilipRoman · 3h ago
Eh, it compiles down to the same thing with optimizations enabled:
But I agree, using printf for constant strings is one step away from doing printf(x) which is a big no-no.
Joker_vD · 3h ago
Useless bit of compiler optimizations trivia: the "this printf() is equivalent to puts()" optimization seems to work by looking for the '%' in the format string, not by counting whether there is only one argument to printf(), e.g. if you add 42 as a second argument to the printf() — which is absolutely legal and required by the standard to Work as Intended™ — the resulting binary still uses puts().
unwind · 2h ago
I agree, but I have to point out that if you're gonna be like that, then you should be explicit about your final
It's intriguing to think how different my experience could have been if educational material at the time had focused as much on full explanations of the compiler+linker process, including example error conditions, as it did on teaching the language.
30 years later, I like to claim that I have a reasonably workable understanding of how compilers work, but I'm still nebulous on how linkers do what they do. I'm much more comfortable with higher-level compilers such as C# that compile to a VM bytecode (IL) and don't worry about linkers.
> puts() writes the string s and a trailing newline to stdout.
int main() { puts("Hello World!"); }
https://godbolt.org/z/zcqa4Txen
But I agree, using printf for constant strings is one step away from doing printf(x) which is a big no-no.