3 ms·
Well, it's not like you have to mutate the state or program with side-effects just because you have some classes... once someone starts grasping on OOP principl
by ivanhoe 7y ago
Well, it's not like you have to mutate the state or program with side-effects just because you have some classes... once someone starts grasping on OOP principles, you can teach them the best practices, what to avoid, etc. That said, I definitely think that FP is the right way to go, I'm personally moving in that direction, but I think people should first get their feet wet with OOP, as it's easier to learn, and there's a lot of common knowledge between the two. Once you learn OOP and start to feel the problems and limitations, transition to FP will make more sense IMHO. It will not be just because some dudes on Internet said it's cooler, but you can spot the benefits yourself.
- kerkeslager 7y ago> Well, it's not like you have to mutate the state or program with side-effects just because you have some classes... That's true, as I said in the post you're responding to. But as I also said in the post you're responding to, then your claim "OOP is easier to grasp as it's closer to how we usually think of the world" ceases to be true: when you give one of your employees a raise, do you replace them with another employee who is identical except for their salary? Obviously not, but that's how you'd give someone a raise if `Employee` is a class of immutable objects. You get to have one or the other: 1. Either OO is similar to how we think of the world and you're writing bad OO code that's got mutation all over the place, 2. OR OO isn't similar to how we think of the world, but you've got immutable objects that play nicely with concurrency. You can't have both. > I think people should first get their feet wet with OOP, as it's easier to learn, "OOP is easier to learn" is a claim I hear a lot, but I've yet to see any evidence that this is the case. Most people's evidence seems to be, "The way I learned it is the easiest." Given that most people start with OOP, it's unsurprising that many people think OOP is easier. There's also more learning materials available for OOP. But if you had completely untrained people learning programming for the first time with equal quality learning materials and instruction, I don't know which group would make progress more quickly, and I don't think anyone does know. In any case, if the ease of learning OOP comes from being able to start with bad habits (i.e. mutation) that allow you to write code the way you think of the world, I question whether this is actually a good thing. > and there's a lot of common knowledge between the two. This I totally agree with you on.