CSE341: Programming Languages Course Mechanics, Lecture notes of Programming Languages

An overview of the course mechanics for CSE341: Programming Languages. The course covers fundamental concepts of programming languages and aims to make students better programmers. The course uses ML, Racket, and Ruby languages to teach concepts of functional programming, variable bindings, and first-class functions. a concise to-do list, course creator and staff contact information, and lecture notes. useful as study notes, lecture notes, and summaries for university students taking CSE341: Programming Languages.

Typology: Lecture notes

2019/2020

Uploaded on 05/11/2023

alopa
alopa 🇺🇸

4.2

(19)

255 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE341: Programming Languages
Lecture 1
Course Mechanics
ML Variable Bindings
Zach Tatlock
Winter 2020
Welcome!
We have 10 weeks to learn the fundamental concepts of
programming languages
With hard work, patience, and an open mind, this course makes
you a much better programmer
Even in languages we won’t use
Learn the core ideas around which every language is built,
despite countless surface-level differences and variations
Poor course summary: “Uses ML, Racket, and Ruby”
Today’s class:
Course mechanics
[A rain-check on motivation]
Dive into ML: Homework 1 due Wednesday of next week
Winter 2020 2CSE 341: Programming Languages
Concise to-do list
In the next 24-48 hours:
1. Read course web page:
http://courses.cs.washington.edu/courses/cse341/20wi/
2. Read all course policies (4 short documents on web page)
3. Adjust class email-list settings as necessary
4. Get set up using Emacs [optional; recommended] and ML
Installation/configuration/use instructions on web page
Essential; non-intellectual
No reason to delay!
Winter 2020 3CSE 341: Programming Languages
Who: Course Staff
Winter 2020 4CSE 341: Programming Languages
Zach Tatlock: Faculty, 341 my favorite course / area of expertise
Still figuring out
TAs, stay tuned
Get to know us!
pf3
pf4
pf5
pf8

Partial preview of the text

Download CSE341: Programming Languages Course Mechanics and more Lecture notes Programming Languages in PDF only on Docsity!

CSE341: Programming Languages

Lecture 1

Course Mechanics

ML Variable Bindings

Zach Tatlock

Winter 2020

Welcome!

We have 10 weeks to learn the fundamental concepts of programming languages With hard work, patience, and an open mind, this course makes you a much better programmer

  • Even in languages we won’t use
  • Learn the core ideas around which every language is built, despite countless surface-level differences and variations
  • Poor course summary: “Uses ML, Racket, and Ruby” Today’s class:
  • Course mechanics
  • [A rain-check on motivation]
  • Dive into ML: Homework 1 due Wednesday of next week Winter 2020 CSE 341: Programming Languages 2

Concise to-do list

In the next 24-48 hours:

  1. Read course web page: http://courses.cs.washington.edu/courses/cse341/20wi/
  2. Read all course policies (4 short documents on web page)
  3. Adjust class email-list settings as necessary
  4. Get set up using Emacs [optional; recommended] and ML
    • Installation/configuration/use instructions on web page
    • Essential; non-intellectual
      • No reason to delay!

Who: Course Staff

Zach Tatlock: Faculty, 341 my favorite course / area of expertise Still figuring out TAs, stay tuned… Get to know us!

Who: Course Creator

Winter 2020 CSE 341: Programming Languages 5 Dan Grossman, CSE Faculty Occasionally will be referred to as “Prof. DJG” Has poured blood, sweat, and tears into this material. Awesome material, any mistakes / shortcomings are Zach’s fault!

Staying in touch

  • Message Board
    • For most class discussions
    • TAs will monitor
  • Course email list: [email protected]
    • Students and staff already subscribed
    • You must get announcements sent there
    • Fairly low traffic, usually just unexpected / urgent situations
  • Course staff: [email protected]
    • Please always email the staff list, not individuals Winter 2020 CSE 341: Programming Languages 6

Lecture: Zach

  • Slides, code, and reading notes / videos posted
    • May be revised after class
    • Take notes : materials may not describe everything
      • Slides are just visual aids for me to use
  • Ask questions, focus on key ideas
  • Engage actively
    • Arrive punctually (beginning matters most!) and well-rested
      • Just like you will for the exams!
    • Write down ideas and code as we go
    • If attending and paying attention is a poor use of your time, one of us is doing something wrong

Section

  • Required: will usually cover new material
  • Sometimes more language or environment details
  • Sometimes main ideas needed for homework
  • Will meet this week: using Emacs and ML Material often also covered in reading notes / videos

Academic Integrity

  • Read the course policy carefully
    • Clearly explains how you can and cannot get/provide help on homework and projects
  • Always explain any unconventional action
  • I am a great believer in and enforcer of academic integrity
    • Great trust with little sympathy for violations
    • Honest work is the most important feature of a university
  • This course especially: Do not web-search for homework solutions! We will check! Winter 2020 CSE 341: Programming Languages 13

