Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITEC 380 Organization of programming languages Dr. Andrew Ray.

Similar presentations


Presentation on theme: "ITEC 380 Organization of programming languages Dr. Andrew Ray."— Presentation transcript:

1 ITEC 380 Organization of programming languages Dr. Andrew Ray

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

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

4 Introduction 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 Introduction How? Synchronous component Study at your leisure lectures Self study / experimentation Homework assignments –Intro –Major project Adaptability –Online forums/chat/twitter?

6 Introduction Informatio n Course website –www.radford.edu/aaray/ITEC_380 Demo

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

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

9 Introduction 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 Introduction Example 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 ); }

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

12 Introduction 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 Introduction Language s What is the purpose of a language? Why are there multiple languages? What are the major components of languages?

14 Introduction 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 Introduction Implementatio n Compilation –Source, translation to binary, execution Interpretation –Source, intermediate program, execution Benefits / downsides

16 Introduction History Dr. Okie’s history notes –http://www.radford.edu/~nokie/classes/380/w1 l4.html

17 Introduction 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 Introduction Symbol table Keystore method –Variables Type, value, scope, memory location –Functions –Classes Put info into table Pull it out when generating code

19 Introduction Stage 1 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 What tokens come from x = 12 + y * 34?

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

21 Introduction 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 Introduction Optimizatio n How to make your code better Extremely difficult field Reorganization of information –Unrolling loops Reduce redundant information

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

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

25 Introduction Next week Grammar Variable types / bindings / lifetime


Download ppt "ITEC 380 Organization of programming languages Dr. Andrew Ray."

Similar presentations


Ads by Google