teaching machines

CS 330 – Final

See the PDF.

CS 330 Lecture 39 – Exit

Dear students, Today we close out our formal exploration of the stuff of programming languages. This is what we said we’d look into in the syllabus: Recognize and exploit the strengths of three major programming paradigms: imperative, functional, and object-oriented. Reason about the strengths and weaknesses of various type systems. Weigh the costs and benefits […]

CS 330 Lecture 38 – Metaprogramming in Java

Dear students, Last time we saw how we could add a hook in Ruby so that when a non-existent method is called on a object, we can still execute the desired action. method_missing lets us write really virtual methods—ones that don’t even exist. Our code effectively used information about the method that would have been […]

CS 330 Lecture 37 – Metaprogramming in Ruby

Dear students, This last week of the semester we enter the crazy world of metaprogramming. What is metaprogramming? Well, there’s been a recurring them in our discussion this semester. C++ pushed very hard to make our data be treated just like builtin data. The classes we write are allowed to be virtually indistinguishable from the […]

CS 330 Lecture 36 – Guish Interpreter

Dear students, I am gone to learn about the state of computer science in high schools across Wisconsin. However, since at least one of you objected to my being gone a few times this semester, we continue our discussion of writing our interpreter! We pick up where we left off last lecture. We ended with […]

CS 330 Lecture 35 – Parsing

Dear students, We started writing our own lexer last time. We were trying to model in code this DFA that we drew on the board: Now, you might not have seen it, but we were actually playing a game of Chutes and Ladders. Each character in our source code was like a roll that moved […]

CS 330 Lecture 34 – Lexing

Dear students, Okay, we’re on a quest to design our own programming language. Usually you’re supposed to start this kind of learning by writing a calculator. I couldn’t bring us to do that. Instead we’re going to design a language for drawing art based on primitive shapes. And instead of me foisting a language upon […]

CS 330 Lecture 33 – State Machines

Dear students, Okay, pruning out the recursive calls that you’ve already done before is one way to tame recursion. Let’s look at another. We mentioned early that the piling up of stack frames is what gets recursion in trouble. Consider this definition of sum’ in Haskell: sum' [] = 0 sum' (first:rest) = first + […]

CS 330 Lecture 32 – Taming Recursion

Dear students, We’ve seen that Haskell does some pretty crazy things: it infers types, it supports this crazy pattern matching stuff, it disallows side effects, and it computes things lazily. Let’s look at one last crazy thing it does: it uses recursion for everything! There are no loop control structures. Normally, when you think of […]

1 2 3 30