Yoda wants you to be a functional programmer

Bring balance to the f#rce


This one is just for laughs but technical writing doesn't always have to be serious.
I was double checking a Yoda quote for my previous post and it got me thinking about how many Yoda quotes could be applied to the functional programming (FP) paradigm.
Star wars and programming are meant to go together.

“Size matters not. Look at me. Judge me by my size, do you? Hmm? Hmm. And well you should not.” – Yoda

Functional programming involves small building blocks of functions that you compose to make more specific functions and so on. The functions and the types tend to be small and stay small.

“Do. Or do not. There is no try.” – Yoda

Functions always return a value. No void here.

“Much to learn you still have…my old padawan. This is just the beginning!” – Yoda

FP is a new paradigm. Learning a new paradigm is way harder than learning a new language. It is a very useful tool to have in your toolbox though.

“Truly wonderful, the mind of a child is.” – Yoda

When learning FP, don't bring your object-oriented baggage. Embrace that this is something different.

“Always pass on what you have learned.” – Yoda

Another reference (pun intended wink wink) to functions in FP always returning something.

“Once you start down the dark path, forever will it dominate your destiny, consume you it will.” – Yoda

This one was tough. Do I use this to represent that once you grok a paradigm and see it's merits, you can't unlearn that. I think instead this should be a warning against letting yourself think any one paradigm is the best or only one that matters (I am looking at OOP).

“Mind what you have learned. Save you it can.” – Yoda

FP is a new paradigm and will make you a better developer.

“You will find only what you bring in.” – Yoda

In FP you don't usually store state. You pass along what you need in arguments.

“Attachment leads to jealously. The shadow of greed, that is.” – Yoda

I could make a point here about storing state but I think it is more important to reiterate the warning about the dark side of being too attached to just one paradigm. Find balance in the force.


So that's it for Yoda on functional programming. Hope it made you think and I hope it made you smile.

blog comments powered by Disqus