Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
FORTRAN 1955 Procedural SQL 1986 Database ALGOL 1958 Procedural Perl 1987 Tex extractoion COBOL 1959 Procedural HTML 1994 Hypertext BASIC 1963 Procedural LISP 1958 Functional Pascal 1971 Procedural Scheme 1975 Functional C 1974 Procedural Prolog 1972 Logic Modula-2 1977 Procedural Occam 1987 Parallel Ada 1979 Parallel Linda 1987 Parallel Smalltalk 1971-80 Object Oriented JavaScript 1996 Scripting C++ 1983 Object Oriented VBScript 1996 Scripting VB 1988 Object Oriented Java 1995 Object Oriented C# 2000 Object Oriented Food for Thought • Panini • Curry Paradigms: Imperative • Focus on dynamic aspect of computation – operational semantics • Specifies step-by step what must be done Pure Forms • Godel’s purely descriptive recursive function formalism • Realized by Mc.Carthy’s Lisp • Turing’s Imperative formalism Paradigms: Functional Paradigms: Logic Paradigms: Object Oriented Paradigms: Event Driven Some Initial Thoughts, and Recap • From the Church-Turing thesis all computers are equivalent to a Turing Machine and therefore are equivalent to each other. • Computer manufacturers admit this; they do not say “our machine has some magic instruction which makes our computer more powerful than the competition”. Their advertising goes like this: “Our machines are faster, cheaper, easier to program and are more greener” • From the Church-Turing thesis all programs can be constructed using two registers and two instructions, so all programming languages are equivalent in expressibility (power,…) • Language developers admit this; they do not say “our language has some magic feature which allows our language to do more than in any other language”. Instead, their advertising goes like this. “Our language is more user-friendly, our compilers are faster and they produce smaller executable files, and are more greener” Why are these two instructions so fundamental? decjmpreg reg,lab inc reg Programming Paradigms What is a “Paradigm” ? Important Paradigms • Imperative (procedural) • Functional • Logic • Object Oriented • Event Driven Using conditional expressions to define recursive functions Thesis: All computable functions can be defined by the recursive use of conditional expressions. if p then a else b n! = g(n,1) where g(n,s) = if n = 0 then s else g(n – 1, n x s) Equivalence of imperative and functional programming Flow Diagrams: Turing Von Neumann and McCarthy Prolog Syntax Sheet Facts and Rules parent(abraham, isaac). Fact. Lower case for names. parent(isaac, esau). Fact. Lower case for names. grandfather(X,Y) :- parent(X,A),parent(A,Y). Rule. If X is the grandfather of Y then X is the parent of A and A is the parent of Y. For example, if george “X” is the parent of colin “A” and colin “A” is the parent of tristan “Y” then george “X” is the grandparent of Tristan “Y”. Queries ?- parent(abraham,X). The capital X designates an “output” variable which will be all sons of Abraham. ?- grandfather(abraham,X). The capital X designates an “output” variable which will be all grandchildren of Abraham. What Programming Languages do we know? FORTRAN COBOL C/C++ ADA Java C# Scheme Prolog Occam COBOL SmallTalk Java Ada C# Assembler ALGOL 60 Basic FORTRAN Haskell F# Lua Python Joy Clean Lisp Oz Pascal Prolog Scheme FP Erlang OO Imperative Functional Logic Lang Lang Lang Lang Lang Lang Paradigm Lang Lang Paradigm Paradigm Lang Paradigm Lang Lang Lang Assembly C Imperative Java Functional Matlab Logic ActionScript Object Oriented C++ Event Driven Lisp Prolog Criteria for Comparison Prolog Scheme asm Java C Criteria Procedural int a,b,c a = 1; B = 46; c = a + b; ADD A TO B GIVING SUM Recursion Recursion Talking on line 1 I got a call on line 2 Talking on line 2 I got a call on line 3 Talking on line 3 I got a call on line 4 Talking on line 4 I got a call on line 5 Talking on line 5 I got a call on line 6 James I Charles I Catherine Charles II Elizabeth James II Sophia George I Why Babel? Why Babel? “ a language was designed to meet needs “ … so were cars… Procedural (Imperative) Fortran 10 IF(NUM .LT.0 GO TO 20 … READ(*,*) NUM GO TO 10 20 … DIjkstra: “Go To Statement Considered Harmful” Java, C#, C++, C COBOL ADD A TO B GIVING SUM Sum = a + b; HTML SQL New Paradigms Functional = Scheme Logic = Prolog A ( A ) + A var A ( A ) + A var Statement var = expression Expression + term - + term - Term var num ( expression ) I’ve Lost my new mobile’s number • I dumped my “brick” and bought an “Alcatel” (O2). Movie on Wednesday • Jeez: I lost the paperwork and my new number. What to do? • Get my girlfriend to call all numbers in the world, and I will wait for the call. • Does this work (hehe) ?