‹ go back

CPSC 110: 1a.

Published 13 December 2020 at Yours, Kewbish. 1,254 words. Subscribe via RSS.


This post is unlisted and has been archived. This doesn't represent my best work; please check out the posts listed here instead.

Introduction

Racket, so far, has been an interesting language - lots of parentheses matching and prefix notation mistakes. It’s unlike what I’m used to (which is rather cobbled-together Python) but it’s also quite fun to use. Also, because people keep asking: no, I didn’t just decide to learn Racket for my own amusement, though I’ve certainly got a lot out of the few short weeks I’ve used it. I’m planning on taking CPSC 1101, which uses Racket extensively, and I’d like to do the course first. (Why does it feel like I’ve said this before? I don’t know.)

I’d initially tried to take the open edX version of it, but I got a bit sidetracked with rack8, my Chip-8 emulator, and ended up letting it time out. It wouldn’t let me into the course after a month, which was rather unfortunate.

However, I managed to finagle myself into the actual CPSC Edge (private edX platform, I think?) that’s used. This contains the current problem sets and labs, as well as having a lot more final exam practises than on the public version. Fun! (Also, this won’t time out until the end of the semester in late April, so I’ll definitely be good on time.)

In this sort-of-series, I’d like to document my progress through CPSC 110 (which should be the same as if on the public version anyhow). I did something similar last summer with CS50, so hopefully I’ll be more motivated to complete everything in a timely manner. Here’s the first post: notes and thoughts on part 1a, in which Kiczales guides us on a scenic tour of BSL (Beginning Student Language).

Notes

Like my CS50 posts, I’m generally going to put my personal notes here. Skip to the reflection if you wish.

  • Racket works with expressions (each statement in parentheses, essentially) to form programs
    • each exp is an element that is evaluated (Racket is compiled and then run from the bytecode)
    • functions go first, parameters later, so (+ 3 4) (which would be 7) (prefix notation)
    • have a very specific style guide w/ where they want spaces, refer to expressions section
  • examples of primitives => strings, numbers
    • basic data structure provided by BSL (and later basically Racket)
  • follows order of operations => evaluates innermost first, from left to right
    • each step of the evaluation plugs in results to the next one
    • frequently in the embedded questions
  • Racket substring indices work like Python => range but excludes last one
  • using (require 2htdp/image) brings in image primitives
    • can draw with (above) and (overlay), etc
    • stack (circle)s and other primitives inside => refer to docs
    • (# interesting that they choose to use images in their first examples, probably makes things a bit more intuitive?)
  • definitions with (define) => Kiczales says these are generally capitalized
    • also can define functions as long as fn name and parameters in sep set of parentheses
    • fn is evaluated first by evaluting arguments and plugging those into main fn expressions
    • then the same rules of evaluation follow throughout
    • can use Stepper to see step-by-step evaluation of entire program in DrRacket
  • booleans are true and false, instead of the #t and #f I used in rack8
    • are actually equivalent but I suppose for CPSC 110 use true/false
    • use (and), (or), and (not) to evaluate multiple (see conditionals section)
    • and only evaluates until it finds one that isn’t true, or evalutes only until it finds an expression that is true
  • Racket doesn’t have a single expression if => must have an else clause
    • in rack8 just used a void expression, haven’t gone through what to do in the recommended CPSC 110 style
    • the expression must go as a second argument in parentheses
  • if evaluation, and other conditional expressions first evaluate the ‘question expression’s
    • then replaces the body of the if with either the true or false expression and evaluate the entire final expression
    • if neither, then produce an error

A Short Reflection

As an aside, it feels kind of weird to take notes on this, especially as some of it’s stuff I’ve muddled my way through via experience with rack8. However, I have a feeling I’m going to forget the specifics if I don’t at least try to record it, and perhaps this will serve as some sort of guide for others who are also investigating CPSC 110 or Racket.

Also, a brief note on setup. It’s entirely possible to do Racket and most of what’s done by Kiczales in a different IDE than DrRacket. Is it recommended to use Vim just because one feels like it? Probably not, but I couldn’t be bothered to set it up while doing rack8, and now also cannot be bothered to set it up, since everything already works fine(ish) in Vim. I won’t get the image functionality, or the REPL (though I could do that in VimScript or an extension), but I’m alright with that.

I think I prefer Kiczales’s teaching style to Malan’s (see CS50 posts), or at least the course organization overall. CS50 lectures were very long chunks of information, and I find CPSC 110 is sort of like watching all of the CS50 shorts with questions in between.

That shorter cycle has been a lot more helpful, especially with the way the Edge course sticks a bunch of questions in some very innovative formats2 in between each video. Kiczales’s videos are nicely clear and concise, and theywork even when not using DrRacket or listening fully. Also, kudos to whoever had to edit and put in those arrows and annotation diagrams - they’re super helpful, but were probably extremely painful to animate and put in.

Conclusion

Section 1a of the course has mostly been basic material that I’ve covered on my own, but I think it’s still valuable to review, especially the finer minutiae of evaluation ordering and what exactly is expected style-wise in autograder submissions. I’m looking forward to section 1b, which is more on ‘how to design functions’. From what I’ve researched on my own, there seems to be a pattern recipe of some kind involved, but we’ll see more about that in the next CPSC 110 post.

On the more logistics side of things, I don’t think I’ll be able to churn through a section a week (or maybe I will - who knows? Winter break is coming up-), so I’ll try to break things up with some thought-chain posts. Those will be the HCI ones, like the one I made recently regarding persisting context in annotations. Hopefully that’ll give me some more time to absorb and process the CPSC 110 material, as well as explore some of the thinking I’ve been doing on my own regarding HCI. I’m looking to finish this course sometime before the summer, hopefully so I can challenge the course right after I graduate, or sometime in the first term. We’ll see, but for now, I’ll be going back to BSL, and more Racket.


  1. UBC’s introductory course on designing programs that all students pursuing some form of CS will have to take some form of. I could take 103 + 107, but that’d be 2x more courses for roughly the same material, according to certain sources. Also, I can challenge the exam, which will save me a good amount of time and effort. ↩︎

  2. I was not aware the question could see what part of the screen you were clicking on, which enabled some interesting question formats. Think along the lines of ‘identify a parameter in this function call code block, put this green dot over it.’ ↩︎


‹ go back