1 / 25

ITEC 380

ITEC 380. Organization of programming languages Dr. Andrew Ray. Objectives. Introductions (Me + You ) Outline of course Why study languages? Paradigms How languages are understood. Me. 6 th year here at RU 1 st time teaching this course

leah-oneill
Download Presentation

ITEC 380

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. ITEC 380 Organization of programming languages Dr. Andrew Ray

  2. Objectives • Introductions (Me + You) • Outline of course • Why study languages? • Paradigms • How languages are understood

  3. Me • 6th year here at RU • 1st time teaching this course • Have used lessons from this type of course to help with • Research • Teaching

  4. You • What is one topic you’d really like to learn about concerning programming languages? • What do you want to learn in this class? • How interested are you in this class? (1-10) • Share with class

  5. How? • Synchronous component • Study at your leisure lectures • Self study / experimentation • Homework assignments • Intro • Major project • Adaptability • Online forums/chat/twitter?

  6. Information • Course website • www.radford.edu/aaray/ITEC_380 • Demo

  7. Outline of course • 1-2 - Languages • 3-6 – Functional programming • 7-10 – Logical programming • 11-12 – Procedural programming • 13-14 – OO / Review

  8. Paradigms • Radically different methods of accomplishing the same task • Procedural • Object oriented • Functional • Logical

  9. Example • Quicksort in haskell quicksort :: Ord a => [a] -> [a] quicksort [] = [] quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater) where lesser = filter (< p) xs greater = filter (>= p) xs

  10. void qsort(int a[], int lo, int hi) { int h, l, p, t; if (lo < hi) { l = lo; h = hi; p = a[hi]; do { while ((l < h) && (a[l] <= p)) l = l+1; while ((h > l) && (a[h] >= p)) h = h-1; if (l < h) { t = a[l]; a[l] = a[h]; a[h] = t; } } while (l < h); a[hi] = a[l]; a[l] = p; qsort( a, lo, l-1 ); qsort( a, l+1, hi ); } } Example

  11. Paradigms • Right tool right job • OO is probably used for > 95% of software development • Purpose • Performance • Reliability • Elegance • Expression

  12. Choose your language • You are familiar with OO and procedural languages • Goal: Not a rehash of Java / Ada • Desire: Choose a different OO & procedural language to study for the course • Thoughts?

  13. Languages • What is the purpose of a language? • Why are there multiple languages? • What are the major components of languages?

  14. Computers • Syntax • Did you put the exact number of ;’s in it? • Semantics • What does it mean? • Goal • Tell the computer what to do

  15. Implementation • Compilation • Source, translation to binary, execution • Interpretation • Source, intermediate program, execution • Benefits / downsides

  16. History • Dr. Okie’s history notes • http://www.radford.edu/~nokie/classes/380/w1l4.html

  17. Compilers • How a language is understood (ears / brain) • Lexical analysis • Syntactic Analysis • Intermediate code generation • Optimization • Code Generation • All use a central DB to store info (symbol table)

  18. Symbol table • Keystore method • Variables • Type, value, scope, memory location • Functions • Classes • Put info into table • Pull it out when generating code

  19. Stage 1 What tokens come from x = 12 + y * 34? • Read the information • Start at the top left and read a character at a time • When you hit whitespace/eos, generate token • Hand token off • Repeat

  20. Token handling • Parse tree • What happens to each token Tree Token 1: x Token 2: = Token 3: 12 Token 4: + Token 5: y Token 6: * Token 7: 34 Token 8: ; x = 12 + y * 34

  21. Code generation • Use parse tree / symbol table • Step 1 – Lookup y’s value • Step 2 – Multiply, store temp • Step 3 – Add 12 to temp, store in temp2 • Step 4 – Assign temp2 to x • Not difficult to generate assembly for this x = 12 + y * 34

  22. Optimization • How to make your code better • Extremely difficult field • Reorganization of information • Unrolling loops • Reduce redundant information

  23. Not universal • Not every implementation follows these steps • Linking result against existing code • Targeting interpreter versus assembler

  24. Review • Major paradigms / history of languages • Parts of a computer language • How a language becomes real

  25. Next week • Grammar • Variable types / bindings / lifetime

More Related