Programming Languages: Application and Interpretation

Posted on January 12, 2022
Tags: PL

preface

  • programming languages are aggregates of features
  • features interact in ways that may not be easy to predict
  • while we progress across features, also want to study variation between them
  • mystery language approach: with a fixed syntax, explore the different ways the same feature can behave
  • programming languages thought of as abstract syntax tree -> program that processes this tree is recursive function

evaluation

two types

  • interpreter: consumes a program and simulates its execution.
    • interpreter:: Program -> Value
  • compiler: consumes a program and produces another program
    • compiler:: Program_L -> Program_T

we have a choice:

eager (f (+ 5 4)) (f 9)

or

lazy (f (+ 5 4)) (+ 1) where x is replaced by (+ 5 4)

substitution

  • is generally slow

representing programs

  • our evaluator comsumes programs
  • surface syntax: how to represent a program (human POV)

abstract syntax

  • represent essence of the input, ignoring the superficial syntactic details
  • in-computer representation of programs => AST, abstract syntax trees
  • AST: tree-structured data that represent programs in programs
  • by adopting a language’s primitives, we inherit its semantics