The Role of the Programming Language

Why have them?

  1. They provide a convenient way to express to a computer what we want to happen.

  2. They provide a portable way of expressing a program.

  3. Because assembly is just too painful for large scale use.

Levels of Programming Language

  1. Machine Language -- 10101010101010111010101

    1. Completely unintelligable

    2. Required by the CPU

    3. Sometimes done by hand (really, honestly, actually)

  2. Assembly -- MV R1, R3

    1. Non-portable

    2. Optimally fast

    3. One-to-one with machine language

    4. Really painful as a programming language

  3. Third Generation

    1. This is the imperative languages (C, Cobol, Fortran, Basic)

    2. Popular in the 60's thru 80's

  4. Fourth Generation Languages

    1. First meaning -- Object Oriented

    2. Second meaning -- Cool advertising slogan that solves all problems

    3. Second meaning (v2) – Domain specific programming language

  5. But where is Prolog and Lisp????

Some Important Features of Programming Languages

  1. They are generally slower than assembly.

  2. They generally take more space than assembly.

  3. They save programmer time (which can be used to optimize speed or space).

Types of Programming Languages

  1. Some are general purpose (C++) and others are specialized (Simula, Mathmatica).

  2. Imperative:  Programs are a list of action to be taken (C, Basic, Fortran, Pascal).

  3. Functional:  Programs are a set of functions to be called

    1. Don't have a loop, just call yourself recursively.

    2. Lisp is the most common example.

  4. Object Oriented:  Package data with code, call the result an object

    1. Nice way to promote code reuse.

    2. Nice way to organize large codes

    3. Not great for small programs.

  5. Logical Programing:  Write the program as a sequence of assertions, let the computer figure out the rest.

    1. GREAT when in the right domain.

    2. HORRIBLE otherwise.

Implementations of a Programming Language

  1. Compiler

    1. Idea:  Convert the P.L. into machine code

    2. Advantages:  Fast execution

    3. Disadvantages:  Need to compile, not portable, poor debugging, large space required

  2. Interpreter

    1. Idea:  Run the P.L. directly

    2. Advantages:  Portable, extensible code possible

    3. Disadvantages:  Slow execution, run time needed

  3. Just In Time Compiler

    1. Idea: Compile it on first execution .. run the compiled code thereafter

    2. Advantage: Faster than an interpreter, no need for the programmer to compile, extensible code possible

    3. Disadvantages: Execution speed between compiled and interpreted, not portable, COMPLEX

  4. PseudoCode

    1. Idea:  Convert the P.L. to machine code for some virtual machine, run that

    2. Advantages:  Portable

    3. Disadvantages:  Medium execution, run time needed, poor debugging