Application Domains of Programming Languages 1. Scientific Application Original application. Keys: Mathematical and statistical computations such as Numerical analysis Regression analysis Linear Programming Integer Programming Statistical analysis and testing Amount of input data: often relatively small except some cases like Satellite data acquisition Compute-bound Floating-point representation precision important REAL*8, Double Precision type Availability of scientific subroutine/function packages. Typical languages: FORTRAN, Pascal, APL, BASIC 2. Business Processing Keys: Record/File processing: creation, maintenance, extraction and summarization. Alphanumeric data processing Data volume large, little arithmetic computation, extensive I/O bound. Batch processing as opposed to interactive processing. Iterative processing as opposed to Recursive Processing. Typical languages: COBOL, PL/I 3. Text Processing: Manipulation of natural language text. Keys: Pattern matching String variables of dynamic length typically implemented by pointers. Recursive pattern definition (as in SNOBOL) Pat = 'A' | *Pat 'B' // This defines a Pattern that contains all of 'A' 'AB' 'ABB' 'ABBB' 'ABBBB' **and many more // Another Example Balanced = BAL $ Output &Anchor = 1 // Anchored Pattern Matching A+B*(C+D)*(E+F)+G Balanced Fail // Above pattern matching statement will produce the following // outputs: A A+ A+B A+B* A+B*(C+D) A+B*(C+D)* A+B*(C+D)*(E+F) A+B*(C+D)*(E+F)+ A+B*(C+D)*(E+F)+G Dynamic scope rule. Typical languages: SNOBOL C Java 4. Artificial Intelligence: Intelligent behavior including logical inference capability. Keys: Efficient space search based on heuristics. Predicate manipulation (PROLOG) Manipulation of relations among objects. (LISP, Scheme) Symbolic Computation as opposed to Numeric or String. Scheme: (define remove-first (lambda (elem listt) (if (null? listt) '() (if (eq? elem (car listt)) (cdr listt) (cons (car listt) (remove-first elem (cdr listt))) )))) ; removes the first matching element only ;; (remove-first 'a '(b c a b a b)) will be (b c b a b) (define remove-all (lambda (elem listt) (if (null? listt) '() ; An empty-list (if (eq? elem (car listt)) (remove-all elem (cdr listt)) ; keep removing (cons (car listt) (remove elem (cdr listt))) )))) ; removes all matching elements ;; (remove-all 'a '(b c a b a b)) will be (b c b b) ;; Another example: Currying Transformation (define f (lambda (a b c) (+ a b c))) ;; A procedure with three arguments ;; (f 10 20 30) will be 60 (define new-f (lambda (x) (lambda (y) (lambda (z) (f x y z) )))) ;; A procedure with one argument. ;; (((new-f 10) 20) 30) will be 60 Recursion and Backtracking //////////////////////////////////// PROLOG: above(A,B) :- A>B. below(X,Y) :- above(X,Y) , ! , fail. // A rule with a "Cut" below(X,Y). // A fact about two variables X and Y parents(david,chris). // A fact parents(david,donna). parents(chris,cassy). parents(chris,skyler). parents(donna,john). parents(john,smart). parents(john,beauty). ancestor(X,Y) :- parents(X,Y). ancestor(X,Y) if parents(X,T), ancestor(T,Y). solve(X,Y) :- ancestor(X,Y), output(X,Y), fail. solve(X,Y). output(X,Y) if write ("\n", X, " is an ancestor of ", Y). // This clause is not to be resatisfied upon backtracking. Application areas: Game Playing Natural Language Processing Expert Systems Automatic Reasoning Robotics 5. Systems Programming Keys: Providing interface between computer hardware and users/operators Effectively dealing with unpredictable events such as I/O errors and runtime interrupts. Close relation to computer's micro-operations. Typical languages: Assembly languages Ada, C Application areas: Compilers/Interpreters Assemblers. I/O routines. CPU Schedulers 6. Simulation Keys: Effective Transaction/Event processing Providing queuing systems Random number generations Easy and automatic statistic collections. Typical Languages: Simula67 (First language with 'class' and abstract data) Simscript GPSS: An example: GPSS // A single-server queuing system. GENERATE 100,50,,1000 // 100=Average Generation Time * 50=Half Range of the uniformly distributed * interarrival time, and 1000=Limit Count RETRY QUEUE WQUEUE SEIZE TELLER DEPART WQUEUE ADVANCE 40,10 RELEASE TELLER TRANSFER .250,,RETRY TERMINATE 7. WWW Application Keys: Event-driven programming for effective GUI applications Object-oriented programming for effective event handling and exception handling. Typical languages: Java, Javascript !Click here for a Javascript Example!