Exams

  • Midterm: Friday February 7, in class
  • Final: Wednesday March 18, 8:30-10:20am
  • Same concepts, but different format from homework
    • More conceptual (but write code too)
    • Will post old exams
    • Closed book/notes, but you bring one sheet with whatever you want on it Winter 2020 CSE 341: Programming Languages 14

Coursera (more info in document)

  • Prof. DJG has taught this material to thousands of people around the world - A lot of work and extremely rewarding
  • You are not allowed to participate in that class!
    • Do not web-search related to homework problems!
  • This should have little impact on you
    • Two courses are separate
    • 341 is a great class and staff is committed to this offering being the best ever

Has Coursera help/hurt 341?

  • Biggest risks
    • Becomes easier to cheat – don’t! (And we’ve changed things)
    • Instructors become too resistant to change – hope not!
  • There are benefits too
    • The videos
    • More robust grading scripts
    • Way fewer typos
    • Easier software installation (new SML Mode)
    • Taking the “VIP version” of a more well-known course
    • Change the world to be more 341-friendly

Questions?

Anything I forgot about course mechanics before we discuss, you know, programming languages? Winter 2020 CSE 341: Programming Languages 17

What this course is about

  • Many essential concepts relevant in any programming language
    • And how these pieces fit together
  • Use ML, Racket, and Ruby languages:
    • They let many of the concepts “shine”
    • Using multiple languages shows how the same concept can “look different” or actually be slightly different
    • In many ways simpler than Java
  • Big focus on functional programming
    • Not using mutation (assignment statements) (!)
    • Using first-class functions (can’t explain that yet)
    • But many other topics too Winter 2020 CSE 341: Programming Languages 18

Why learn this?

This is the “normal” place for course motivation

  • Why learn this material? But in our experience, we don’t yet have enough shared vocabulary
  • So 3-4 week delay on motivation for functional programming
  • I promise full motivation: delay is worth it
  • (Will motivate immutable data at end of “Unit 1”)

341 claim

Learning to think about software in this “PL” way will make you a better programmer even if/when you go back to old ways It will also give you the mental tools and experience you need for a lifetime of confidently picking up new languages and ideas [Somewhat in the style of The Karate Kid movies (1984, 2010)]

The semantics

  • Syntax is just how you write something
  • Semantics is what that something means
    • Type-checking (before program runs)
    • Evaluation (as program runs)
  • For variable bindings:
    • Type-check expression and extend static environment
    • Evaluate expression and extend dynamic environment So what is the precise syntax, type-checking rules, and evaluation rules for various expressions? Good question! Winter 2020 CSE 341: Programming Languages 25

ML, carefully, so far

  • A program is a sequence of bindings
  • Type-check each binding in order using the static environment produced by the previous bindings
  • Evaluate each binding in order using the dynamic environment produced by the previous bindings - Dynamic environment holds values , the results of evaluating expressions
  • So far, the only kind of binding is a variable binding
    • More soon Winter 2020 CSE 341: Programming Languages 26

Expressions

  • We have seen many kinds of expressions: 34 true false x e1 + e2 e1 < e if e1 then e2 else e
  • Can get arbitrarily large since any subexpression can contain subsubexpressions, etc.
  • Every kind of expression has
    1. Syntax
    2. Type-checking rules
      • Produces a type or fails (with a bad error message L)
      • Types so far: int bool unit
    3. Evaluation rules (used only on things that type-check)
      • Produces a value (or exception or infinite-loop)

Variables

  • Syntax: sequence of letters, digits, _, not starting with digit
  • Type-checking: Look up type in current static environment - If not there fail
  • Evaluation: Look up value in current dynamic environment

Addition

  • Syntax: e1 + e2 where e1 and e2 are expressions
  • Type-checking: If e1 and e2 have type int , then e1 + e2 has type int
  • Evaluation: If e1 evaluates to v1 and e2 evaluates to v2 , then e1 + e2 evaluates to sum of v1 and v Winter 2020 CSE 341: Programming Languages 29

Values

  • All values are expressions
  • Not all expressions are values
  • A value “evaluates to itself” in “zero steps”
  • Examples:
    • 34 , 17 , 42 have type int
    • true , false have type bool
    • () has type unit Winter 2020 CSE 341: Programming Languages 30

Expressions

Values

Slightly tougher ones

What are the syntax, typing rules, and evaluation rules for conditional expressions? What are the syntax, typing rules, and evaluation rules for less-than expressions?

The foundation we need

We have many more types, expression forms, and binding forms to learn before we can write “anything interesting” Syntax, typing rules, evaluation rules will guide us the whole way! For Homework 1: functions, pairs, conditionals, lists, options, and local bindings

  • Earlier problems require less Will not add (or need):
  • Mutation (a.k.a. assignment): use new bindings instead
  • Statements: everything is an expression
  • Loops: use recursion instead