DEV Community

Discussion on: How did you break the habit of writing procedural code?

Collapse
 
jesterxl profile image
Jesse Warden

It's easier if you're in a language that encourages functional thinking while being around developers who think that way too. I'm around Go and Python devs from a variety of backgrounds. The Go developers you'd think would be Functional minded, but they're basically "not OOP". The Python devs are either heavily procedural with an occasional OOP developer. Again, some of the younger devs or those not from a Java background just follow the procedural style because "it's easy, reads well, and it's obvious where the error is".

You teach them something like returns in Python, or suggest they try Rust for a code challenge, and they start embracing the "expression" mindset and start making their code more railway oriented. It's hard, though, because both Go and Python encourage the imperative flow. Even JavaScript with it's Promises does.

So it's hard, but easy to fallback into a language that allows it and is built for it. Harder still to deviate when you're on a team that does it. Even in JavaScript, though, if you're on a team that embraces it, it's much easier, like say a newer React team that's fully onboard with Hooks & Lodash/Folktale, etc.

... that said, I whip out let when coding Elm, so not sure 😅...