5 ms·
Totally agree on the hardware implementation. Mutable state has two uses. First, when what you are modelling really has state the varies with time (e.g. real
by yetanotherphd 13y ago
Totally agree on the hardware implementation.
Mutable state has two uses. First, when what you are modelling really has state the varies with time (e.g. real world stuff, UI stuff). Second, as a kind of optimization.
One good reason for learning FP is that you think more clearly about what mutable state you are using and why.
For example, OOP programmers tend to instinctively write
obj.setX(x)
obj.doG()
y = obj.doF()
when it could be done as
y = F(G(x))
They instinctively cache G(x) in case they need it later, even though this never actually happens.
- fleitz 13y agoState rarely varies with time other than the wall clock, mostly in between time X and Y some events happened. With FP systems you generally have to model these things explicitly and attach a particular time to a particular state which makes the entire system much easier to reason about. Cached state really bothers me because invariably even after caching it, the state can't be reused because of the difficulty of reasoning about the whole system. I think in reality the appeal of FP is that the people who use it are generally more experienced programmers who tend not to make too much mess in non-FP languages anyway. The benefits are more the peer group than anything else.
- RyanZAG 13y ago> I think in reality the appeal of FP is that the people who use it are generally more experienced programmers who tend not to make too much mess in non-FP languages anyway. The benefits are more the peer group than anything else. Careful, you're arguing here that FP is better because the person using it is a better person. There is nothing wrong with that statement if it is actually an unbiased fact, but simply choosing to use or not use FP would automatically bias you towards declaring that true or false. Avoiding that line of reasoning is a good idea because it's not useful. Stick to the merits of FP itself.
- yetanotherphd 13y agoActually I think the poster is right, and I don't think we should avoid all lines of argument that might be subject to personal bias. The poster was saying that FP has a certain cachet (no pun intended) that is probably due to the quality of the average programmer. It's a bit like if someone was asked to explain higher salaries in Silicon Valley. Are we allowed to refer to the quality of programmers? Of course there is a risk of personal bias, but how could one have this discussion without referring to this factor?
- RyanZAG 13y agoYou'd have to bring in actual results: programmers in SV create great products that are widely used around the world. This could be used as evidence to imply they are better. FP is a bit tougher here - the vast majority of programs used by the general public are not FP. You could argue that FP is 'newer' and not had time to create these widely used programs yet - but FP is far from new. Basically there is no real world evidence to back up that FP programmers are higher skilled and only personal biases and assumptions.
- yetanotherphd 13y agoI find that a bit limiting, I would rather hear people's opinions even if they might be subject to bias. And I don't think that an opinion based on personal experience is "only personal biases and assumptions". It is also important that your approach be uniformly enforced: you would have to encourage people to refrain from saying that FP programmers have the same skill level as non-FP programmers, since that opinion is also not based on any evidence.
- wonderzombie 13y agoThis is kind of the dirty secret of any kind of programming, that it's very hard to make arguments that this or that technology leads to categorically better or different software. I mean, yes, there are specific domains, like trying to write webapps in C vs Ruby, but in general the programming languages well-suited for a task tend to be much, much more alike than different. We love to hate on PHP but it basically runs a non-trivial proportion of the web, incl Facebook. Python and Ruby look different but they're not so different that we can say, on average, a programmer is X times more productive using language Y instead of Z. That said I am kinda sorta sympathetic to the idea that people who veer off the beaten path of Java are self-selecting and may be open to more ideas, more adaptable, etc. But I'm leery of extending that to saying they're "better" in any measurable or definitive way. The one thing I would say re: FP being "newer" is that while the ideas aren't newer, it's "newer" in the sense that it's not as battle-tested as Java or C. Although, then again, when you see Ruby (a friendlier, no parens Lisp-alike), JS, higher-order functions in C++, list comprehensions in Python, and so on, it stops looking quite so much like FP is really all that foreign. People are already using a lot of it. So perhaps I should be more specific and say that while the concepts aren't new, the implementations are new to industry or production systems.
- someguyperson 13y ago> I think in reality the appeal of FP is that the people who use it are generally more experienced programmers I would wager that FP is used more in universities than in any other setting, and by underclassmen, not just graduate students. So I don't exactly think this is true.