Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Rationale for use in systems programming === [[File:The C Programming Language.png|thumb|Some software written in C]] C is widely used for [[systems programming]] in implementing [[operating system]]s and [[embedded system]] applications.<ref name="Zh3CW">{{Cite book|title=Programming and problem solving with C++ |edition=6th |last1=Dale |first1=Nell B. |last2=Weems |first2=Chip |year=2014 |location=Burlington, Massachusetts |publisher=Jones & Bartlett Learning |isbn=978-1449694289 |oclc=894992484}}</ref> This is for several reasons: * The C language permits platform hardware and memory to be accessed with pointers and [[type punning]], so system-specific features (e.g. [[Control/Status Register]]s, [[Memory-mapped I/O|I/O registers]]) can be configured and used with code written in C β it allows fullest control of the platform it is running on. * The code generated after compilation does not demand many [[runtime system|system features]], and can be invoked from some boot code in a straightforward manner β it is simple to execute. * The C language statements and expressions typically map well on to sequences of instructions for the target processor, and consequently there is a low [[Run time (program lifecycle phase)|run-time]] demand on system resources β it is fast to execute. * With its rich set of operators, the C language can use many of the features of target CPUs. Where a particular CPU has more esoteric instructions, a language variant can be constructed with perhaps [[intrinsic function]]s to exploit those instructions β it can use practically all the target CPU's features. * The language makes it easy to overlay structures onto blocks of binary data, allowing the data to be comprehended, navigated and modified β it can write data structures, even file systems. * The language supports a rich set of operators, including bit manipulation, for integer arithmetic and logic, and perhaps different sizes of floating point numbers β it can process appropriately-structured data effectively. * C is a fairly small language, with only a handful of statements, and without too many features that generate extensive target code β it is comprehensible. * C has direct control over memory allocation and deallocation, which gives reasonable efficiency and predictable timing to memory-handling operations, without any concerns for sporadic ''[[stop-the-world]]'' garbage collection events β it has predictable performance. * C permits the use and implementation of different [[C dynamic memory allocation|memory allocation]] schemes, including a typical {{code |lang=c |malloc}} and {{code |lang=c |free}}; a more sophisticated mechanism with [[Region-based memory management|''arenas'']]; or a version for an [[OS kernel]] that may suit [[Direct memory access|DMA]], use within [[interrupt handler]]s, or integrated with the [[virtual memory]] system. * Depending on the linker and environment, C code can also call libraries written in [[assembly language]], and may be called from assembly language β it interoperates well with other lower-level code. * C and its [[calling convention]]s and linker structures are commonly used in conjunction with other high-level languages, with calls both to C and from C supported β it interoperates well with other high-level code. * C has a very mature and broad ecosystem, including libraries, frameworks, open source compilers, debuggers and utilities, and is the de facto standard. It is likely the drivers already exist in C, or that there is a similar CPU architecture as a back-end of a C compiler, so there is reduced incentive to choose another language.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)