The Knights of Functional Programming fight the Imperative Dragon.

It was The Knights Of Functional Programming.

There they were.

Three of them.

Mounted on gorgeous white stallions wearing shining platinum armour.

But which would face the Imperative Dragon?The Knight of declarative programming stepped forward.

When the imperative dragon saw it realised it needed to strengthen its own attacks.

As the dragon was imperative it used a for loop like so:The Declarative Knight saw what the dragon was doing so decided to power up his own attacks.

The people of lambda village we’re in awe.

The dragons solution described how he was powering up his attacks.

As a result, it wasn’t easy to understand at a glance.

but the Knights method described what he was doing, Mapping the attack array to a new one with double the power.

Yes, the knight and dragon were using JavaScript but most languages have similar concepts.

in Java, you have the Guava library.

C# has the .

select().

C++ has std::transformMost functional languages like Clojure and Haskell use map.

Stunned by this, the dragon decided to try a new tactic.

What he would do is only use his most powerful attacks.

He needed to filter his attack list to select only his strongest attacks.

But unfortunately for the dragon, the Declarative Programming Knight had a solution to do the same thing.

The dragon was so shocked by the declarative knight's response, that he decided to make one more effort to power up his attack, the dragon fused all his attacks into one like so:But the Kight had a better way:When all was said and done the dragon was in awe the knight but wasn't ready to give up.

But the dragon realised that there weren’t many points of contention left.

For example, the dragon knew that an imperative style dominated the UI space.

take HTML as an example:See how HTML simply describes what you want on the screen.

It gives you no intel on how to render a <p> or a <div>.

The dragon considered searching its inner store for more attacks.

ut even still it had no options consider SQL and MongoSee how both describe what data you want: ‘select this from here’ or ‘find what matches this criteria’ rather than the process of opening the file and reading the data.

At that point, the dragon realised the game was up.

He had been defeated by the imperative style.

He knew of course that the battle would go on.

There are more dragons of the object-oriented and procedural styles.

There are also more knights of functional programming.

So the dragon reserved his strength and flew away.

Ada couldn’t believe her eyes!.Lambda village was safe.

It was all because of the declarative style used in functional programming.

She sat down and made herself a cup of tea.

And they all lived happily ever after.

.

. More details

Leave a Reply