Lecture 0 Slides - Lecture Slides

1 of 75

Welcome!

COMP_SCI 111

2 of 75

About Me - Prof. Connor Bain

Undergrad at the University of South Carolina in Computer Science, Math, and Music

MS/PhD from Northwestern University in Computer Science and Learning Sciences

I'm the Faculty Chair at Willard Residential College

Other classes I teach:

CS 110 - Introduction to Computer Programming

CS 212 - Mathematical Foundations of Computer Science

CS 396 - Communicating Computer Science

CS 397/497 - Pedagogical Design in CS

My research focuses on the idea of computational literacy (both from a design and a cognitive perspective). My in-person office is Tech L374 but online we'll be using Piazza and Zoom.

3 of 75

The goal of this class is not to manufacture expert programmers. Our goal is to build your computational literacy–your ability to see the world as computable. We'll do this by learning how to reason about and design computer programs.

4 of 75

  1. No showing off.
  2. Ask questions.
  3. Respect and help others.
  4. Read carefully.

Course Tenets

This is a learning community

5 of 75

Lecture 0

What is computation? + Course Overview

6 of 75

Plan for Today

  1. What is Computation?
  2. Logistics
  3. Modeling Computation as Data Flow

7 of 75

What’s the information revolution?

  • The shift of certain forms of intellectual labor from humans to machines
  • Including the programming of the machines
    • Increased productivity
    • Certain kinds of intellectual tasks easier and/or cheaper
    • Increases access to knowledge and power (but often not equitably)
    • Enables new kinds of endeavors
    • Eliminates other tasks through economic pressure

8 of 75

9 of 75

10 of 75

The first tool that strengthened the power of his brain rather than his arm.

  • Capt. Grace Hopper

11 of 75

Cultural changes?

  • Too early to tell if information revolution will have the same kinds of long-term unanticipated impact, but …
    • Cell phones, social media, etc., are now major modes of social interaction
    • Facebook is the major news source for 40% of the US population, and that’s changed the dynamics of US elections
    • TikTok has become a major source of knowledge for younger people
    • The video game industry has largely killed the toy industry
    • Almost nobody used libraries for research, but everyone uses google
    • When was the last time you brought a physical music album?
    • Social groups both good and bad all use the internet for recruiting and fundraising
    • Anyone can find out who you know, where you’ve been, and what you do.

12 of 75

but what is computing?

13 of 75

The functional model of computation

A computation

  • Takes a set of inputs
    • Information encoded in some representation(s)
  • Does some stuff (computes)
  • Generates an output
    • Again, information encoded in some representation
  • Stops

input(s)

output

COMPUTE

14 of 75

The functional model

  • A computational problem specifies an output for every possible combination of inputs
    • Essentially, it’s a mathematical function

f(input) = output

  • A computation solves the problem if and only if
    • It always generates the specified output
    • For any given set of inputs
  • The only relevant behavior of a computation is its output
  • We teach the computer how to compute via programs

15 of 75

Question answering

Q: What’s seven plus three?

Pretty much everyone agrees that this is a case of computation

    • I present you with numbers to add
    • You use a mental function to add them
    • You present me with a number (the sum)

A: Ten

16 of 75

What’s <really-big-number>�plus <other-really-big-number>?

17 of 75

What’s different here?

  • I present you with some numbers in spoken English
  • You represent them
    • In a different representation (Arabic numerals)
    • And a different medium (patterns of graphite on paper)
  • And then use a different function to add them
    • It’s now a physical procedure, not just a mental one
  • Translate the answer back into spoken English

18 of 75

Behavioral equivalence

  • It doesn’t matter what representation we use internally
    • English, Arabic numerals, Roman numerals
  • Or what function we use
  • Or where it occurs
    • In the head, on paper, in a computer
  • All that matters is whether we generate the right behavior

speech

speech

writing

writing

add1

add2

write

read

19 of 75

What do we compute with?

20 of 75

Everything in this lecture is data

  • This is a good time to realize that everything you’ve seen so far is data
    • The pictures
    • The text
    • Even actions or functions like add
  • The last one is the really important one: functions are data
  • And programs are made up of functions, which means programs are data too!

21 of 75

Programmability

  • Computers are program interpreters
    • They read a stream of imperatives
    • And do what they say

  • This programmability allows a single device to perform many different tasks
    • Without it, you’d need separate machines for email and word processing
    • Computers wouldn’t be economically feasible

