3 ms·
I largely disagree with this article. C has too many pitfalls that a beginner can either be discouraged by a non-working program, or not understanding the subtl
by nayuki 9y ago
I largely disagree with this article. C has too many pitfalls that a beginner can either be discouraged by a non-working program, or not understanding the subtle gotchas.
Avoiding undefined behavior in C is difficult, even for experts. Failing to understand UB leads to very inconsistent, often latent, hard-to-debug situations long after the bug has occurred. Other languages - including assembly language - don't have this extremely hostile concept of UB. C encourages bad habits like ignoring error codes from I/O functions. Also, doing concurrency correctly in C (or Java for that matter) is a grand effort, but is easier in languages like Go and Rust.
Managing language minutiae in C, like function prototypes and header files, is something not found in newer languages. Another problem is having a global namespace instead of a more structured, modularized one (C++, Java, Python, etc.). And finally, manual memory management means that a lot of extra code is written (contrary to the author's claims about conciseness), and it especially makes string processing hard.
Personally, I only use C to implement cryptographic primitives (ciphers and hash functions) and some numerical kernels. These are straightforward calculations that don't require memory management or tricky pointer arithmetic.
- ramzyo 9y ago> C has too many pitfalls that a beginner can either be discouraged by a non-working program, or not understanding the subtle gotchas. Totally agree with you - personally C would have been a very difficult first language for me. Java and Ruby were tough enough at the outset when I started down the programming path. Now I work primarily in C and have been doing so for the last four years or so. Still get hung up on subtle gotchas, especially when interfacing with hardware!
- ayae 9y agoI don't think most of these pitfalls are very problematic for a beginner trying to play with the machine and to understand how things work. > doing concurrency correctly in C (or Java for that matter) is a grand effort And that makes it a great teaching tool for exploring how concurrency works, and what issues arise because of concurrency, in a way that other languages don't expose. It's definitely not easy, but understanding how to use (manual) locking/reference counting/memory barriers can be pretty fun (and I'm not saying it's relevant to every developer). > contrary to the author's claims about conciseness C is a conscise language in the sense that the language itself (its specification) is quite small. The code you write with it can be quite verbose.