Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The universe is stateful; no matter how hard FP zealots try to abstract that out of code, they will never change this fundamental fact.


FP does not do that.

First of all, there is stateful code and then there is effectful code. It sounds like you are talking about the second, not the first. You can have tons of state and remain mathematically pure.

Where people get hung up is effectful code, or mutable state. Even one of the more hardcore FP languages, Haskell, does not try to abstract that out. Instead it embraces it fully by giving constructs in the language to describe and control effects! This is far more powerful than straight up imperative languages. If anything, writing mutable, effectful code is more powerful in Haskell than in C/C++.

Where Haskell gets difficult is when writing effectful code that interacts with external C libraries and the OS. But this has nothing to do with purity, state, or effects. It really only has to do with the fact that it is designed to have lazy evaluation by default. Which itself has a lot of advantages, but it makes this interaction more difficult as code does not execute in the same order as you write it.

You may find that languages such as OCaml, which are fully functional and have strict evaluation are a joy to work with.


Nonsense. These are all just techniques for modeling reality, not reality itself.

You could model the universe just as accurately as a stateless function of time as you could as a stateful entity that moves through time.


The further you get from the true representation of the thing you’re trying to model, the more difficult reasoning about it becomes. I’m all for abstractions that result in a net positive... I simply believe that FP is less about improving computing and more about ego.


The universe is also highly concurrent and probabilistic, but that doesn't mean we need to design our programming languages that way.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: