Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Introduction to Compilers and Administrivia, Lecture notes of Programming Languages

A summary of the introductory lecture of CSE P 501 - Compilers course at the University of Washington in Autumn 2021. The document covers the definition of compilers and interpreters, the guidelines for in-person classes, and the importance of communication and understanding in the current pandemic situation. The document also discusses the difference between compilers and interpreters and their implementation in various programming languages. The document can be useful as lecture notes or study notes for students taking the CSE P 501 course or similar courses on compilers and programming languages.

Typology: Lecture notes

2020/2021

Uploaded on 05/11/2023

christin
christin 🇺🇸

4.6

(18)

264 documents

1 / 54

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE P 501 Compilers
Overview and Administrivia
Hal Perkins
Autumn 2021
UW CSE P 501 Autumn 2021 A-1
Welcome back to the Almost NormalJ
Please remember in class to wear masks
at all times and no eating/drinking.
Your col le ag ue s ( in cl ud in g cou rse staff!)
thank you for your help.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36

Partial preview of the text

Download Introduction to Compilers and Administrivia and more Lecture notes Programming Languages in PDF only on Docsity!

CSE P 501 – Compilers

Overview and Administrivia

Hal Perkins

Autumn 2021

Welcome back to the Almost Normal™ J

Please remember in class to wear masks

at all times and no eating/drinking.

Your colleagues (including course staff!)

thank you for your help.

Agenda

  • Introductions
  • What’s a compiler?
  • Administrivia

In Person This Quarter

  • It’s in-person this quarter, not remote or hybrid
    • But we will take advantage of things that we learned worked well over the last year – maybe zoom for some office hours? - Please suggest other things that we might do better/differently
    • Lectures will be recorded on panopto for review/study, but that is not a substitute for going to class - Be here, take notes, enjoy!
  • Most important: stay healthy, wear masks, keep your (physical) distance from others when you can – let’s make this work! - Have you had your flu shot yet?

UW & Allen School Guidelines

  • Wear masks indoors (including in class)
  • No eating/drinking in class or meetings (quick

sip of water now and then is fine)

  • Avoid crowding in office hours or other

meetings, no crowded waiting lines, etc.

  • And be prepared to adjust and adapt as

circumstances change

Agenda

  • Introductions
  • What’s a compiler?
  • Administrivia

Who: Course staff

  • Instructor: Hal Perkins: UW faculty for quite a while now; veteran of many compiler courses (among other things)
  • Teaching Assistant: Hannah Potter, CSE grad student
  • Office hours: Hannah, Tue. before class, 5:30-6:20, CSE2 150; Hal, after class – lecture room - We could also set up some zoom office hours later in the week or on the weekend – thoughts?
  • Get to know us – we’re here to help you succeed!
  • And you! Thanks for joining us this quarter!!

Agenda

  • Introductions
  • What’s a compiler?
  • Administrivia

And the point is…

  • How do we execute something like this? int nPos = 0; int k = 0; while (k < length) { if (a[k] > 0) { nPos++; } }
  • Or, more concretely, how do we program a computer to understand and carry out a computation written as text in a file? The computer only knows 1’s & 0’s: encodings of instructions and data

Common Issues

  • Compilers and interpreters both must read the

input – a stream of characters – and

“understand” it: front-end analysis phase

w h i l e ( k < l e n g t h ) { i f ( a [ k ] > 0

) { n P o s + + ; } }

Compiler

  • Read and analyze entire program
  • Translate to semantically equivalent program

in another language

  • Presumably easier or more efficient to execute
  • Offline process
  • Tradeoff: compile-time overhead

(preprocessing) vs execution performance

Interpreter

  • Interpreter
    • Typically implemented as an “execution engine”
    • Program analysis interleaved with execution: running = true; while (running) { analyze next statement; execute that statement; }
    • Usually requires repeated analysis of individual statements (particularly in loops, functions) - Hybrid approaches can avoid some of this overhead
    • But: immediate execution, good debugging, interactive, …

Often implemented with interpreters

  • JavaScript, PERL, Python, Ruby, awk, sed,

shells (bash), Scheme/Lisp/ML/OCaml,

postscript/pdf, machine simulators

  • Particularly efficient if interpreter overhead is

low relative to execution cost of individual

statements

  • But even if not (machine simulators), flexibility, immediacy, or portability may be worth it

Structure of a Compiler

  • At a high level, a compiler has two pieces:
    • Front end: analysis
      • Read source program and discover its structure and meaning
    • Back end: synthesis
      • Generate equivalent target language program

Source Front End Back End Target

Compiler must…

  • Recognize legal programs (& complain about illegal ones)
  • Generate correct code
    • Compiler can attempt to improve (“optimize”) code, but must not change behavior
  • Manage runtime storage of all variables/data
  • Agree with OS & linker on target format

Source Front End Back End Target