315 points · by ggr2342 · 3y ago · 99 comments
I wrote the slides with the intention of them working as standalone notes, though, and as a kind of "textbook" for the course. So I think if you can follow along with the slides, you will get a fair amount of learning out of them, almost as much as attending the lectures.
Like BrownU's CS019 course using Pyret. It also teaches a functional approach to programming.
Also Berkeley's CS61A,B,C trilogy.
Do intro level courses matter in the long run? Or is it the higher level courses that set apart universities in undergrad CS education?
computer science doesn’t exist in a vacuum.
You won't learn anything if you don't practice it.
But "learning" computer related stuff without the theory behind is also kind of moot. You wouldn't get the full picture this way, and you would end up with a lot of "knowledge" that isn't more than assumptions. Likely wrong assumptions…
I guess not for everyone. Frankly.
I know quite some people who do programming for living but are more or less avert to any theory behind it. You get even called names if you come along with such topics… (I think it doesn't need to be said that it's quite difficult to deal with those people at times as they're kind of ignorant.)
for many, a task makes the long grind of study more fun.
a mission and all that.
it also add success criteria to an otherwise ambiguous task.
I do see your point though. In the algebra class, I couldn't grok groups from the axioms, without first seeing some concrete examples. But the thing is, math people's "concrete" is already several layers of abstractions removed from reality.
Even trying to get past 2 swipes in nearly drove me insane.
If you want to learn proper abstractions you should start with something FP-ish.
This also avoids to get your head messed up with the imperative kind of "reasoning".
Besides this: FP is much simpler to learn, so much better suited for newcomers. One just needs to follow up on what every child learns since first grade in school, namely the substitution model found in math. On the other hand imperative thinking makes absolutely no sense when looked at it intuitively. It looks more like complete nonsense: `x = x + 1` isn't true for any `x`… So imperative programming is at it's core contrary to logical reasoning. I would try to avoid it as long as possible.
I can't see how this is the case. Assignment is just one tiny piece of learning how to program, and is almost never a pain point after a small amount of instruction.
Imperative programming is easier to learn because you simply write out the steps that you want the computer to take, and the computer takes them. FP requires much much more abstract thinking that is often difficult for newcomers to grasp.
The main exception that I see is when someone who has a very deep mathematics education. Graduate level math folks seem to more easily grasp FP concepts from my experience. Almost everyone else seems to grasp imperative programming easier.
All functional programing languages, have ergonomics in their syntax and semantics. around referential transparency and immutable data structures, there's nothing in there about Monads or Functors or Hindley–Milner type systems.
Languages like Haskell do benefit from having that kind of experience, however, langs like, OCaml, Erlang, Elixir, Gleam, Racket, Clojure, Standard ML.... and the list goes on, doesn't require that kind of education.
(Antidotally, I find FP langs much easier to reason about and I have a background in the humanities. I just don't buy the advanced math argument.)
The issue isn't assignment. You have also assignment even in the most pure FP languages.
The issue is mutation!
> Imperative programming is easier to learn because you simply write out the steps that you want the computer to take, and the computer takes them.
No, that's not easy given every step can change the whole world around and you need to track all the changes in your head.
That becomes very hard to follow even after only a few steps. (That's why imperative programs are always so buggy.)
FP code, which usually eschews mutation, is much simpler to follow as you can look at any "step" in isolation. No hidden "change the world" side-effects everywhere.
> FP requires much much more abstract thinking that is often difficult for newcomers to grasp.
No it doesn't. At least as long as you don't go nuts like e. g. Haskell.
At the core FP is basically the same trivial concept taught to children in elementary school: If you have some expression you can mechanically substitute following occurrences which the value assigned to that expression. That's all.
> The main exception that I see is when someone who has a very deep mathematics education.
Like every child that attended math classes for many years. In school people are trained for a very long time in exactly the way of reasoning you need to write FP code.
On the other hand you need to teach those people imperative programming form the ground up, including mayor mental shifts around all kinds of concepts they were taught previously. Only after this kind of brainwashing people start "to get" imperative programing…
> Almost everyone else seems to grasp imperative programming easier.
No. Quite the opposite.
https://cseducators.stackexchange.com/questions/342/what-mak...
https://stackoverflow.com/questions/778461/should-functional...
Just go out and talk to some programming instructors… Everybody will tell you the same.
Only people whos brains are already burned by imperative programming think it's easier. For everybody else it's the opposite. Which is perfectly logical as the FP way of thinking is what they practiced for many many years before, in math in school.
The way I see it, I live in a world that has state. I spend all my waking hours manipulating the state around me. From this perspective, imperative programming is as natural and intuitive as anything can be. You do things, and the world changes.
Abstractions are good, but you should first understand the concrete ideas behind them. Otherwise you may end up doing pure symbolic manipulation without any intuition to guide you.
> `x = x + 1` isn't true for any `x`
Out of interest, if this had been written x := x + 1 as in the style of Pascal, would that make imperative programming more logical?
And it's almost tragicomic to see how imperative programmers struggle to even see the actual real issue presented in this snippet.
Considering how much people struggle with learning math I'm not sure that this is a good way of going about things. I don't think functional programming classes have much more success either.
Even more are struggling with programming, no matter the paradigm…
> I don't think functional programming classes have much more success either.
Objectively they have. I've linked already some evidence in the other reply in this thread.
I'm going to have to disagree with you like most other replies.
You need basic math knowledge to do FP - at least know what a function is.
Imperative programming is just writing out a list of instructions for the computer to follow and everyone understands the concept of write out a list of instructions. No math needed.
If by FP we mean "Let's write our functions as pure (and leave IO as a magic box for time being)", then this is undeniably more straightforward then getting head deep into side effects that procedures can create, not to mention the entangled web of dependencies in OOP, and other messy stuff it promotes
There's some courses that are inarguably fundamental, some which "separate the good from the bad," but there's also many which are simply not practical, besides the fact that they teach you how to learn.
It's a flawed analogy but I'd liken it to mechanics vs automotive/manufacturing engineers. There's a good bit of overlap, but lots that isn't shared. And software engineering as an industry doesn't always do a good job differentiating between the two
It feels like the dominant style of programming in the companies I've worked at (YC startups and FAANG) is "functionalish" procedural, with a sprinkling of objects-qua-objects to interface with libraries and frameworks (Eg, react class components or rails ActiveRecord models).
Note I'm distinguishing between objects-qua-objects (data coupled tightly to methods that operate on them) from structs-implemented-via-objects (eg, ruby's `Struct` or Java "beans") or modules-implemented-via-objects (like a class with a bunch of static methods used as a namespace). I only see the first one as "object-oriented".
Trying to change career tracks
Could you describe a bit more about what you're looking for when you say "traditional CompSci?"