15 ms·
Imho it's exactly the other way around: Imperative programming is an implementation detail and nothing you should care at first. If you want to learn proper ab
by still_grokking 3y ago
Imho it's exactly the other way around: Imperative programming is an implementation detail and nothing you should care at first.
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.
- Aerroon 3y ago>One just needs to follow up on what every child learns since first grade in school, namely the substitution model found in math. 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.
- nequo 3y agoCreating connections in the curriculum between math and other subjects is a good way to help students better understand both math and other subjects. I don’t have literature to cite on this though.
- still_grokking 3y ago> Considering how much people struggle with learning math I'm not sure that this is a good way of going about things. 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.
- Aerroon 3y ago>Objectively they have. I've linked already some evidence in the other reply in this thread. I don't see it. Maybe we (our class) were taught wrong, but back in uni I would rate the usefulness of our FP class as one of the worst. I got the sense that most of the students (that passed the class) weren't able to use what they studied in the class. If they took away anything from that class, it would be that they shouldn't touch Haskell again. FP is useful, but I would argue that imperative is easier to learn, because keeping track of state is easy when you're learning. You're dealing with small programs that you wrote yourself. Keeping their entire state in your mind is not difficult. Also, I think there's a joke somewhere in here about learning Java ruining the 'state' of your brain for learning FP.
- whateverman23 3y ago> FP is much simpler to learn, so much better suited for newcomers. 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.
- still_grokking 3y ago> Assignment is just one tiny piece of learning how to program, and is almost never a pain point after a small amount of instruction. 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-makes-imperative-programming-easier-or-harder-to-learn https://cseducators.stackexchange.com/questions/342/what-mak... https://stackoverflow.com/questions/778461/should-functional-programming-be-taught-before-imperative-programming 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.
- _a_a_a_ 3y agoYou claim a lot, you've backed up none of it. This doesn't come across like you're a professional programmer. > `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?
- still_grokking 3y agoNo, it wouldn't. And it's almost tragicomic to see how imperative programmers struggle to even see the actual real issue presented in this snippet.
- deleted 3y ago[deleted]
- _a_a_a_ 3y agoOK, how about x <- x + 1; (BTW be careful about assuming you're the brightest guy in the room, how others "struggle to even see" when you do, and with such clarity)
- still_grokking 3y agoTwo out of three replies were talking about the assignment even mutation is the (obvious!) real issue. > OK, how about > x <- x + 1; Better. From such syntax you can at least guess that mutation is happening there. Still nothing you would show a newcomer in a FP-programming introduction. (I'm not sure why your comment got down-voted. I can only up-vote it, so I did; to battle stupid down-votes because "feels"…)
- jltsiren 3y agoI've never understood this argument. 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.
- worrycue 3y ago> FP is much simpler to learn, so much better suited for newcomers 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.