Programming Languages and Techniques (CIS120) Lecture 2, Lecture notes of Programming Languages

Information about the CIS120 course, including homework policies, recitations, important dates, and the use of clickers. It also provides instructions for accessing course materials and installing necessary software. The course focuses on value-oriented programming and uses OCaml/Eclipse. Homework assignments are mostly automatically graded and require passing a certain number of tests. Late submissions are penalized. Exams include two midterms and a final. Clickers are used in each lecture.

Typology: Lecture notes

2012/2013

Uploaded on 05/11/2023

anuradha
anuradha 🇺🇸

4.6

(9)

240 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Programming)Languages))
and)Techniques)
(CIS120))
Lecture)2)
January)17,)2013)
ValueCOriented)Programming)
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

Partial preview of the text

Download Programming Languages and Techniques (CIS120) Lecture 2 and more Lecture notes Programming Languages in PDF only on Docsity!

Programming Languages

and Techniques

(CIS120)

Lecture 2

January 17, 2013

Value-­‐Oriented Programming

If you are joining us today…

• See Wed’s slides/screencast on course website

• Read the course syllabus/lecture notes on the

website

• Sign yourself up for Piazza

hPp://www.piazza.com/

• Install OCaml/Eclipse on your laptop; ask if you have

quesWons

hPp://www.seas.upenn.edu/~cis120/current/

ocaml_setup.shtml

• No laptops, tablets, smart phones, etc., during

lecture

Announcements

• Please read:

  • Chapter 2 of the course notes
  • OCaml style guide on the course website (hPp://www.seas.upenn.edu/~cis120/current/ programming_style.shtml)

• Homework 1: OCaml Finger Exercises

  • PracWce using OCaml to write simple programs
  • Start with first 4 problems (lists next week!)
  • Due: Tuesday, January 28 th at 11:59:59pm (midnight)
  • Start early!

• Guest lecturer (Peter-­‐Michael Osera) next week

  • Prof. Weirich OH Monday, then away Tuesday-­‐Saturday

Homework Policies

  • Projects will be (mostly) automaWcally graded
    • We’ll give you some tests, as part of the assignment
    • You’ll write your own tests to supplement these
    • Our grading script will apply addiWonal tests
    • Your score is based on how many of these you pass
    • Some assignments will also include style points, added later
    • Your code must compile to get any credit
  • You will be given your score (on the automaWcally graded porWon of the assignment) immediately
  • MulWple submissions are allowed
    • First few submissions: no penalty
    • Each submission aker the first few will be penalized
    • Your final grade is determined by the best raw score
  • Late submissions
    • 10 point penalty if less than 24 hours late
    • 20 point penalty if 24-­‐48 hours late
    • Submissions not accepted a6er 48 hours past the deadline

Important Dates

  • Homework:
    • Homework due dates listed on course calendar
    • Mostly Tuesdays, some Fridays
  • Exams:
    • 12% First midterm: Friday, February 21 st , in class
    • 12% Second midterm: Friday, April 4 th , in class
    • 18% Final exam: Wednesday, May 7 th , 9-­‐11 AM
    • Contact me well in advance if you have a conflict

Where to ask quesWons

• Course material

  • Piazza Discussion Boards
  • TA office hours, on webpage calendar
  • Tutoring, Sunday and Monday evenings
  • Prof office hours: Mondays from 1 to 3 PM, or by appointment (changes will be announced on Piazza)

• HW/Exam Grading: see webpage

• About the CIS majors

  • Ms. Jackie Caliman, CIS Undergraduate coordinator

Clicker Basics

• Beginning today, we’ll use clickers in each lecture

  • Grade recording starts 1/

• Any kind of TurningPoint ResponseCard is fine

  • Doesn’t have to be the exact model sold in the bookstore

• Use the link on the course website to register your

device ID with the course database

CIS120 6-­‐character device ID

Test Drive

• Clickers out!

• Press any of the number buPons

  • Make sure the display looks like this:

• If it looks like this…

  • … first check that the channel is set to 41
    • If not, try pressing Channel, then 41, then Channel again to reset the channel
  • If this doesn’t work come to office hours

In what language do you have the most significant programming experience?

  1. Java C#!
  2. C, C#, C++ or Objective-C!
  3. Python, Ruby, or MATLAB!
  4. Clojure, Scheme, or LISP!
  5. OCaML, Haskell, or Scala!
  6. Other!

Programming in OCaml

Read Chapter 2 of the CIS 120 lecture notes,

available from the course web page

Value-­‐Oriented Programming

• Java, C, C#, C++, Python, Perl, etc. are tuned for an

impera2ve programming style

  • Programs are full of commands
    • “Change x to 5!”
    • “Increment z!”
    • “Make this point to that!”

• Ocaml, on the other hand, promotes a value-­‐

oriented style

  • We’ve seen that there are a few commands…
    • e.g., print_endline, run_test … but these are used rarely
  • Most of what we write is expressions denoWng values

Metaphorically, we might say that

imperaWve programming is about doing

while

value-­‐oriented programming is about being

What is an OCaml module?

open Assert let attendees (price:int) :int = (- 15 * price) / 10 + 870 let test () : bool = attendees 500 = 120 ;; run_test "attendees at 5.00" test let x = attendees 500 ;; print_int x ;; print_endline "end of demo" module import commands funcWon declaraWons let declaraWons

(Top-­‐level) Let DeclaraWons

A let declaraWon gives a name (a.k.a. an iden;fier ) to

the value of some expression*

There is no way of assigning a new value to an

idenWfier aker it is declared.

let pi = 3. let seconds_per_day = 60 * 60 * 24! *We someWmes call these idenWfiers variables , but the terminology is a bit confusing because in languages like Java and C a variable is something that can be modified over the course of a program. In OCaml, like in mathemaWcs, once a variable’s value is determined, it can never be modified… As a reminder of this difference, for the purposes of OCaml we’ll try to use the word “idenWfier” when talking about the name bound by a let.