news.volyx.in

Everything I wish I knew when learning C (tmewett.com)

738 points by bubblehack3r · 1379 days ago · 391 comments on HN

Article summary

The article discusses the challenges of learning C programming and provides a collection of summaries, signposts, and advice for navigating the language. It covers topics such as compilation, linking, headers, and symbols, as well as undefined behavior, essential compiler flags, and memory management. The article also touches on naming conventions, the struct method pattern, and platform-specific APIs. The goal is to provide a useful resource for those learning C and other compiled languages.

Main themes

  • C programming challenges
  • pointer syntax and semantics
  • compiler flags and debugging
  • naming conventions and standards
  • memory management and undefined behavior
  • language learning and pedagogy

What commenters say

  • The syntax for declaring pointers in C can be confusing, especially for beginners.
  • The use of multiple declarations in C can lead to ambiguity and is generally frowned upon.
  • Some argue that learning a language other than C first can make it easier to understand pointers and other concepts.
  • The inclusion of certain compiler flags, such as -fsanitize=address,undefined, can be useful for debug builds but may be too heavyweight for production.
  • The C standard's use of undefined behavior for certain naming rules, such as those ending in _t, can be confusing and may not always trigger a compilation error.
  • The purpose of the naming rule is to allow for the addition of new typedefs, and the undefined behavior provision gives compilers flexibility.
  • The declaration of a type without a full definition can lead to unpredictable behavior if multiple translation units use differing definitions.