News for hackers. Stuff that matters.
Re:Functorio by lmm on Wednesday February 17, 2021 @02:59AM (#26163854)
In my experience a codebase that crisscrosses back and forth between FP and mutation-based style ends up worse and buggier than one that commits fully to one or the other; it's not perfect being the enemy of better because it's not better.
Re:Functorio by rkangel on Wednesday February 17, 2021 @07:38AM (#26165686)
Criscrossing backwards and forwards would be bad, but the 'functional core, imperative shell' does work well. It is an excellent fit for Erlang/Elixir - you write a lot of pure functional logic (with the equivalently easy tests), and then you 'glue' it to the outside world with as little process machinery and statefulness as possible.

We are in Erlang though, so I wouldn't call it 'mutation' necessarily. The stateful bits are individual actors, creating a new internal state in response to messages.

Re:Functorio by m_mueller on Wednesday February 17, 2021 @03:15AM (#26163944)
I think it needs to be thought of as part of an overarching design - again, see Gary Bernhardt. A pure functional core that can be unit tested against, where the tricky logic happens. And a shell where you deal with dirty but dumb things like thread pools, logging, error handling, non-pure libraries etc. And then just be very diligent to separate concerns, i.e. don't put too many smart things into the shell.
Re:Functorio by lmm on Wednesday February 17, 2021 @10:31PM (#26175294)
> I think it needs to be thought of as part of an overarching design

Right. Which is very much opposed to your initial "FP is a tool, not a unified theory on how to model the world".

Re:Functorio by m_mueller on Thursday February 18, 2021 @02:06AM (#26176878)
I don’t think it is? I don’t see the contradiction. My point is FP, imperative and OOP can be combined effectively in one architecture.
Re:Functorio by lmm on Sunday February 21, 2021 @04:14AM (#26212063)
They can be, but you need to adopt a particular global perspective/worldview to make it work. Treating FP as just a tool in the toolbox that you can use ad-hoc anywhere in the codebase is not effective.
Re:Functorio by travv0 on Wednesday February 17, 2021 @09:43AM (#26166775)
"Functional core, imperative shell" is exactly what IO in the Haskell type system enforces.