C language knowledge (1) -- Philosophy and Characteristics(C语言 基本知识1)

C language knowledge (1) -- Philosophy and Characteristics

 

C (programming language)

From Wikipedia, the free encyclopedia

C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system.[1] It has since spread to many other platforms. Although predominantly used for system software,[2][3] C is also widely used for applications. C has also greatly influenced many other popular languages,[4] especially C++, which was designed as an enhancement to C.

Philosophy

C is an imperative (procedural) systems implementation language. Among its minimalistic design goals were that it could be compiled in a straightforward manner using a relatively simple compiler, provide low-level access to memory, generate only a few machine language instructions for each of its core language elements, and not require extensive run-time support. C is therefore suitable for many applications that had traditionally been implemented in assembly language.

Despite its low-level capabilities, the language was designed to encourage machine-independent programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with minimal change to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers.

Characteristics

As most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. Parameters of C functions are always passed by value. Pass-by-reference is achieved in C by explicitly passing pointer values. Heterogeneous aggregate data types (the struct in C) allow related data elements to be combined and manipulated as a unit. C has around 30 reserved keywords and the source text is free-format, using semicolon as a statement terminator (not a delimiter).

C also exhibits the following more specific characteristics:

  • Non-nestable function definitions, although variables may be hidden in blocks to any level of depth
  • Partially weak typing, for instance, characters can be used as integers in a way similar to assembly
  • Low-level access to computer memory via machine addresses and typed pointers
  • Function pointers allowing for a rudimentary form of closures and runtime polymorphism
  • Array indexing as a secondary notion, defined in terms of pointer arithmetic
  • A standardized C preprocessor for macro definition, source code file inclusion, conditional compilation, etc.
  • Complex functionality such as I/O and mathematical functions consistently delegated to library routines
  • Syntax divergent from ALGOL, often following the lead of C's predecessor B, for example using
    • { ... } rather than ALGOL's begin ... end
    • the equal-sign for assignment (copying), much like Fortran
    • two consecutive equal-signs to test for equality (compare to .EQ. in Fortran or the equal-sign in BASIC)
    • && and || in place of ALGOL's and and or, which
      • are syntactically distinct from the bit-wise operators & and | (B used & and | in both meanings)
      • never evaluate the right operand if the result can be determined from the left alone (short-circuit evaluation)
    • a large number of compound operators, such as +=, ++, etc.

 

Reference:
http://en.wikipedia.org/wiki/C_(programming_language)

(中文)Chinese C wiki page: http://zh.wikipedia.org/wiki/C%E8%AF%AD%E8%A8%80
 

 

Comments:

Post a Comment:
Comments are closed for this entry.
About

williamxue

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today