Lecture 9

Last times

  • In week 0, we said:
    • what ultimately matters in this course is not so much where you end up relative to your classmates but where you, in Week 10, end up relative to yourself in Week 0
  • And indeed, looking back now, we’ve learned new technologies and concepts every week. Even though we might not have ever felt like we were completely comfortable, we’ve certainly gained experience and knowledge in more and more areas.
  • In our first problem set, we probably found it difficult to print out a pyramid of # marks. But now, we’re able to build an entire web application for CS50 Finance, with a back-end and a front-end, using a number of languages and frameworks.
  • One of your classmates wrote, “Beside learning the new material, I felt that I started to be more ‘comfortable with being uncomfortable’ and being okay with working towards building a skill rather than just getting the right answer…”, which beautifully encapsulates one of the goals of this course. Indeed, even in the real world, languages and technologies evolve over time, but we’ve come to appreciate principles of abstractions and tradeoffs and algorithms and data structures that will guide us in solving problems with computer science.
    • In fact, David himself had to learn Python a few years ago! And he too had to figure out how to build the Frosh IMs site years ago, since web development wasn’t part of the CS curriculum back then.
  • A big thank you to all the staff, including the production team, the TFs and CAs, and course heads, without whom this course would not be possible.
    • In particular: Cheng, who has been writing these notes; Veronica, who has been translating the course’s materials in Spanish; and Brian, who has been an extraordinary head TF these past few years.
  • In week 0, we learned that algorithms were a series of steps to solve a problem, given some inputs and outputs:
    box with word "algorithms"
    • And to represent those inputs and outputs in computers, we needed to understand bits, binary digits, atop which we discovered abstractions like ASCII for text characters, Unicode for emoji, and RGB for pixels in images and videos.
    • We wrote some algorithms down in pseudocode, and were already able to discuss running time of algorithms in terms of steps required to solve a problem of size n:
      chart with: "size of problem" as x-axis; "time to solve" as y-axis; red, steep straight line from origin to top of graph labeled "n"; yellow, less steep straight line from origin to top of graph labeled "n/2"; green, curved line that gets less and less steep from origin to right of graph labeled "log n"
    • Finally, we were introduced to Scratch, where we practiced using these new programming concepts.
  • Then, in week 1, we transitioned to learning C, where we used only text to write source code, which was then compiled into machine code, binary that our computer could actually run.
  • In week 2, we learned more programming features like functions, arguments, and discussed memory, where we could change bytes on the hardware of our computer, to store and work with data:
    computer chip with grid overlaid
  • In week 3, we learned about strings in C, which led us to discover pointers. In week 4, we used pointers to build data structures like a trie:
    array with blanks, and letters M, P, T; each letter points to another array, with blanks, and some letters that each point to other arrays and letters in them
  • In week 5, we learned about (many) web technologies like HTTP, DNS, IP, HTML, CSS, and JavaScript. We looked at request headers and response codes in HTTP, and we looked at HTML’s Document Object Model (DOM) that represents a webpage in the browser:
    simple webpage mapped to a tree with each element as a node, nested
    • And as an aside, in one year’s Harvard-Yale football game, some Yale students actually managed to prank much of the Harvard audience to hold signs that read “WE SUCK”!
  • In week 6, we learned Python, a higher-level language that includes features like linked lists and hash tables, so we don’t need to implement them ourselves before we start writing more useful programs.
  • In week 7, we looked at one particular paradigm of web programming, Model-View-Controller, which is just one popular pattern for organizing our code:
    request (HTTP, CLI, etc.) from a client goes into a Controller, which demands from a Model (Database, WS, etc) and receives data that it then sends to a View (Templates, layout) which are sent back to the client as a response (HTML, RSS, XML, JSON, etc.)
  • Finally, in week 8, we looked at SQL and databases more generally, with which we can query data efficiently and cleanly.

Next times

Jeopardy

  • We take a few staff and student volunteers, and play Jeopardy! These questions and answers were submitted by students as suggested quiz questions.
  • The first question: What institution developed Scratch?
    • Answer: MIT
  • Question: What color is the cat?
    • Answer: Orange
  • Question: What is running time of merge sort?
    • Answer: O(n log n)
  • Question: What is the tool you can run if your program has memory leaks?
    • Answer: Valgrind
  • Question: What is rubber duck debugging?
    • Answer: When you read your code to a rubber duck and try to find the mistake.
  • Question: Is the C the absolute worst?
    • Answer: Yes
  • Question: What is the name of an animal you don’t want to find under your pillow? (That shares a name with a programming language.)
    • Answer: Python
  • Question: Who is your friend?
    • Answer: Bootstrap
  • Question: What is the (HTTP response) code for OK?
    • Answer: 200
  • Question: What do you call the situation where a structure refers to itself in its definition?
    • Answer: Recursion
  • Question: In what state, besides Massachusetts, does Google sometimes think we reside?
    • Answer: Kansas
  • Thanks for joining us!