cse 425: intro to programming languages and their design a few key ideas no particular language is a...

10
E 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course However you should be proficient in at least one language A working knowledge of C++ is worth pursuing as you go We’ll work on many paradigms in C++ “How we communicate influences how we think and vice versa.” [Louden and Lambert 3 rd Ed. pp. 2] “Similarly, how we program computers influences how we think about computation, and vice versa.” [Louden and Lambert 3 rd Ed. pp. 2]

Upload: nancy-moody

Post on 25-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

A Few Key Ideas

• No particular language is a prerequisite for this course– However you should be proficient in at least one language– A working knowledge of C++ is worth pursuing as you go– We’ll work on many paradigms in C++

• “How we communicate influences how we think and vice versa.” – [Louden and Lambert 3rd Ed. pp. 2]

• “Similarly, how we program computers influences how we think about computation, and vice versa.” – [Louden and Lambert 3rd Ed. pp. 2]

Page 2: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

Abstraction in Programming

• Von Neumann Architecture– Program instructions and data are stored in a memory area– CPU executes a sequence of instructions

• Machine instruction sets: lowest level of abstraction– Binary representation that the CPU can process– Or that a virtual machine can process (e.g., byte code)

• Assembly language is only slightly more abstract– “Readable” labels: operations, registers, location addresses

00100010 001001 000000100000000100

LD R1 FIRST

(opcode) (register) (location)

Page 3: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

Evolving to Higher Levels of Abstraction

• Algebraic notation and floating point numbers– E.g., Fortran (John Backus)

• Structured abstractions and machine independence– E.g., ALGOL (a committee), Pascal (Niklaus Wirth)

• Architecture independence (on beyond Von Neumann)– E.g., based on Lambda Calculus (Alonzo Church)– E.g., Lisp (John McCarthy)

Page 4: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

Data Abstraction

• Basic abstractions– Variables, data types, declarations

• Structured abstractions– Data structures, arrays

• Unit abstractions– Abstract data types (ADTs), classes, packages, namespaces

• Key ideas– Information hiding, modularity, reusability, interoperability

Page 5: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

Control Abstraction• Basic abstractions

– Algebraic statements, “syntactic sugar”

• Structured abstractions– Loops, branch instructions– Procedures, iterators, cursors, manipulators, etc.

• Unit abstractions– ADTs, classes, packages, namespaces (same as for data!)

• Key ideas– Selection, iteration, formal/actual parameters, composition

Page 6: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

Some Programming Paradigms

• Imperative/procedural (E.g., C, C++)– Variables, assignment, other operators

• Functional (E.g., Lisp, Scheme, ML, Haskell, C++)– Abstract notion of a function, based on lambda calculus

• Logic (E.g., Prolog, but can develop structures in C++)– Based on symbolic logic (e.g., predicate calculus)

• Object-oriented (E.g., Java, Python, C++)– Based on encapsulation of data and control together

• Generic (E.g., C++ and especially its standard library)– Based on type abstraction and enforcement mechanisms– We’ll cover informally via examples throughout the semester

Page 7: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

Language Definition

• Syntax– Lexical structure, tokens, grammars (E.g., BNF)

• Basic semantics– Informal description, may be incomplete

• Formal semantics– Operational semantics (execution specification)– Denotational semantics (specification as functions)– Axiomatic semantics (assertions about program state)

Page 8: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

Language Design

• Goals (potentially conflicting)– Efficiency of coding or execution, writability, expressiveness

• Specific design criteria– Regularity (how well language features are integrated)– Generality (how few cases have to be handled specially)– Orthogonality (how widely features still behave the same)– Uniformity (consistent appearance/behavior across features)– Safety or “security” (how difficult it is to produce errors)– Extensibility (how easy and effective is feature addition)

Page 9: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

Comparing Programming Languages

• Different languages usually have different goals– E.g., C++ focuses on expressiveness and efficiency of

execution, at some cost to writability and efficiency of coding

• Accordingly, they may focus on different design criteria– E.g., although Java, C++, and Python are all designed with

the object-oriented programming paradigm in mind…– … operator overloading increases extensibility but reduces

safety (e.g., operator precedence of ^ for exponentiation)– … generality and uniformity are aided by a simpler and

smaller set of language features– … and so forth

Page 10: CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be

CSE 425: Intro to Programming Languages and their Design

Today’s Studio Exercises• We’ll explore Visual Studio and a few coding ideas

– Built incrementally from simple to more complex abstractions

• We’ll work in C++, a multi-paradigm language– Please form teams that put people less (or without a) C++

background together with those familiar with C++– Ask for help as needed– Use the on-line C++ reference and also the material at

http://www.cse.wustl.edu/~cdgill/courses/cse332/

• Record your answers as you go and e-mail them (with the studio name in the subject line), when you’re done– E-mail them to the course account, [email protected]– You should get an e-mail back acknowledging receipt– Please track which studios you have (and have not) sent