22 of 75

Who can program?

23 of 75

Course Overview

  1. Why should I take this course?
  2. What am I going to learn?
  3. How am I going to learn it?

24 of 75

COMP_SCI 111

Intro programming sequence

  • 111: basic concepts, functional, imperative, and object-oriented programming
  • 150: more on imperative programming & object-oriented programming in Python
  • 214: data structures and algorithms
  • 211: statically typed languages with manual memory management, explicit pointers in C and C++

By the end, you’ll know all the basics of CS as well as have experience with a number of different programming languages.

This course

  • No previous experience expected
  • Core concepts of computer science
  • Practice of Programming and debugging
  • Uses Racket’s Intermediate Student Languagea dialect of the Scheme programming language
    • Low barrier to entry
    • Level playing field
    • Formally more powerful than more conventional languages

25 of 75

Updates for Fall 2026

Intro programming sequence

  • GE / CS 150: basic concepts, imperative, and object-oriented programming
  • CS 180: functional programming; testing
  • CS 208: data structures and algorithms
  • 211: statically typed languages with manual memory management, explicit pointers

26 of 75

Functional programming

  • For the first part of the class, we’ll focus on a style of programming called functional programming, that’s based on the functional model of computation
  • FP is a paradigm of programming in which you avoid imperatives
    • This mostly means programming without assignment statements
      • Can’t do the equivalent of a = a + 1
      • Or a.field = a.field + 1
      • That means you also can’t have for loops or while loops
    • For those of you without programming experience, you've got an advantage here!
  • Functional programming is good to start with because it rules out certain classes of bugs that learners find very difficult to fix

27 of 75

What if I’m interested in CS but I don’t want to major in it?

There are several other formal options for you to consider:

28 of 75

big course ideas

29 of 75

Computation is a tool

Computation is a medium of expression

Computation is language for biology

Computation is language for art

Computation is language for psychology

Computation is language for…

Computation is a playground

30 of 75

Major course themes

  • Programming as com/position
    • Both in the sense of placing elements together
    • And of writing and communication
  • Computer Science as a psychological discipline
    • Humans are the scarcest resource in software development
  • Computer Science as a social discipline
    • Large programs are beyond the capacity of individuals
  • Computer Science as an aesthetic discipline
    • Aesthetics has functional consequences

31 of 75

Aesthetic values in program design

  • Clarity
    • Systems should be easily understood by humans
  • Compositionality
    • Elements should combine cleanly and predictably
  • Generativity
    • A small set of basic elements should be able to create a large range of behaviors
  • Modularity
    • Interactions between elements should be limited, clear, and easily understood

32 of 75

Programming as com/position

  • Function composition
    • Linking outputs to inputs
  • Data composition
    • Primitives
    • Lists and records (tuples)
    • Inductive structures
  • Imperative composition
    • Sequencing changes in time
  • Composing code with data
    • Object-oriented programming
  • Interaction composition
    • Networks, events, and agents

33 of 75

34 of 75

35 of 75

36 of 75

37 of 75

38 of 75

39 of 75

40 of 75

41 of 75

https://youtu.be/BC7P89dw9HQ?si=x1I6PcHaAAuNhHQ9

42 of 75

Skill Building

  1. Composing new programs
  2. Decomposing/debugging existing programs
  3. Communicating about programs

43 of 75

1. composing programs

44 of 75

45 of 75

46 of 75

2. decomposing / debugging programs

47 of 75

48 of 75

49 of 75

50 of 75

3. communicating about programs

51 of 75

administrative stuff

found in the syllabus!

Please read the syllabus carefully. Additionally, take a look at the posted "recommended" schedule.

52 of 75

Academic Integrity

  • You are encouraged to ask one another questions about assignments, but you must do your own work.
  • Easy way to avoid: do not look at anyone's code other than mine or your own.
  • We will consider the following to be academic violations:
    • Turning in someone else’s file
    • Reading and reproducing someone else’s code for a problem
    • Cutting, pasting, transcribing, etc. someone else’s code, in whole or in part
    • Allowing anyone else to type or edit your code other than someone on the course staff
    • Giving your code to someone else or posting your code in any public location
    • Using any tools to generate code.
  • Everything you submit in this class is subject to an in-person audit by course staff.

