cs 345: programming language paradigms chris brooks hr 510 mwf 11:00-12:05

7
CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05

Upload: scarlett-marshall

Post on 04-Jan-2016

216 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05

CS 345: Programming Language

ParadigmsChris Brooks

HR 510

MWF 11:00-12:05

Page 2: CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05

• Introductions

• Course Overview

• Syllabus

• Programming Paradigms– Structured programming– Object-Oriented Programming– Functional Programming– Declarative Programming

Page 3: CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05

Structured Programming(Imperative programming)

• Language closely tied to Von Neumann architecture.– Fortran, C, COBOL

• Break code into blocks or subroutines– Modular design – Explicit control of execution– Verb-oriented

• This piece of code takes an action

Page 4: CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05

Object-Oriented Programming

• Provide more reuse and speed development– Simula, Smalltalk, C++, Objective C, Java

• Noun-oriented focus– How are system components represented?– What messages does an object understand?– How are objects related to each other?

• Key ideas:– Inheritance, polymorphism, information hiding

Page 5: CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05

Functional Programming

• Programs can be recursively composed from smaller programs.– Language is extensible– Programs and data take the same form

• Lazy evaluation

– Lisp, ML, Scheme

• Functions operate on data and return a result without side effects.

• Emphasis on the evaluation of expressions.

Page 6: CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05

Declarative Programming• Programs consist of a description of the relevant

data or knowledge relations.– Prolog, SQL, Haskell

• Describe the result to be achieved, rather than how to achieve it.

• A built-in inference engine provides execution control.

• Programs focus on describing the relationship between objects in a domain.

• Programming as proving statements.

Page 7: CS 345: Programming Language Paradigms Chris Brooks HR 510 MWF 11:00-12:05

Different Tasks Require Different Approaches

“If all you have is a hammer, then every problem looks like a nail.”

• Structured programming: focus on actions to take and flow control.– Operating systems, device drivers

• Object-oriented programming: focus on data structures– GUIs, simulations, toolkits

• Functional programming: focus on composition of small computational units.– Compilers, numerical analysis

• Declarative programming: focus on relations among data.– Databases, expert systems.