Docsity

CS 655: Programming Languages - A Vibrant and Active Area of CS Research - Prof. Westley W, Study notes of Programming Languages

Toggle sidebar
bg1
1
“Who Are You?”
This is the part where we mention
our names (I’m abysmal at
remembering them, so you’ll have
to help me out) and something we
like (e.g., I’m partial to Babylon 5).
Programming Languages
Topic of Ultimate Mastery
Wes Weimer
CS 655 – TR 5:00-6:15 @ MEC 339
http://www.cs.virginia.edu/~weimer/655
Reasonable Initial Skepticism
Today’s Class
•Vague Historical Context
•Goals For This Course
•Requirements and Grading
•Course Summary
•Convince you that PL is useful
Meta-Level Information
• Please interrupt at any time!
• Completely cromulent queries:
– I don’t understand: please say it another way.
– Slow down, you talk too fast!
– Wait, I want to read that!
– I don’t get joke X, please explain.
What Have You Done For Us Lately?
• Isn’t PL a solved problem?
– PL is an old field within Computer Science
– 1920’s: “computer” = “person”
– 1936: Church’s Lambda Calculus (= PL!)
– 1937: Shannon’s digital circuit design
– 1940’s: first digital computers
– 1950’s: FORTRAN (= PL!)
– 1958: LISP (= PL!)
– 1960’s: Unix
– 1972: C Programming Language
– 1981: TCP/IP
– 1985: Microsoft Windows
– 1992: Ultima Underworld / Wolfenstein 3D
pf3
pf4
pf5
pf8

Partial preview of the text

Download CS 655: Programming Languages - A Vibrant and Active Area of CS Research - Prof. Westley W and more Study notes Programming Languages in PDF only on Docsity!

“Who Are You?”

This is the part where we mention our names (I’m abysmal at remembering them, so you’ll have to help me out) and something we like (e.g., I’m partial to Babylon 5).

Programming Languages Topic of Ultimate Mastery

Wes Weimer CS 655 – TR 5:00-6:15 @ MEC 339 http://www.cs.virginia.edu/~weimer/

Reasonable Initial Skepticism (^) Today’s Class

•Vague Historical Context

•Goals For This Course

•Requirements and Grading

•Course Summary

•Convince you that PL is useful

Meta-Level Information

  • Please interrupt at any time!
  • Completely cromulent queries:
    • I don’t understand: please say it another way.
    • Slow down, you talk too fast!
    • Wait, I want to read that!
    • I don’t get joke X, please explain.

What Have You Done For Us Lately?

  • Isn’t PL a solved problem?
    • PL is an old field within Computer Science
    • 1920’s: “computer” = “person”
    • 1936: Church’s Lambda Calculus (= PL!)
    • 1937: Shannon’s digital circuit design
    • 1940’s: first digital computers
    • 1950’s: FORTRAN (= PL!)
    • 1958: LISP (= PL!)
    • 1960’s: Unix
    • 1972: C Programming Language
    • 1981: TCP/IP
    • 1985: Microsoft Windows
    • 1992: Ultima Underworld / Wolfenstein 3D

Don’t We Already Have Compilers? Dismal View Of PL Research

C++