53 of 75

Other Class Resources

  • We’ll be following the slides and lecture notes, rather directly from a textbook
    • All our course resources will be posted on Canvas
  • We'll use Piazza, an online Q&A platform that allows you to ask questions (either privately or publicly) and have it answered by someone in our learning community. Sign-up details are on Canvas under the Course Resources page.
  • There will be scheduled office hours where you can drop by
  • We'll also suggest readings in two freely available textbooks. If you want a complete supplementary textbook, checkout the syllabus for links to free versions of
    • Abelson and Sussman’s Structure and Interpretation of Computer Programs
    • Felleisen et al.’s How to Design Programs

54 of 75

Difficulty curve of the course

Writing

functions

Lists and

higher order functions

Recursive functions

Imperative programming

and object-oriented programming

55 of 75

Data Flow Diagrams

56 of 75

The functional model of computation

A computation

  • Takes a set of inputs
    • Information encoded in some representation(s)
  • Does some stuff (computes)
  • Generates an output
    • Again, information encoded in some representation
  • Stops

input(s)

output

COMPUTE

57 of 75

Programming is a psychological discipline

  • Reasoning about the actual physical layout of data as binary text is an unnecessary burden on programmers
    • Most people don’t think well in binary
  • So we design programming languages to match how we think about our data so much as possible
  • Your programming language’s compiler and run-time system manage storage for you so you can think in terms of objects instead of bits

58 of 75

Objects

  • A computer’s memory is ultimately implemented as binary text
    • In other words, a series of 0s and 1s.
  • In practice, that text is really a bunch of separate representations of different pieces of data
  • Each of those representations of a piece of data is known as an object

59 of 75

Everything is an object

  • So from now on, everything in your computer’s memory is an object
    • Primitive (indivisible) data objects
      • Numbers (1, 7, -3.5)
      • Text strings ("bla bla bla")
      • functions
    • Compound data objects
      • Tables of data
      • Lists of objects
      • Bitmaps (contain many little color objects, one per pixel)
      • Sounds (contain 1 number per sound sample)

60 of 75

Objects and computation

When we do computation, we traffic in objects

    • Objects are the inputs to functions
    • Objects are the outputs of functions

61 of 75

Types of Objects (aka Data Types)

  • Computers have a taxonomy of types of data objects
  • Every object has a type
    • The object’s type determines what functions it can be used with
    • Example: Can add numbers, but not pictures or functions

object

number

integer

float

function

point

color

picture

string

boolean

exception

contract-violation

arity-mismatch

62 of 75

Calls and data flow

63 of 75

Function calls

  • When we run a function/program, we
    • Specify one data object for each of its inputs
    • Receive one data object as its output
  • Calls are so important, they have many synonyms
    • Run: execute, call, apply, invoke
    • Input: argument, parameter
      • Or: pass (as in “pass the function 2 as an argument”)
    • Output: result, return value

64 of 75

Data flow diagrams

  • Most programming languages use textual notations
  • We will start with a graphical notation called a data flow diagram
    • Easy to understand what is an input to what and what’s the output
    • Doesn’t scale well to complicated programs

  • We’re using this as an informal learning tool: don’t get hung up on trying to memorize the details of it

65 of 75

Changing the inputs changes the output

66 of 75

Except when it doesn’t

67 of 75

Chaining calls

  • In functional programming, programs/functions are built up by chaining together calls of existing functions
    • The output of one becomes the input of another
  • Data flows through the chain, from left to right
    • Hence the name data flow diagram

68 of 75

Chaining chains

69 of 75

A single object can be used as input to many functions

70 of 75

Order of inputs (usually) matters

71 of 75

Different diagrams can produce the same result

72 of 75

Computers are literal-minded

73 of 75

What versus how

  • Over time, you’ll want to learn how to look past the code to understand what a function is trying to do
    • What it computes
    • Versus how it computes it

74 of 75

What versus how

  • Over time, you’ll want to learn how to look past the code to understand what a function is trying to do
    • What it computes
    • Versus how it computes it

Gives the first however many

characters of the input string

75 of 75

Big ideas

  • Data consists of objects
  • Objects come in different types
    • Determines what operations can be performed on it
  • Inputs and outputs of functions are objects
  • Most computation is done by chaining function calls