4 ms·
I think you're confusing things. (Pure) functional programming is a form of declarative programming. The most important feature of declarative programming is th
by taffer 8y ago
I think you're confusing things. (Pure) functional programming is a form of declarative programming. The most important feature of declarative programming is the elimination of side effects and the idea of referential transparency. It has nothing to do with OOP.
- austincheney 8y ago> I think you're confusing things. (Pure) functional programming is a form of declarative programming. I disagree. See https://www.red-lang.org/p/about.html https://www.red-lang.org/p/about.html as an example of a language that is purely imperative functional.
- taffer 8y agoImperative and functional are opposites. There is no such thing as a purely functional imperative language.
- austincheney 8y agoI provided you established evidence to the contrary.
- convolvatron 8y agoimperative programming is control flow centric. do this, do that, do this other ten times. functional programming is about referential transparency - the value of an expression is determined entirely by its arguments and not some hidden state. so you certainly can have imperative functional programming which is both recipe-like and referentally transparent. declarative programming is the antipode of imperative programming. yes, its referentally transparent, but it also attempts to describe the nature of the solution, rather than the (imperative) process to get there. i dont know that there is a declarative variant that makes sense without transparency...because if there is hidden state and we have no handle on order of evaluation, its kind of a lost cause.
- madhadron 8y agoThe usual definitions of imperative vs functional are that imperative is built from Hoare triples and functional is built from lambda calculus. By those definitions, you cannot have a functional, imperative language.
- austincheney 8y agoWhen used properly the nested scope provided by lambda calculus allows shared variables accessible from outside a local function thereby accounting for the precondition of Hoare's triples without it being locally present or passed in. This is enough to satisfy both the functional nature of portablity/isolation and the imperative model by Hoare's logic. * https://en.wikipedia.org/wiki/Hoare_logic https://en.wikipedia.org/wiki/Hoare_logic * https://en.wikipedia.org/wiki/Imperative_programming https://en.wikipedia.org/wiki/Imperative_programming * https://en.wikipedia.org/wiki/Scope_(computer_science)#Lexical_scoping https://en.wikipedia.org/wiki/Scope_(computer_science)#Lexic...
- madhadron 8y ago> When used properly the nested scope provided by lambda calculus allows shared variables accessible from outside a local function thereby accounting for the precondition of Hoare's triples without it being locally present or passed in. Yes, you can express any Turing complete system in terms of any other Turing complete system. > This is enough to satisfy both the functional nature of portablity/isolation and the imperative model by Hoare's logic. I think you're missing the point. It's not about portability or isolation. It's about the mathematical system you use as the foundation of your semantics. Yes, you can implement a lambda calculus in turns of Hoare triples and you can implement Hoare triples in terms of lambda calculus. Or in terms of unification over Horn clauses or combinatory logic. What makes a language functional is that its semantics are defined as an extension of the lambda calculus. What makes a language logical is that its semantics are defined as an extension of unification over Horn clauses. All the benefits people suggest to using one style or another are theorems, not definitions.