Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.


C is an imperative, procedural programming language invented in the early days of UNIX in the 1970s, adopted by the majority of UNIX systems.[1] The language was initially implemented by Dennis Ritchie whilst working at Bell Labs, and later formalized through a series of standards, both by the committees and the author himself. For UNIX users, C facilitates the compilation of computer programs through a compiler, a program that translates an expression tree into machine code. Ritchie himself had produced his own C compiler for the DEC PDP-11, however this lacked the portability, problematic for adoption by the dynamically evolving UNIX landscape; this issue would later be addressed by companies distributing UNIX and corresponding C compilers and pre-processors for their respective machines and instruction sets.[2]

The running, open standard, initially orchestrated by ANSI in 1989, now managed by the C Language Working Group, defines what is formally recognized as "the C Programming Language".[3] Some popular compilers for the C programming language include GNU GCC, Clang, TCC and MSVC, and less commonly Borland Turbo C, ICC, LCC, PCC and ACK (typically in legacy or "mission critical" systems). Many UNIX operating systems like OpenBSD, FreeBSD and NetBSD use the Clang compiler toolchain, however, for example, Illumos[4] and Plan 9[5] use the portable C Compiler and Plan 9 C compiler respectively.

C, as with many popular languages,[6][7][8][9][10][11] has a standard library known as a libc (given by its filename on many UNIX systems)[12], however unlike other popular programming languages, there is significant fragmentation between specific implementations of several C standard library.[13][14] Some popular libc implementations include dietlibc, musl, GNU glibc, mlibc, Newlib and uClibc.[15] It is advised by developers to ensure non-standard extensions are kept to a minimum, or otherwise use preprocessor directives to compile particular expressions depending on the active libc and/or target.[16] Note, many incompatibility concerns can be successfully alleviated through many automated build tools such as GNU Autotools, CMake, Meson, Zig's build toolchain among a plethora others, however for ideological[17][18][19] and practical[20][21][22] reasons these tools may wish to be avoided.

When approaching a C codebase, it is typical to find files entitled INSTALL and README, typically with either Markdown or Asciidoc extensions, and less commonly Roff and Tex files, which need to be processed by external tools besides your pager to recover useful information (they are often used in the context of academic projects or programs predating the success of Markdown and similar mark-up language). These files typically outline the configuration, building and installation for a variety of supported platforms and components, as well as outlining the dependencies and development headers used in the compilation and linking process.[23][24] Upon successful installation, a binary with the appropriate headers for your CPU architecture and binary format (on UNIX, typically ELF) will appear in your file tree, which can be executed unprivileged via its path or through its filename (assuming the binary's installation directory is appended to your user's $PATH variable). If a project doesn't provide such facilities, knowledge of your preferred C compiler and linker may be useful in attempting to compile and link binaries for your (or other) systems.

When writing C, for contributing to open source projects, there are several major coding standards and style guides you should make yourself aware of, each describing the syntactic, naming, meta-programming and structural components of a C code base; these may include GNU Coding Standards , Linux kernel coding style, Plan 9 Coding Conventions, Suckless Coding Style, "Pike Style", NetBSD Source Code Style Guide, however many more exist and vary on a project-by-project basis. It is always preferable to respect a projects' expected style for a variety of reasons, namely, consistency within the code base, appropriate patch application, code review automation, and maintainability.[25]

Learning C is an integral part of beginning contribution to the majority of open source code bases, however it isn't particularly an easy task, especially with little background in computer programming or limited knowledge of hardware design and operating system design & interfaces. Many resources and online books are listed below:

  1. Ritchie, Denis & Kernighan, Brian (1988). C Programming Language: https://a.co/d/6Yrgcfo
  2. The FreeBSD Documentation Project (1995–2024). FreeBSD Developers' Handbook: https://docs.freebsd.org/en/books/developers-handbook/
  3. Gustedt, Jens (2019). Modern C: https://www.manning.com/books/modern-c
  4. Learn X in Y minutes (n.d.). Where X=C: https://learnxinyminutes.com/docs/c/
  5. Learn C: https://www.learn-c.org/
  6. Miller, Dean & Perry, Greg (n.d.). C Programming Absolute Beginner's Guide (3rd ed.): https://a.co/d/5558uzl
  7. Seacord, Robert (n.d.). Effective C: An Introduction to Professional C Programming: https://a.co/d/i3q6T2M

Criticisms of C are abundant and controversial,[26] many attribute issues regarding C to fragmentation and portability issues,[27] lack of type safety and primitive resource access checks,[28] poor administration on part of the C Language Working Group,[29] and overall worsening over time.[30][31]

References

  1. https://dl.acm.org/doi/10.1145/2509136.2509515
  2. https://thechipletter.substack.com/p/a-history-of-c-compilers-part-1-performance
  3. https://en.cppreference.com/w/c/language/history
  4. https://hackaday.com/2023/07/16/illumos-gets-a-new-c-compiler/
  5. https://9p.io/sys/doc/compiler.html
  6. https://smlfamily.github.io/Basis/
  7. https://doc.rust-lang.org/beta/std/index.html
  8. https://ziglang.org/documentation/master/std/
  9. https://docs.oracle.com/javase/8/docs/api/allclasses-frame.html
  10. https://www.scala-lang.org/api/current/
  11. https://ocaml.org/manual/5.2/api/index.html
  12. https://www.musl-libc.org/faq.html
  13. https://wiki.musl-libc.org/compatibility
  14. https://www.fefe.de/dietlibc/FAQ.txt
  15. https://wiki.osdev.org/C_Library
  16. https://nullprogram.com/blog/2017/03/30/
  17. https://suckless.org/sucks/
  18. https://www.interaction-design.org/literature/topics/keep-it-simple-stupid
  19. http://harmful.cat-v.org/software/GNU/auto-hell
  20. https://twdev.blog/2021/08/cmake/
  21. https://silverhammermba.github.io/blog/2023/01/06/gradle
  22. https://web.archive.org/web/20181118080003/http://freshmeat.sourceforge.net/articles/stop-the-autoconf-insanity-why-we-need-a-new-build-system
  23. https://github.com/Mercury-Language/mercury
  24. https://github.com/NetBSD/src
  25. https://docs.kernel.org/process/5.Posting.html
  26. https://web.mit.edu/~simsong/www/ugh.pdf
  27. http://doc.cat-v.org/henry_spencer/ifdef_considered_harmful
  28. https://www.researchgate.net/publication/371166462_C_Programming_Language_A_Review
  29. https://cor3ntin.github.io/posts/c/
  30. https://www.i-programmer.info/news/184-cc/16204-c23-what-we-have-to-suffer.html
  31. https://wiki.theory.org/YourLanguageSucks