DOC PREVIEW
UW CSE 341 - Lecture Notes

This preview shows page 1-2-3-4 out of 11 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

'&$%CSE 341:Programming LanguagesWinter 2006Lecture 6— The truth about bindings and course motivationCSE341 Winter 2006, Lecture 6 1'&$%Where we areClass has covered tremendous ground—you will catch up when you dohomework 2.Next time we’ll take up first-class functions (closures, functions asvalues):• A really key idea in computer sc ienceBut we haven’t yet seen that pattern-matching is an elegantgeneralization of variable binding.And we owe you an explanation of why we should study programminglanguages, particulary ML, Scheme, and SmalltalkCSE341 Winter 2006, Lecture 6 2'&$%Deep patternsPatterns are much richer than we have let on. A pattern can be:• A variable (matches everything, introduces a binding)• _ (matches everything, no binding)• A constructor and a pattern (e.g., C p) (matches a value if thevalue “is a C” and p matches the value it carries)• A pair of patterns ((p1,p2)) (matches a pair if p1 matches thefirst component and p2 matches the second component)• A record pattern...• An integer constant...• ...CSE341 Winter 2006, Lecture 6 3'&$%The truth, the whole truth, and nothing but thetruthIt’s really:• val p = e• fun f p1 = e1 | f p2 = e2 ... | f pn = en• case e of p1 => e1 | ... | pn => enInexhaustive matches may raise exceptions and are bad style.Example: could write Rope pr or Rope (r1,r2)Fact: Eve ry ML function takes exactly one argument!CSE341 Winter 2006, Lecture 6 4'&$%Some function examples• fun f1 () = 34• fun f2 (x,y) = x + y• fun f3 pr = let val (x,y) = pr in x + y endIs there any difference to callers between f2 and f3?In most languages, “argument lists” are syntactically separate,second-class constructs.Can be useful: f2 (if e1 then (3,2) else pr)CSE341 Winter 2006, Lecture 6 5'&$%A question?What’s the best car?What are the be st kind of shoe s?CSE341 Winter 2006, Lecture 6 6'&$%Aren’t all languages the same?Yes: Any input-output behavior you can program in language X youcan program in language Y• Java, ML, and a language with one loop and three infinitely-largeintegers are “equal”• This is called the “Turing tarpit”Yes: Certain fundamentals appear in most languages (variables,abstraction, each-of types, inductive definitions, ...)• Travel to learn more about where you’re fromNo: Most cars have 4 tires, 2 headlights, ...• Mechanics learn general principles and what’s differentCSE341 Winter 2006, Lecture 6 7'&$%Aren’t these academic languages worthless?In the short-term, m aybe: Not many summer internships using ML?But:• Knowing them m akes you a better Java, C, and Perl programmers(affects your idioms)• Java did not exist in 1993; what does not exist now?• Do Java and Scheme have anything in common? (Hint: check theauthors)• Eventual vindication: garbage-collection and genericsCSE341 Winter 2006, Lecture 6 8'&$%Aren’t the semantics my least concern?Admittedly, there are m any important considerations:• What libraries are available?• What does my boss tell me to do?• What is the de facto industry standard?• What do I already know?Technology leaders affect the answers to these questions.Sound reasoning about programs, interfaces, and compilers requiresknowledge of sem antics.CSE341 Winter 2006, Lecture 6 9'&$%Aren’t languages somebody el se’s problem?If you design an extensible software system, you’ll end up designing a(small?) programming language!Examples: VBScript, JavaScript, PHP, ASP, QuakeC, Renderman,bash, AppleScript, emacs, Eclipse, AutoCAD, ...Another view: A language is an interface with just a few functions(evaluate, typechec k) and a sophisticated input type.In other words, an interface is just a stupid programming language.CSE341 Winter 2006, Lecture 6 10'&$%SummaryThere is no such thing as a “best programming language”. (There aregood general design principles we will st udy.)A good language is a relevant, crisp, and clear interface for writingsoftware.Software leaders should know about programming languages.Learning languages has super-linear payoff.• But you have to learn the semantics and idioms, not a cutesyntactic trick for printing “Hello World”.End of the course: Language-design goals, mechanisms, and trade-offsNext time: why ML, Scheme, and Smalltalk?CSE341 Winter 2006, Lecture 6


View Full Document

UW CSE 341 - Lecture Notes

Documents in this Course
Macros

Macros

6 pages

Macros

Macros

6 pages

Macros

Macros

3 pages

Mutation

Mutation

10 pages

Macros

Macros

17 pages

Racket

Racket

25 pages

Scheme

Scheme

9 pages

Macros

Macros

6 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?