
1
Spring 2002 CS 403 Class Notes Page 1
Lecture 32 – Tuesday, April 30
• Today
– Programming paradigms
• Reading Assignments For Next Class
– Chapter 11
Spring 2002 CS 403 Class Notes Page 2
Programming Paradigms
• Imperative/procedural paradigm
– Pretty much what you are used to
• Object-oriented paradigm
– Also have some experience with this, but C++ and even
Java have some procedural legaci es
• Functional paradigm
• Logic paradigm
• Event-driven paradigm
• Concurrency paradigm
Spring 2002 CS 403 Class Notes Page 3
Imperative Paradigm
• Also called the procedural paradigm
• Basic elements:
– Assignment statements
– Procedures
– Standard f low-of-control statements (if, while, etc.)
• Program has definite initiation and termination points
• Pascal, C, etc. are examples of this
Spring 2002 CS 403 Class Notes Page 4
Object-Oriented Paradigm
• Program is a series of communicati ng objects.
• Objects pass messages to one another.
• Objects have methods that are executed in response to a
message.
• Smalltalk is the classical language in this category.
• C++ i s also object-oriented but:
– It has non-object elem ents (built-in types, plain functi ons, etc.)
– We don’t usually us e the “message passing” par adigm to
conceptualize C++ pr ograms.
• Java eliminates the “plain functions” , but is otherwise very
similar to C++ in this regard.
Spring 2002 CS 403 Class Notes Page 5
Functional Paradigm
• Program consists entirely of functional elements
– Function: Mappi ng from domain to range
– f(x) = x * x (for all x)
– f(x) = 0 if x = 1
1 if x = 2
x * x otherwise
• No assignment statements, no way to affect state
directly
• Lots of functional composition and recursion
Spring 2002 CS 403 Class Notes Page 6
Example: LISP
• Language for doing list processing.
• Basi c statements:
– (CAR ‘(A B C D)) returns A
– (CDR ‘(A B C D)) returns (B C D)
– (CONS ‘A ‘(B C D)) returns (A B C D)
– (ATOM ‘A) returns T
– (ATOM ‘(B C D)) returns NIL (or FALSE)
– (EQUAL ‘(A B) ‘(A B)) returns T
– (NULL ‘()) returns T
– (NULL ‘(A B C)) returns NIL
– Arithmetic functions