4 ms·
I get the impression from the article the author may have meant declarative instead of functional programming. FP can be fully imperative. I often see developer
by austin-cheney 1y ago
I get the impression from the article the author may have meant declarative instead of functional programming. FP can be fully imperative. I often see developers interchange these terms improperly because there is some implicit narrow context that’s out of scope to the broader nature of the terms.
- zelphirkalt 1y agoCan you give an example for imperative yet functional? Do you mean something like within a function using lots of assignment and such, but keeping the function pure to the outside?
- austin-cheney 1y agoRed Language claims to be functional imperative. In my case I prefer to use functions as much as possible for structure and organization in TypeScript, because functions are portable and provide scope. The functions are mostly void functions that don’t return a value, such as event handlers. I completely detest OOP and inheritance.
- troupo 1y agoErlang and Elixir. They are fictional, but don't care if you do impressive IO or any other side effect in the middle of a function.
- troupo 1y agoJut re-read my reply. iOS keyboard is just so hilariously bad. "they are fictional", "impressive IO". Here's the corrected version: Erlang and Elixir. They are functional, but don't care if you do IO or any other side effect in the middle of a function.
- zelphirkalt 1y agoTo be honest, I don't think that this strictly meets the criteria of FP, but there is nothing wrong with that. I myself often use a Scheme dialect, which also allows you to do mutation and side-effects all day long. But what I do is to put that stuff into a thin layer that is around the functional core of the code, so that the core logic is not affected by the procedural/imperative parts. It is not 100% functional (and can't be), but it is practical and reaps most of the benefits of FP, except for that very thin layer that does some input and output. I am not trying to down-talk Elixir or Erlang here. Both are great languages. That said, I wouldn't call this approach "imperative but functional". I would rather say functional core and thin imperative/procedural outer layer. Similar response to the sibling comment. And considering this, I still see functional and imperative at odds. But this is merely a difference in terminology, not in practice and how we solve problems.
- troupo 1y ago> That said, I wouldn't call this approach "imperative but functional". I would rather say functional core and thin imperative/procedural outer layer. I call such languages "pragmatic programming languages" :) They don't care about theoretical pureness, they want to get stuff done. And often that stuff is thing like "stick logging into the middle of a function" or "fire off an event to an external system".