6 ms·
Like the article said, "functional programming" doesn't mean using maps and folds. Functional programming is meant to make you reason about state by always hand
by steinuil 9y ago
Like the article said, "functional programming" doesn't mean using maps and folds. Functional programming is meant to make you reason about state by always handling it very explicitly e.g. by using functions that take a state and produce a new one, so that your program is constructed by piping the result of a function into another's input, instead of implicitly.
- gaius 9y agoThat would appear to be a definition of functional programming that says nothing about functions themselves, which seems odd. Because you can't make any guarantees about state in a language that wasn't intended for FP because how do you know what side effects the built-in functions are having?
- steinuil 9y agoWell, clearly in a language that doesn't make a distinction between functions that have side effects and functions that don't you'll just have to pinky swear you won't put any in your functions, and maybe try to wrap the side effects the built-in functions do have (like errno in C) with your own functions. But that's not the point; a functional style can be achieved in any language as long as it has functions.
- crimsonalucard 9y agoYou can't even make that guarantee for functional languages. How do I know the built in operators for scala aren't producing side effects without reading the code of the compiler itself? Additionally you should know that functional programming is a lie. Your computer is an imperative machine with no understanding of functional programming. The compiler transforms your functional program into an imperative one.
- gaius 9y agoAdditionally you should know that functional programming is a lie. Your computer is an imperative machine with no understanding of functional programming Yet you program a register machine as if it were a stack machine all the time without batting an eyelid!
- crimsonalucard 9y ago>Because you can't make any guarantees about state in a language that wasn't intended for FP because how do you know what side effects the built-in functions are having This is your original argument. I said that FP programs offer none of the said guarantees because they are at it's core compiled into imperative programs... You responded with a statement about a stack machine being an abstraction over a "register machine." How does the stack machine statement move your original argument forward...? We're getting side tracked here...
- hiptobecubic 9y agoYou don't. It's entirely possible to write not-at-all-functional code in Scala. One of the many reasons I dislike it.
- crimsonalucard 9y agoah never knew that. My mistake. I just chose a random "functional" language as an example.