Hacker News new | ask | show | jobs
by logicalmonster 1057 days ago
Functional Programming (FP) can be extremely elegant, and you should do your best to at least get familiar with it to see how using it can improve your code quality. There's a lot of theoretical reasons why this paradigm might be particularly great in a future where all devices seem to be adding lots of processing cores. For instance, without a function having side-effects, the potential for conflicts between threads or processes could be completely eliminated, so FP can potentially have some real-world benefits beyond just more elegant code.

That said, you should also think in terms of "What does JavaScript have that functional programming doesn't?". As a working-stiff programmer, most of the time the problems you're going to encounter are going to be a lot easier and faster to solve if mutating state is available as an option.

2 comments

Remember you can mix FP with other paradigms.

For example, feel free to use mutation if it's limited to the implementation of a small function. The function will still be effectively pure (to callers of the function).

Or when implementing "functional core, imperative shell," Gary Bernhardt says he tends to start with imperative code in the shell, then refactor it into the functional core[1].

[1]: https://hw.leftium.com/#/item/34866473

That's true, concurrency is becoming an important consideration and is probably why predictable and FP-oriented langs like Elixir, Rust, Clojure are having good growth.

As for mutating state, I come from an embedded software (microcontrollers) background haha and there's no option but to mutate state