Post

I used to live and die by functional code in TypeScript. I'd avoid mutating a let like the plague, would use maps and filters for everything. But I have really started to like the simplicity of loops and imperative code. 😅 It reads so well. It feels human.

I like to contain the imperative code with functions. So state doesn't leak. Functions are small, start with a bit of state, then return a value. I think what I find works is I make the building blocks of my app more imperative, then composing those imperative pieces in a more declarative way.

I think the biggest reason why I have grown to go back to more imperative-like code is because TS I feel fights me more on the functional side compared to other languages. Maybe if they added some extra functional utilities/syntax I might sway my opinion again??

0 reposts1 like

No replies yet.