Java (or C#)

Parts of Computer Science

  • CS = (Math × Logic) + Engineering
    • Science (from Latin scientia - knowledge) refers to a system of acquiring knowledge - based on empiricism, experimentation, and methodological naturalism - aimed at finding out the truth.
  • We rarely actually do this in CS
    • “CS theory” = Math (logic)
    • “Systems” = Engineering (bridge building)

Programming Languages

  • Best of both worlds: Theory and Practice!
    • Only pure CS theory is more primal
  • Touches most other CS areas
    • Theory: DFAs, PDAs, TMs, language theory (e.g., LALR)
    • Systems: system calls, assembler, memory management
    • Arch: compiler targets, optimizations, stack frames
    • Numerics: FORTRAN, IEEE FP, Matlab
    • AI: theorem proving, ML, search
    • DB: SQL, persistent objects, modern linkers
    • Networking: packet filters, protocols, even ruby on rails
    • Graphics: OpenGL, LaTeX, PostScript, even Logo (= LISP)
    • Security: buffer overruns, .net, bytecode, PCC, …
    • Software Engineering: obvious

Overarching Theme

  • I assert (and shall convince you) that
  • PL is one of the most vibrant and active areas of CS research today - It has theoretical and practical meatiness - It intersects most other CS areas
  • You will be able to use PL techniques in your own projects

Goal

•Learn to use advanced

PL techniques

Polymorphic References:

A Major Pain

Consider the following program fragment: Code Type inference fun id(x) = x id : α → α (for any α) val c = alloc id c : ptr (α → α) (for any α) fun inc(x) = x + 1 inc : int → int c := inc Ok, since c : ptr (int → int) (c) (“hi”) Ok, since c : ptr (string → string)

Reconciling Polymorphism

and References

  • Type system fails to prevent a type error!
  • Solutions (examples):
    • weak type variables:
      • polymorphic variables whose instantiation is restricted
      • difficult to use, several failed proofs of soundness
    • value restriction: generalize only the type of values! - easy to use, simple proof of soundness

Story: Java Bytecode Subroutines

  • Java bytecode programs contain subroutines (jsr) that run in the caller’s stack frame
  • jsr complicates the formal semantics of bytecodes
    • Several verifier bugs were in code implementing jsr
    • 30% of typing rules, 50% of soundness proof due to jsr
  • It is not worth it:
    • In 650K lines of Java code, 230 subroutines, saving 2427bytes, or 0.02%
    • 13 times more space could be saved by renaming the language back to Oak - [In 1994], the language was renamed “Java” after a trademark search revealed that the name “Oak” was used by a manufacturer of video adapter cards.

Recall Goal

•When (not if) you design

a language, it will avoid

the mistakes of the past

and you’ll be able to

describe it formally

Goal

•Understand current PL

research (PLDI, POPL,

OOPSLA, …)

Final Goal: Fun

Prerequisites

  • Undergraduate

compilers

course

  • “Mathematical

maturity”

Assignments

  • Short Homework Assignments (~7)
  • Scribe Notes (25 / |class_size|)
  • Final Project
  • Final Exam
  • Course Evaluations

Homework Problem Sets

  • Some material can be “mathy”
  • Much like in Calculus, practice is

handy

  • Short: 3 problems / HW
    • This course has no TA
    • I don’t want to be grading …
  • You have one week to do each one

Scribe Notes

  • Long-standing CS tradition
  • Every class one or two students take

detailed notes and latex them up

  • I post the notes
  • Provides
    • a formal set of course note
    • practice (paper writing, typesetting)
    • study guides

Final Project

  • Literature survey, implementation

project, or research project

  • Write a 10-page paper (a la PLDI)
  • Give a 10-15 minute presentation
  • On the topic of your choice
    • I will help you find a topic (many examples)
    • Best: integrate PL with your current research

Final Exam

  • I reserve the right to make

threatening noises about a take-

home final exam

  • But there’s no TA …
    • Draw your own conclusions
    • Notably, if everyone does quite well on all other assignments, the final becomes unnecessary

Grand Unified Theory

  • Design a new type system
  • Your type-checker becomes a bug-finder
  • No type errors ⇒ proof program is safe
  • Design a new language feature
  • To prevent the sort of mistakes you found
  • Write a source-to-source transform
  • Your new feature works on existing code

CS 655 - Core Topics

  • Operational semantics
  • Type theory
  • Verification conditions
  • Abstract interpretation
  • Lambda Calculus
  • Concurrency
  • Type systems

Special Topics

  • Program Verification Using Counterexample-Guided Abstraction Refinement
  • Type Systems For Resource Management
  • Possibly: Bug Finding And Verification In The Real World (Coverity guest lecture)
  • What do you want to hear about?

In Our Next Exciting Episode

⇓ σ

⇓ false

Def: σx:= n = n ⇓ σ[x := n]^ σx:= n =^ σ(y)

⇓ n

⇓ σ’

⇓ true ⇓ σ’

Meat Today? Judgments

hypotheses therefore result ⇓ n {Z}  Z ∧ ((P ⇒ Q) ⇒ P) ⇒ P Θ; ∆; Σ; Γ  x : Γ(x)

Can really show anything. Varies by judgment.

Rules of Inference

Conclusion

Hypothesis 1 … HypothesisN

Γ  if b then e1 else e2 : τ

Γ  b : bool Γ  e1 : τ Γ  e2 : τ

  • For any given proof system, a finite number of rules of inference (or schema) are listed somewhere
  • Rule instances should be easily checked
  • What is the definition of “NP”?

Derivation

  • Tree-structured (conclusion at bottom)
  • May include multiple sorts of rules-of- inference
  • Could be constructed, typically are not

For Next Time

  • See webpage under “Lectures”
  • Read Winskel Chapter 2
  • Read Hoare article
  • Peruse the optional readings
    • You know you want to
  • Be ready to do scribe scheduling