15-150: Principles of Functional Programming

by brandonsparkon 11/20/23, 5:34 PMwith 126 comments
by jstriebon 11/20/23, 11:32 PM

I loved 150 when I took it, and program in SML from time to time to this day.

Bob Harper (a CMU professor with a focus on PL theory) also has a really good SML reference that is closer to a textbook than lecture notes.

http://www.cs.cmu.edu/~rwh/isml/book.pdf

by aromanon 11/20/23, 8:09 PM

150 was one of my favorite courses at CMU; each homework really made me feel like I unlocked a new level of reasoning with code.

by vermilinguaon 11/20/23, 9:05 PM

Content aside, what gorgeous slides. I wish any of my lecturers had the same eye for presentation.

by frankbreetzon 11/20/23, 7:10 PM

Does this include exercises? I didn't see any and I always find that the most useful part of learning.

by ajbt200128on 11/20/23, 7:08 PM

Of note, CMU produces a bunch of functional programming research, including a whole homotopy type theory department, so this is a quality source.

by low_tech_punkon 11/20/23, 8:12 PM

God send!! The FP learning resource is quite sparse on the internet. I’ve been looking for structured material like this for a while.

by valenterryon 11/21/23, 7:58 AM

No word on where the concept originally comes from? (in the text/description)

Should have at least differentiated between "functional programming" and "pure functional programming" IMHO.

by andrewlon 11/20/23, 7:05 PM

This looks valuable. And it is from the summer of 2023, so quite current.

by agomez314on 11/20/23, 7:14 PM

Great resource! Forgive my ignorance but why do so many modern functional programming courses use Standard ML instead of a Lisp dialect? Is it because of its built-in type-checking, or is it just how it's always been taught?

by endgameon 11/22/23, 11:19 AM

The lecture on CPS made things "click" for me in a way that they hadn't before. Thank you.

by hohohmmon 11/21/23, 2:02 AM

Use to be called 15-212. TA-ed it for 1 semester. That's when I really understood programming.

by esafakon 11/20/23, 11:41 PM

Pretty good for a new grad!

by gsuuonon 11/20/23, 10:57 PM

This looks cool! Just a note, it looks like the youtube playlist is in reverse order: https://www.youtube.com/watch?v=DSGXB9G5dxk&list=PLsydD1kw8j...

by PennRoboticson 11/20/23, 7:02 PM

Standard ML (sml / smlnj)

The instructor is clear, energetic, has a decent flow in the first lecture e.g. emphasizes the important points with vigor and repetition, switches media every 10 or 15 minutes, has a conversation with students. Slides are relatively noise-free and are informative; terms to know are highlighted.

I haven't watched a full functional programming lecture series yet, but I'd gladly audit this one.

As a "new" instructor (as in, not a TA anymore) he's got a bit of teaching talent. I hope he keeps a tight feedback loop and improves every year and continues publishing material.

by systemson 11/20/23, 7:19 PM

on the choice of language to teach the course why sml

i think there are a lot of nicer choice

   OCaml , its basically sml only more popular and used more in real life
   Haskell , again more popular , and used more in real life 
   Idris , newer and said to be more progressive 
   F# , a more practical choice and similar to sml 
   a lisp , well if you want to focus on the functional part and less on the types part

by imslavkoon 11/20/23, 7:45 PM

Slightly off-topic but what's a good forum to seek help on FP practices outside of the courses like this online?

Every winter break I get back into trying to learn more FP (in Haskell) and in the past several years I have been practicing algo problems (codeforces, advent of code, leetcode).

I always get stuck on more advanced graph algorithms where you traverse a and modify a graph, not a tree structure - it gets particularly tricky to work on circular data structures (I learned about "tying the knot" but it's incredibly challenging for me) and usually the runtime perf is sub-par both asymptotically and empirically.

by c-c-c-c-con 11/20/23, 7:11 PM

Wow, he went from taking his bachelor to lecturing.

I always dreamt of that when going through my degree and encountering courses that needed a thorough rework.

by freedombenon 11/20/23, 7:00 PM

I do wish functional programming were more taught. we're getting to a point where I almost think OOP should be taught briefly and the rest of the focus on C/C++ for low level stuff (OS, data structures, some algorithms), and something functional or pseudo-functional for high level stuff. Most of the newer codebases in startups now require functional concepts to understand what's happening. For example, try writing modern JS without understanding .map, .reduce, et al, and function passing, etc.

Regardless I think it's important that students get exposed to more than just Python, which seems to increasingly be the only thing students come out knowing.

by frozenlettuceon 11/20/23, 7:39 PM

My complaint with FP: Sometimes I just want to do something silly, like adding a log somewhere. If I choose to add said side effect, now all my functions are marked with an io signature (so there might be _other_, nastier side effects hiding there as well - mainly an issue if you have multiple people contributing to the same project). If I don't add the side effect, and choose to refactor multiple layers of code, I will need to make all my functions return multiple values and later fold over all the accumulated strings and... life is too short for that. The principles really resonate with me, but maybe we are limited by the current tooling, because the development experience is quite clunky in its current stage.

by airstrikeon 11/20/23, 8:25 PM

Hey Brandon, thanks for posting this. Off-topic but maybe consider serving up thumbnails on that page instead of the full-size pngs https://brandonspark.github.io/prologue/lecture01.png

by Koshkinon 11/20/23, 8:25 PM

It seems that the fundamental problem with the functional paradigm (in its pure form) is that the real world - including the architecture of the computer that is used to run the programs on - is full of side effects, i.e. is essentially "imperative," and with this impedance between them the idea creates more problems than it solves.

by zubairqon 11/20/23, 7:53 PM

Watching it now

by narinxason 11/20/23, 7:12 PM

just in time for nobody to really care about programming because LLMs are so good at translation and all computer code and programing are a subfield of linguistics...