Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 78 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
78
Dung lượng
465 KB
Nội dung
Programming Languages Intro; Caml; Functional Programming Dan Grossman Winter 2009 8 January 2009 CSE P505 Winter 2009 Dan Grossman 2 Welcome! 10 weeks for key programming-language concepts – Focus on the universal foundations Today: 1. Staff introduction; course mechanics 2. Why and how to study programming languages 3. Caml and functional-programming tutorial 8 January 2009 CSE P505 Winter 2009 Dan Grossman 3 Hello, my name is… • Dan Grossman, djg@cs • Faculty member researching programming languages – Sometimes theory (math) – Sometimes implementation (graphs) – Sometimes design (important but hand-waving) – Particularly, safe low-level languages, easier-to-use concurrency, better type-checkers, other • Approximately 0 years professional experience – …but I’ve done a lot of compiler hacking • You can get the rest from Facebook 8 January 2009 CSE P505 Winter 2009 Dan Grossman 4 Course facts (overview) • www.cs.washington.edu/education/courses/csep505/09wi/ • TAs: Trinh, Laura, Ben • Homework 0 • Distance learning • No textbook • 5 homeworks • Caml • Final exam: Thursday March 19, 6:30-8:20PM Then onto actual course motivation and content 8 January 2009 CSE P505 Winter 2009 Dan Grossman 5 Course web page • Read syllabus – includes some advice • Read advice for approaching homework – Homework code is not industry code – Functional programming is not imperative/OO programming • Course web page will have slides, code, homework, programming resources, etc. – Link to page with audio/video archives 8 January 2009 CSE P505 Winter 2009 Dan Grossman 6 TAs Trinh, Laura, and Ben • All have taken a more theoretical version of this course from me (and presumably liked it ) – And they’ll be at most of the lectures • Can reach all 4 of us at csep505staff@cs – And discussion board from course website • Trinh will do a majority of the homework grading, but all will answer homework questions 8 January 2009 CSE P505 Winter 2009 Dan Grossman 7 Homework 0 • An optional, brief and extremely useful survey • On the web page; just email me • Things like what you do and what your concerns are • (Also helps me learn your names) 8 January 2009 CSE P505 Winter 2009 Dan Grossman 8 Wide background • Homework 0 will almost surely demonstrate a wide range of background – So some material will be simultaneously too remedial and too advanced – Still let me know (politely) – “Challenge problems” help some • Affect your grade, but only a little • Speaking of background, no need for PMP/5 th -year mutual fear 8 January 2009 CSE P505 Winter 2009 Dan Grossman 9 Distance learning • I’ve done this once before • The technology will rarely get in the way – The two-way A/V is great (either location fine) – I’m okay with writing on the Tablet PC • Please, please come to class!!! – Archive/streaming useful when absolutely necessary – I cannot teach to a brick wall • And low attendance makes me cranky – You cannot learn as well without asking questions and feeling like you’re part of a live interaction 8 January 2009 CSE P505 Winter 2009 Dan Grossman 10 Segue to a sermon • I’m here to teach the essential beauty of the foundations of programming languages • If you’re here because – It’s distance so you don’t have to attend – You can get out of the house on Thursday nights – “A Master’s degree” will get you a raise then you risk taking “longcuts” and being miserable • Advice: If you must be <100% engaged, try to wait as long as possible – the material builds more than it seems – catching up is hard [...]... of programming languages very precisely, because it matters • There is no best language, but lots of similarities among languages • “Academic” languages make this study easier and more forward-looking • “A good language is not always “the right language but we will pretend it is • APIs evolve into programming languages 8 January 2009 CSE P505 Winter 2009 Dan Grossman 26 Welcome! 10 weeks for key programming- language. .. bit F#-specific (still useful?) 8 January 2009 CSE P505 Winter 2009 Dan Grossman 14 Welcome! 10 weeks for key programming- language concepts – Focus on the universal foundations Today: 1 Staff introduction; course mechanics 2 Why and how to study programming languages 3 Caml and functional -programming tutorial 8 January 2009 CSE P505 Winter 2009 Dan Grossman 15 A question • What’s the best kind of car?... weeks for key programming- language concepts – Focus on the universal foundations Today: 1 Staff introduction; course mechanics 2 Why and how to study programming languages 3 Caml and functional -programming tutorial 8 January 2009 CSE P505 Winter 2009 Dan Grossman 27 And now Caml • • • • “Hello, World”, compiling, running, note on SEMINAL – Demo (not on Powerpoint) Tutorial on the language – On slides but... software system or a non-trivial API, 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 API with few functions but sophisticated data Conversely, an interface is just a stupid programming language 8 January 2009 CSE P505 Winter 2009 Dan Grossman 24 Our API…... language – On slides but code-file available and useful Then use our new language to learn – Functional programming – Idioms using higher-order functions – Benefits of not mutating variables Then use Caml to define other (made-up) languages 8 January 2009 CSE P505 Winter 2009 Dan Grossman 28 Advice Listen to how I describe the language Let go of what you know: do not try to relate everything back to... realworld programming issues – Though maybe more later in the course after the basics • But even if we don’t, some truths are so beautiful and perspective-altering they are worth learning anyway – Watching Hamlet should affect you • Maybe very indirectly • Maybe much later • And maybe you need to re-watch it 8 January 2009 CSE P505 Winter 2009 Dan Grossman 21 Academic languages Aren’t academic languages... 2009 Dan Grossman 22 A recent functional surge • F# – Interoperable core with Caml, for NET • C# 3.0 – First-class functions, some type inference, etc • Multicore (no mutation means easier to parallelize) • MapReduce / Hadoop (first published 2004) • Erlang for distributed computing • … 8 January 2009 CSE P505 Winter 2009 Dan Grossman 23 “But I don’t do languages” Aren’t languages somebody else’s problem?... Caml programming (some written answers) – Expect to learn as you do them – Probably all < 200 lines + thinking – Again, challenge problems are optional – There are 9 weekends before last lecture • Do your own work, but feel free to discuss – Do not look at other’s solutions – But learning from each other is great • Homework 1 due in two weeks – Probably the hardest if you’re new to Caml / functional programming. .. for it • I’ll post a sample later 8 January 2009 CSE P505 Winter 2009 Dan Grossman 13 Caml • Caml is an awesome, high-level language • We’ll use a small core subset that is well-suited to manipulating recursive data structures (like programs) • Tutorial will demonstrate its mostly functional nature – Most data immutable – Recursion instead of loops – Lots of passing/returning functions • Thought about... Dan Grossman 15 A question • What’s the best kind of car? • What’s the best kind of shoes? 8 January 2009 CSE P505 Winter 2009 Dan Grossman 16 An answer Of course it depends on what you are doing Programming languages have many goals, including making it easy in your domain to: • Write correct code • Write fast code • Write code fast • Write large projects • Interoperate • … 8 January 2009 CSE P505 Winter . Programming Languages Intro; Caml; Functional Programming Dan Grossman Winter 2009 8 January 2009 CSE P505 Winter 2009 Dan Grossman 2 Welcome! 10 weeks for key programming- language concepts – Focus. key programming- language concepts – Focus on the universal foundations Today: 1. Staff introduction; course mechanics 2. Why and how to study programming languages 3. Caml and functional -programming. study programming languages 3. Caml and functional -programming tutorial 8 January 2009 CSE P505 Winter 2009 Dan Grossman 3 Hello, my name is… • Dan Grossman, djg@cs • Faculty member researching programming