Skip to main content

CSC 151.01, Class 03: Basic types

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Questions
  • Quiz
  • Lab
  • Debrief

Start-of-class algorithms

Today’s “start of class algorithm”

  1. If you were here on Wednesday, return to the workstation you used on Wednesday. Otherwise, hang out at the back of the room.
  2. Put your names on a card.
  3. Hand the card to a mentor.

The normal “start of class algorithm” (resumes Monday)

  1. Take any handouts. (There will not always be handouts.)
  2. Grab a card.
  3. Read the name of the workstation and its location.
  4. Attempt to determine where that workstation is.
  5. If you have difficulty, ask the instructor or mentor.
  6. Put the card in the jar.
  7. Make your way to the indicated workstation
  8. Have a seat
  9. If you are the second person there, introduce yourself.

Preliminaries

News / Etc.

  • Welcome to our temporary new version of Shelby! Smarly
  • Thanks for keeping the room neat.
  • When you speak in class, please say your name first.
  • Contact Sam if you would like to be on the department mailing list.
    • Tantalizing talks
    • Outstanding opportunities
    • Scintillating spam
    • Much more!
  • It was nice to see many of you at yesterday’s convocation. In addition to presenting a valuable topic, I found that the speaker revealed some interesting things about public lectures (or at least my experience of public lectures).
  • Wednesday’s lab reinforced for me the sense that computers are sentient and malicious.
    • A space at the end of the GitHub repo URL made things break. (And spaces are invisible.)
    • But that’s just an instance of “Computer programs are badly designed.” (Or, to us active voice: “Programmers design badly.”)
    • The general evidence, which you will likely see starting in today’s lab, is that you often encounter the following situation:
      • You try something.
      • It doesn’t work.
      • Someone in authority (e.g., SamR) comes and looks over your shoulder.
      • They tell you to do the same thing. (Or they do the same thing themselves.)
      • It works.
    • That is, the computers pay attention to what is happening and do their best to embarrass you.

Upcoming work

  • Signed academic honesty policy due in class TODAY!
  • Assignment 2 due Tuesday night.
    • Your partner for Wednesday and today is your partner for the homework.
    • You should make plans as to when you will work on the assignment together, presumably in this room or the neighboring one (3815).
  • Readings (online), due before class Monday.
  • Flash cards due at the end of the day Wednesday.
    • I’ll talk more about those on Monday.

Extra credit (Academic/Artistic)

  • Tosca (MET Opera in HD). 11:30am Saturday at Harris Cinema.

Extra credit (Peer)

Extra credit (Misc)

Other good things

Questions

What’s a procedure?
Another name for subroutine. We may also use “function” or “method”.
Some computer scientists differenetiate. We won’t.
How do I write for an expert chef, given that I’m not one?
Narrative imagination.
Let’s think about a chocolate chip cookie recipe. It probably begins something like the following: “Sift together the flour, the baking powder, and the salt. Soften the butter and gradually stir in the sugar. Mix the eggs separately …” How many of those instructions does someone who cooks regularly need?
How do I get an individual tutor?
Talk to Sarah Dahlby Albright, whose office is at the East end of the hall.
Make sure to make use of Mentoring sessions.
Note that I generally recommend waiting through two quizzes before getting an individual tutor.
Can you review the difference between a variable and a parameter?
Both name values.
parameters name values that are the inputs to your algorithm, such as the loaf of bread.
variables name values you compute within your algorithm, such as “slice one” and “slice two”.
That was way too confusing. Can you please give a better example, say from my experience with mathematics?
Sure.
Consider the problem of finding the root of a quadratic.
Input is a, b, and c from axx + b*x + c.
Compute the discriminant. (sqrt (- (square b) (* 4 a c)))
Root 1 is (/ (+ (- b) discriminant) (* 2 a))
Root 2 is (/ (- (- b) discriminant) (* 2 a))
It’s not that simple, is it? Some variables you compute along the way can become parameters to a subroutine, right?
You are correct. Nothing is every simple.
What’s the relationship between parameters and subroutines?
A subroutine is basically just an algorithm
That we expect to use in a “larger” algorithm
Most algorithms need input
We refer to those inputs as “parameters”
Why don’t we use the term “input” rather than “parameter”
We make ourselves feel special by using specialized terms that outsiders do not understand.
Where do I find the work due for this class?
On the class web site.
I tend to use the schedule, news, and/or current eboard
Anywhere else?
Your notebook? I do go through the list at the start of each class.
What’s a predicate?
It’s a true/false question
And yes, it’s the question itself

Quiz

  • Ten minutes.
  • Use each letter once.
  • When you are finished, please sit quietly.
  • Sorry if that was stressful. We pushed too hard. We generally try not to.

Lab

  • Start by making sure that both you and your partner finish Wednesday’s lab.

Debrief

General processes

  • When things are going well, most people get through most of the lab.
    • For whatever reason, we’re going a bit slower today. It’s my fault, not yours.
    • In general, if you don’t finish lab during class, you should plan to finish on your own.
    • You’ll need to understand the numeric exercises (1 through 6) in order to do the homework.
  • Regularly swap places with your partner!
    • The person at the computer is the “driver”.
    • The person looking over their shoulder and helping keep them on track is the “navigator”
    • There’s a benefit to being in each position.
  • You can copy longer expressions from the lab itself.
    • But when you copy the greater-than-sign prompt, you’ll get some strange output.
  • If you want to keep a record of what you’ve done, you can copy from the interactions pane to the definitions pane and then surround the text with #| and |#. (Demo.)

Javascript

  • Javascript is a programming language that normally runs in Web browsers and provides for more interactivity on a Web page.
  • Our SysAdmin disables Javascript by default.
  • That makes many sites unusable.
  • I used to think our SysAdmin was paranoid. Then Spectre appeared.
  • (If you haven’t been paying attention, Spectre is an approach to extracting private information that relies on the way the underlying hardware works, but there was a “proof of concept” that showed you could get info out of a Web browser with clever Javascript.)

Conceptual

  • We get a strange numerator and denominator for things like 1.2 because Scheme, like most computer languages, wants to express the fractional part as a ratio whose denominator is a power of 2. There is no such fraction for 1/5, so it just chooses a really large power of 2 and approximates.