3 ms·
> Imperative code is also more concise than equivalent functional code Functional code is almost always more concise than the equivalent imperative code. It's
by BoiledCabbage 7y ago
> Imperative code is also more concise than equivalent functional code
Functional code is almost always more concise than the equivalent imperative code. It's one of the main reasons why people prefer functional code. Almost everyone who looks at it pretty much agrees. The only cases where it will not be is if someone is directly re-writing an imperative algorithm into a functional language, then the functional can be longer. But for the most part, that's translating < 50 lines of code or something. Anything of substance functional is more concise.
If you haven't seen that to be the case, then you may not have looked at any substantial functional code.
Regardless of whether people prefer functional or not, that's almost a universal take-away from anyone re-writing an imperative project into a functional language. It's usually a factor of 2 or 3 shorter and simpler.
- hota_mazi 7y agoFirst of all, please stop making sweeping generalizations, "people prefer", "almost everyone", etc... Without proper citations, these claims are meaningless. Second, more concise doesn't always mean better, let alone more readable or more maintainable. It's often the opposite. Third, functional programming is usually preferred because of aspects such as composition or immutability, not conciseness. Fourth, rewrites of an existing code base usually leads to shorter code bases, simply because of the acquired knowledge, regardless of the language or the techniques.