Anda di halaman 1dari 4

Chapter 1

i. What is C programming language?


ii.
Evolution of programming languages
iii.
Origins of C
iv.
Background information: Compilers and Interpreters
v.
Modular compilation of programs

A programming language is an artificial language designed to communicate instructions to a machine,


particularly a computer. Programming languages can be used to create programs that control the behavior of
a machine and/or to express algorithms precisely.
C is a general purpose programming language developed in 1972 by Dennis Ritchie at Bell Labs. Initially,
there was no formal specification of C language. The book "The C Programming Language" by Brian
Kernighan and Dennis Ritchie published in 1978 served as the informal specification for the first version of
C language.
In 1989, American National Standards Institute (ANSI) established a standard specification of C language
called: "ANSI X3.159-1989 - Programming Language C".
In 1999, a major revision of ANSI C specification was published by the International Organization for
Standardization (ISO), "ISO/IEC 9899:1999 - Programming Languages - C".
Main features of C language:

C is a procedural programming language, not an object-oriented programming language. C programs


are organized as modules and functions.

C supports low-level access to memory using address pointers. This makes C language a choice for
implementing system software.

C supports array data structure with two ways to access array elements, indexes and pointers.

C supports dynamic memory allocation, which helps to reduce the size of object file generated by the
compiler, and allow arrays to be declared with sizes determined at runtime.

C supports a large number of library routines for input/output operations, string manipulations,
mathematical functions, etc.

C uses a header file to share declarations of variables and functions of a program module with other
modules.

C does not do bounds checking on arrays. This often leads to un-desired behaviors during program
execution.

Terms related to programming language and their execution


A compiler is a special program that processes statements written in a particular programming language and
turns them into machine language or "code" that a computer's processor uses. Typically, a programmer
writes language statements in a language such as Pascal or C one line at a time using an editor . The file that
is created contains what are called the source statements . The programmer then runs the appropriate
language compiler, specifying the name of the file that contains the source statements.
When executing (running), the compiler first parses (or analyzes) all of the language statements syntactically
one after the other and then, in one or more successive stages or "passes", builds the output code, making
sure that statements that refer to other statements are referred to correctly in the final code. Traditionally, the
output of the compilation has been called object code or sometimes an object module . (Note that the term
"object" here is not related to object-oriented programming .) The object code is machine code that the
processor can process or "execute" one instruction at a time.

The Basic Structure of a Compiler


The five stages of a compiler combine to translate a high level language to a low level language, generally
closer to that of the target computer. Each stage, or sub-process, fulfills a single task and has one or more
classic techniques for implementation.
Component

Purpose

Lexical Analyzer

Analyzes the Source Code


Removes "white space" and comments
Formats it for easy access (creates tokens)
Tags language elements with type information
Begins to fill in information in the SYMBOL TABLE **

Syntactic
Analyzer

Analyzes the Tokenized Code for structure


Amalgamates symbols into syntactic groups
Tags groups with type information

Semantic
Analyzer

Analyzes the Parsed Code for meaning


Fills in assumed or missing information
Tags groups with meaning information

Code Generator

Linearizes the Qualified Code and produces the equivalent Object Code

Optimizer

Examines the Object Code to determine whether there are more efficient means of
execution

** The Symbol Table is the data structure that all elements of the compiler use to collect and share
information about symbols and groups of symbols in the program being translated.
Definition: In computing, an interpreter is a computer program that reads the source code of another
computer program and executes that program.
Because it is interpreted line by line, it is a much slower way of running a program than one that has been
compiled but is easier for learners because the program can best opted, modified and rerun without timeconsuming compiles.
Compiler vs. Interpreter
An interpreter translates some form of source code into a target representation that it can immediately
execute and evaluate. The structure of the interpreter is similar to that of a compiler, but the amount of time
it takes to produce the executable representation will vary as will the amount of optimization. The following
diagram shows one representation of the differences.

Compiler characteristics:
spends a lot of time analyzing and processing the program
the resulting executable is some form of machine- specific binary code
the computer hardware interprets (executes) the resulting code
program execution is fast
Interpreter characteristics:
relatively little time is spent analyzing and processing the program
the resulting code is some sort of intermediate code
the resulting code is interpreted by another program
program execution is relatively slow