Interpretation
Interpretation
Translation Problem: Computers can only understand one language,binary (0s and 1s) Humans can't really write a program using only 0s and 1s (not quickly anyways) Solution: Programming languages Languages like Python,Java,C,etc are translated to 0s and 1s This translation step comes in a couple forms: Compiled (pre-translated)_-translate all at once and run later iInterpreted (translated_on-the-fly)-translate while the program is running We'11 focus on interpreted languages
Translation Problem: Computers can only understand one language, binary (0s and 1s) Humans can’t really write a program using only 0s and 1s (not quickly anyways) Solution: Programming languages Languages like Python, Java, C, etc are translated to 0s and 1s This translation step comes in a couple forms: Compiled (pre-translated) - translate all at once and run later Interpreted (translated on-the-fly) - translate while the program is running We’ll focus on interpreted languages
Interpreters An interpreter does 3 things: Reads input from user in a specific programming language Translates input to be computer readable and evaluates the result Prints the result for the user There are two languages involved: Implemented language:this is the language the user types in Implementation language:this is the language interpreter is implemented in Implemented Language is translated into the Implementation Language
Interpreters An interpreter does 3 things: Reads input from user in a specific programming language Translates input to be computer readable and evaluates the result Prints the result for the user There are two languages involved: Implemented language: this is the language the user types in Implementation language: this is the language interpreter is implemented in Implemented Language is translated into the Implementation Language
Read-Eval-Print Loop (REPL) input expression value output Read Eval Print 。 string string loop while True: exp read() val eval(exp) print(val)
Interpreter input string Read-Eval-Print Loop (REPL) Read Eval Print expression value loop output string while True: exp = read() val = eval(exp) print(val)
Read
Read