October 3-7, 2022.
Programming Languages as a Field of Study, JavaScript, Python.
You will take the exam on BrightSpace; it will be multiple choice with a 90 minute time limit. You MAY use books, notes, and web searches to look things up. You will not be spied on: there is no browser lock down and hence no need to hide a mobile device in a bag of potato chips. However, you MAY NOT solicit answers in any way. There is to be no asking for help, no posting on forums, no communication with other humans or intelligent bots in any way; you can only “look things up.” You also MAY NOT post answers or help any other test taker either. You are bound by an honor code to follow these rules.
The exam becomes available at 6pm America/Los Angeles time on October 3 and becomes inaccessible at 10pm on October 7. You may complete the exam within any 90 minute period in that window.
Step one of your preparation is to remember the learning objectives from the syllabus. Please review them now.
To meet these objectives throughout the course you must gain an understanding of both big picture and low-level questions about programming language pragmatics. You should be able to answer, for particular languages (and for the exam, JavaScript and Python):
This is just a tiny number of the questions we can ask.
We began the course with a look into how one studies programming languages, including how languages are classified and to what extent they support or do not support various programming paradigms.
Then we began our tour of programming language concepts with deep dives into JavaScript and Python. In addition to language history we uncovered and practiced many technical linguistic aspects. Here is a small subset of things we learned:
JavaScript | Python | |
---|---|---|
First Appeared | 1995 | 1991 |
Designer | Brendan Eich | Guido von Rossum |
Versions | ES2015 and later is “modern” JS; we use ES2022 in this class. | Python 2 is no longer supported! We use Python 3.10. |
Recognized For | First-class functions, prototypes | Wonderful expressiveness |
Notable Uses | Webapp clients, asynchronous servers | Web servers, scripting, data science |
Six words or less | The assembly language of the web | Easy to learn and extremely productive |
REPL | node | python
|
Runs command line scripts | Yes | Yes |
Can be hosted? | Yes (in browser, usually) | Not designed to be |
Typing Systems | Dynamic and Weak | Dynamic and Strong |
Dynamic Types | Technically only 8, cannot create more, but “faked” with constructors | Dozens built-in, user can create infinite number of new types |
Static Typing | Not exactly, as TypeScript is considered a different language | Yes, but type hints are ignored at run time |
Distinguishes primitive and reference Types? | Yes | No, everything is an object (BEAUTIFUL) |
Getting the type of an expression | typeof (operator, funky) or .constructor | type |
Types are.... | just kind of there, they surface as strings with typeof | really objects! |
What’s falsy? | undefined, null, false, 0, NaN, empty string | None, False, numeric 0, empty sequences, empty mappings, instances of classes where __nonzero__ or __len__ return 0 or False. |
Objects vs. Dictionaries | Kind of conflated, but there is a built-in Map | Very different. Dictionaries have type dict, objects are instances of a class |
Objects have | properties, keyed by strings or symbols or numbers | attributes |
Object philosophy | Prototypes | Classes |
Getters | get | @property |
Can properties / attributes be added to existing objects? | Yes | Yes |
Syntax Grouping | Curly braces | Indentation |
Statement separator | ; but language uses weird algorithm to add them if you forget them | ; if multiple statements on same line, otherwise newline unless inside of delimiters or triple-quoted string literals.
|
Local variable declarations | Declare with let or const (legacy var also supported) | Just assign to a variable in function; it will be be local unless a nonlocal or global declaration for the identifier preceded it.
|
Parallel assignment? | Through array pattern match | Yes (no delimiters needed) |
General destructuring | Yes | Only in match statement |
Increment and decrement operators? | Yes | No! |
Multiline strings | Delimited with backticks | Delimited with triple quotes |
Package Ecosystem | npm | pip |
Common unit testing framework | mocha | pytest |
Interested in more comparisons? Check out the the first two columns of this page. Woah, how useful was THAT?! (Very useful, but be careful because in some areas it might be out of date.)
What other similarities and differences can you think of?
An ideal assessment of your understanding of programming language concepts would examine (1) your ability to articulate these concepts as expressed in the design of JavaScript and Python, and (2) your ability to articulate the similarities and differences between JavaScript and Python in their implementation of these concepts, through an oral exam. However, given the the number of students, this assessment will be on your recognition and evaluation of concept expression in the form of multiple choice and similar questions.
At some point during the exam window, find the quiz on BrightSpace and take it. You will have 90 minutes to complete it. Upon submission you should receive feedback and your score will be recorded in the gradebook.
Review your answers and my answers to the first two homework assignments.
Do the reinforcement problems relevant to the material within the scope of the exam.
Keep in mind that our (world’s) knowledge culture is far more literary than oral, so read, or reread:
You have to put in the time for effortful self-study. Although the exam is open resources, you will not have time to look everything up. Those who come in with a strong comfort level with the material will finish on time. I am assessing your fluency and your proficiency with the material, not your Google-Fu.
What does the following JavaScript function return when called (assuming url
is actually a real url that actually returns real data)?
function mystery() { return fetch(url).then(r => "woohoo").catch(e => "aw snap") }
What is the proper Python list comprehension that replaces the code fragment below?
a = [] for x in first_range: for y in second_range: if x >= y: a.append(y // x)
[y // x for x in first_range for y in second_range if x >= y]
[y // x if x >= y for x in first_range for y in second_range]
[y // x for x in second_range for y in first_range if x >= y]
[y // x for x in first_range if x >= y for y in second_range]