If you start coding as a kid, you can experience a lot of time where you're wrong about programming because you aren't ready to understand fundamental concepts. Especially if, like me, you learn how to code by yourself, you don't know any English yet, and personal computers are actually still called personal systems. But in an age of zero internet, I was still drawn by the possibility of building things with computers.
To make things with code, you naturally think in steps like cooking a recipe. I'm on step 5; now I just need to figure out step 6. Everything behind me is done, all I have to do is the rest. You give instructions to computers as if they were human. But calculators or artificial intelligence don't think like us, so neither should we limit our code to what feels more familiar or emotionally safe.
Functions grab a piece of your code, force you to give them a name and then you can only run that code if and when you call them out. As a kid, I would say that sounds like the worst thing ever. Today, I say yes, please.
And that's just the beginning. Much like their math counterparts, they can have inputs and outputs. In fact, that can be all that they do instead of unexpectedly be changing the world around them. Not to mention that a function can be passed into another function or returned from it. Functions can be composed with their little bits of responsibility mixing and matching as appropriate.
Delaying gratification with functions lets us add flexible layers to our code cake that strengthen each flavour, making it much easier to test what we can taste. We see chefs on television always screaming about keeping your station clean, but also about tasting continuously. Masters of the craft who have never heard of functional programming still know how a kitchen can scale with different people come together to make a stream of perfect dishes. That's different functions with clear boundaries knowing what they need and what they will deliver.
In software development, we can't predict all changes, but we can implement those changes more predictably. Functions allow us to tag and test what shouldn't change while something else in the code can change with confidence. We can couple flavours or switch them around so that our recipes can always adapt to fresh ingredients. Functions are an idea so simple that they can always be helpful, even in small doses. But they can keep surprising you with their usefulness if you let them cook.
About Ricardo Tavares
Creates things with computers to understand what problems they can solve. Passionate for an open web that everyone can contribute to. Works in domains where content is king and assumptions are validated quickly. Screaming at phone lines since before the internet.