1 / 40

Welcome to Programming Languages!

Welcome to Programming Languages!. http://flic.kr/p/ eGNyq. Why take Programming Languages?. Make me a better ________________. Why take Programming Languages?. Make be a better creator of PLs Design PLs Implement PLs Make me a better user of PLs Write better code

Download Presentation

Welcome to Programming Languages!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Welcome to Programming Languages! http://flic.kr/p/eGNyq

  2. Why take Programming Languages? Make me a better ________________

  3. Why take Programming Languages? • Make be a better creator of PLs • Design PLs • Implement PLs • Make me a better userof PLs • Write better code • Choose right PL for job

  4. Deep questions • What makes a good PL design? • What types of PL designs are there? • How do you implement a PL?

  5. Can you guess what this is? It’s a program! • Machine language – x86 (Pentium) • Expressed as hex • Calculates greatest common divisor (GCD)

  6. What are the pros/cons of machine language? Pros Cons Unreadable Not portable More??? • Close to machine • Performance

  7. Can you guess what this is? • Assembly language version of GCD program • 1-to-1 mnemonic mapping to machine language

  8. What are the pros/cons of assembly language? • Pretty much same as machine language, but more human readable

  9. Can you guess what this is? • High-level language (C/C++) version of GCD

  10. What are the pros/cons of high-level language? • Pros: More comprehendible, scalable, and portable • Cons: Farther from the machine (poorer performance)

  11. But there are thousands(?) of high-level langs – what makes one better than another? C/C++ Scheme/Lisp Prolog

  12. What makes one lang better than another? • Expressive power • What computations can you express? • Usability • Learnability • Ease of use (create/read/modify) • Ease of implementation • Performance • Tool support • Familiarity/expertise???

  13. Deep questions • What makes a good PL design? • What types of PL designs are there? • How do you implement a PL?

  14. Declarative versus Imperative Declarative Imperative Say how to compute Implementers point of view Closer to machine Dominant • Say what to compute • Programmers point of view • Higher level • Up and coming

  15. (Fuzzy) Categories of languages • Declarative • functional (Lisp/Scheme, ML, Haskell) • dataflow (Id, Val) • logic, constraint-based (Prolog, spreadsheets) • template-based (XSLT) • Imperative • von Neumann (C, Ada, Fortran, …) • scripting (Perl, Python, PHP, …) • object-oriented (Smalltalk, Eiffel, Java, …)

  16. Functional versus von Neuman von Neumann - C/C++ Recursive definition of functions, refining from more complex to simpler(no variables/state!) Functional - Scheme/Lisp Declaration and sequential modification of variables

  17. Deep questions • What makes a good PL design? • What types of PL designs are there? • How do you implement a PL?

  18. Finish this dataflow diagramfor assembly language ???

  19. Finish this dataflow diagramfor assembly language

  20. Finish this dataflow diagram for high-level languages ???

  21. Finish this dataflow diagram for high-level languages Don’t let the namesconfuse you. Theseare all translators

  22. Architectural pattern*:Translate through many intermediate representations * Called pipeline orpipes and filters architecture

  23. But there’s another way! Can you explain this diagram?

  24. Translators Versus Interpreters • Translator: Program that reads “sentences” in one language and converts them to another • See also compilers, assemblers • Interpreter: Program that reads sentences in some language and “executes” them • May or may not be interactive

  25. What language uses this translator/interpreter hybrid architecture? aka Compiler aka Interpreter Why, Java, of course

  26. How do you read/analyze/process code? … What happensin here?

  27. Two big concerns • Syntax: The form in which sentences are expressed • What syntactic elements do parts of the source map to? • Is the source syntactically valid? • Semantics: The meaning of the sentences • What semantic elements do parts of the source map to? • Is the source semantically valid?

  28. What to do first?

  29. Split input into bite-size tokens C/C++ token examples: What next?

  30. Map tokens to syntactic elements C/C++ parse treeexample: What next?

  31. Represent program in terms of semantic elements AST example What next?

  32. And all the rest… And all the rest…

  33. Fortunately, there are tools to help you! • Compiler Compilers • aka Compiler Generators • aka Parser Generators • aka… • Examples: • Lex/Yacc • Flex/Bison • ANTLR

  34. Course Goals • Learn to create your own language translators/interpreters • Using ANTLR • Survey issues and features in PL design • Try programming in sampling of different languages

  35. Course Structure • Three parts (4-5 weeks each) • Follows structure of PLP book • Each ends in an exam • Homeworks throughout (~7) • Readings + quizzes throughout

  36. Grading • 51% exams (3 x 17%) • 39% homeworks and quizzes • 10% participation

  37. Some key policies • No cheating! • I use plagiarism detection system! • Participate! (lest you lose a participation point) • Be here at beginning of class, stay until the end • Pop quizzes at beginning of class common • Be engaged! • Expect seating chart • Bring laptops, but…

  38. http://www.cbc.ca/news/technology/story/2013/08/14/technology-laptop-grades.htmlhttp://www.cbc.ca/news/technology/story/2013/08/14/technology-laptop-grades.html

  39. Let’s tour the course web pages…

  40. What’s next? • Take Java proficiency instrument • In class today • Do Homework 0 • Due Tuesday by 2:40

More Related