PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY Dr. John Georgas, Northern Arizona University Copyright John Georgas All Rights Reserved Outline Current Programming languages Compiled and interpreted implementations Key characteristics History of languages and evolution Programming Languages Enable constructing representations of a computational process; well-defined algorithms processing information Ultimately mapping to machine instructions Many-to-one programs to computational process Syntax and associated semantics Fundamentally just like human languages and form of expression Non-functional properties become critical Style vs. substance Preferences often driven by stylistic or ease of use characteristics rather than fundamental features n i.e. syntactic sugar and library availability 1
Language families Declarative Functional (LISP) Logic (Prolog) Imperative (Fortran, C, Java) Currently dominant paradigm Language Implementations Layered architectures Mappings from highlevel to low-level instructions Compiler-based implementations Mapping High-level syntax to machine code n Plus linking of external resources Advantages: (Usually) faster execution due to optimizations n Both algorithmic and machinespecific Disadvantages: Compiled code coupled to specific hardware architecture Long iterative cycle Requires complete program 2
Interpreter-based implementations Mapping High-level syntax executed by interpreter Interpreter wraps around machine and maps to machine code Advantages: Higher accessibility n Ease of experimentation Portable from machine to machine n As long as an interpreter exists for each Dynamic code generation Disadvantages: (Usually) slower due to interpreter layer Hybrid implementations Mapping High-level syntax to interpreter instructions (intermediate representation) n Or purely interpreted Interpreter still wraps around machine and maps intermediate representation to machine code Advantages: Improved performance (over fully interpreted options) n Enabling compiler-type optimizations Higher accessibility Intermediate representation portable from machine to machine Disadvantages: Longer iterative cycle than fully interpreted options (Usually) still slower due to interpreter layer Some Essential Characteristics Binding Association between entity and attribute n Type bindings: static/dynamic, implicit/explicit n Storage bindings: static, stack, heap Scope Lexical region over which a variable is defined n Static (lexical) scope, dynamic scoping Type equivalence Name/structure Abstraction Support for defining new composite elements 3
Brief History of Languages Machine code Low-level invocations of core machine instructions Assembly language Addition of mnemonics and labels 11 000 011 add ax, bx mov a, ax (IBM Mathematical Formula Translating System) FORTRAN (~1955) Move toward more natural expressiveness n Addition of subprograms and more robust expressions of branching and control flow Static memory allocation and strict naming conventions X = 0 15 X = X + 1 IF (X.LT. 10) GOTO 15 42 CONTINUE (Algorithmic Language) ALGOL (~1958) Influential features: blocked variable scoping, dynamic memory, compound/nested structures n Effort also led to important formal contributions (e.g. BNF) IF (.NOT.(condition)) GOTO 100 statementt1 statementtn GOTO 200 100 statementf1 statementfn 200 CONTINUE if condition then statementt1; statementtn; else statementf1; statementfn; 4
(List Processing Language) LISP (~1959) Functional programming focused on AI applications; essentially recursive n Dynamic memory allocation and deallocation (cond ((= x 0) 0) ((= x 1) 1) (else (+ (fib (- x 1)) (fib (- x 2))))) (Common Business-Oriented Language) COBOL (~1959) Customized for business applications; effort toward English-like syntax 01 Num1 PIC 9 01 Num2 PIC 9 01 Result PIC 99 DISPLAY "Enter First Number ACCEPT Num1 DISPLAY "Enter Second Number ACCEPT Num2 IF TRUE THEN ADD Num1, Num2 GIVING Result END-IF DISPLAY "Result is = ", Result : " WITH NO ADVANCING : " WITH NO ADVANCING (Simulation Language) SIMULA (~1964) Introduction of object-oriented principles class Storer(x); integer x; integer procedure getx; getx := x; Storer; ref(storer) s; s :- new Storer(1); s.getx; 5
C (~1972) Developed as part of UNIX OS Close to the metal n With great power comes great responsibility Early feature sampling: No robust types/structures, pointers and pointer arithmetic, manual memory management C with Classes and C++, Java (Programming in Logic) Prolog (~1972) Declarative programming focusing on inferences based on facts and rules parent(x, Y) :- father(x, Y). father(adam, Cain). :- parent(x, Cain). 6