News for hackers. Stuff that matters.
Re:Why is learning functional programming so damned hard? (2... by bsder on Sunday August 15, 2021 @05:55PM (#28192904)
> FP is absolutely way more time-efficient for most kinds of projects

I absolutely do not agree.

FP binds your particular choice of implementation to the code architecture. FP actually makes refactoring in the small trivial and refactoring in the large ferociously difficult.

A good example would be a program that runs fine suddenly now needs a "timeout" on an operation. FP implementations now need to thread the notion of time from somewhere near the top of the implementation the whole way down the chain to the function that needs "time".

This is painful.

An imperative programmer throws in a global time variable, possibly a local timeout variable and gets on with life.

Now, if I'm trying to manage a high-complexity codebase, I will probably eat the FP penalty. Having complete determinism, decoupling, and visibility in, say, a network stack makes debugging possible that will be very difficult with sorta-state smeared across a bunch of variables at various level of hierarchy.

However, I accept and acknowledge that I am making a tradeoff.

Re:Why is learning functional programming so damned hard? (2... by lmm on Sunday August 15, 2021 @09:51PM (#28194230)
> An imperative programmer throws in a global time variable, possibly a local timeout variable and gets on with life.

Which actually destroys the ability to refactor in the large. You have no idea what might use that global time variable from where or why. Choosing to use FP is choosing to ban yourself from taking on that kind of tech debt (although we should note that most FP languages have an "escape hatch" if you need it - even in Haskell you can always unsafePerformIO). There are definitely times where you want to do that, but I don't think it's right to frame that as the non-functional language making things easier to refactor in the large - rather the non-functional language makes it easier to not refactor in the large because you don't fully decouple things in the large in the first place.

Re:Why is learning functional programming so damned hard? (2... by dnautics on Sunday August 15, 2021 @09:09PM (#28193994)
> FP actually makes refactoring in the small trivial and refactoring in the large ferociously difficult

This is not at all my experience, in fact I'd say I encountered the opposite. Large scale refactoring in C++ and python were nightmarish and are a breeze in Julia and Elixir.

Re:Why is learning functional programming so damned hard? (2... by m_arnold on Monday August 16, 2021 @12:55PM (#28200208)
>A good example would be a program that runs fine suddenly now needs a "timeout" on an operation. FP implementations now need to thread the notion of time from somewhere near the top of the implementation the whole way down the chain to the function that needs "time".

A sufficiently complicated FP codebase almost certainly has some form of effects management in place (monad transformers or algebraic effects, for instance), so adding a timeout is as simple as adding the effect to the type signature at the top level and then letting the compiler tell you all the places you need to wire it up. I've done this in many codebases. It's actually a dream, as the type system won't allow you to make a mistake.

Re:Why is learning functional programming so damned hard? (2... by yawaramin on Sunday August 15, 2021 @09:06PM (#28193982)
> A good example would be a program that runs fine suddenly now needs a "timeout" on an operation. FP implementations now need to thread the notion of time from somewhere near the top of the implementation the whole way down the chain to the function that needs "time".

I mean, 'FP' is so broad a term that a lot of languages fall under that, almost all of which can introduce the concept of a timeout quite easily. E.g. OCaml's Lwt, or Scala's ZIO are two that quickly come to mind.