Chapter 1 -- The Role of the Programming Language
Why have them?
-
They provide a convenient way to express to a computer what we want to
happen.
-
They provide a portable way of expressing a program.
-
Because assembly is just too painful for large scale use.
Some Important Features of Programming Languages
-
They are generally slower than assembly.
-
They generally take more space than assembly.
-
They save programmer time (which can be used to optimize speed or space).
Types of Programming Languages
-
Some are general purpose (C++) and others are specialized (Simula, Mathmatica).
-
Imperative: Programs are a list of action to be taken (C, Basic,
Fortran, Pascal).
-
Functional: Programs are a set of functions to be called
-
Don't have a loop, just call yourself recursively.
-
Lisp is the most common example.
-
Object Oriented: Package data with code, call the result an object
-
Nice way to promote code reuse.
-
Nice way to organize large codes
-
Not great for small programs.
-
Logical Programing: Write the program as a sequence of assertions,
let the computer figure out the rest.
-
GREAT when in the right domain.
-
HORRIBLE otherwise.
Implementations of a Programming Language
-
Compiler
-
Idea: Convert the P.L. into machine code
-
Advantages: Fast execution
-
Disadvantages: Need to compile, not portable, poor debugging, large
space required
-
Interpreter
-
Idea: Run the P.L. directly
-
Advantages: Portable, flexible
-
Disadvantages: Slow execution, run time needed
-
PseudoCode
-
Idea: Convert the P.L. to machine code for some virtual machine,
run that
-
Advantages: Portable
-
Disadvantages: Medium execution, run time needed, poor debugging
Levels of Programming Language
-
Machine Language -- 10101010101010111010101
-
Completely unintelligable
-
Required by the CPU
-
Sometimes done by hand
-
Assembly -- MV R1, R3
-
Non-portable
-
Optimally fast
-
One-to-one with machine language
-
Really painful as a programming language
-
Third Generation
-
This is the imperative languages (C, Cobol, Fortran, Basic)
-
Popular in the 60's thru 80's
-
Fourth Generation Languages
-
First meaning -- Object Oriented
-
Second meaning -- Cool advertising slogan that solves all problems
But where is Prolog and Lisp????