Fork me on GitHub

Sunday, July 19, 2015

Functional languages and why I'm obsessed.


I have to admit that I am obsessed with functional languages. It all started when I came across Dyalog APL (short for 'A programming language') after which I decided to take a functional languages module at school where I've learnt Haskell and Scheme, I'm even considering branching to more esoteric languages like j, k and f#.
What are functional languages?As the name suggests, in a nutshell, functional languages are languages which functions are sort of first hand citizens. Everything else from numbers to strings stem from functions and functions can even take functions as arguments and return functions. They have all these cool features not found in traditional languages like Java. or C#. Functional languages are fundamentally different.

They have different syntax ; no the right word is weird.
This right here is meaningful APL code.
And that  is Haskell code.


They are incredibly faster than traditional languages. Fast in terms of both development an run time. The APL code below for example for instance produces a nicely formatted Pascal's triangle in  less than half a second.



Compare to what you would write in Java and how long it would take.  Read here about how development time was significantly reduced with Lisp.

Functional languages also introduce you to new paradigms of thinking. In pure functional languages loops are not allowed because it implies a change of state. Unlike, traditional languages,  you are forced to rethink solutions to recursion or array programming. This way of thinking definitely boosts your problem solving skills.


Functional languages are known for solving complex mathematical problems but are also closer to home than we think.  Daily examples include Excel formulas, SQL and Java Script . Traditional languages have lately started to support functional languages paradigm including C, Python, C++ and C# . If you have ever come across lambdas and higher order functions like map , filter and reduce then you have applied functional programming.   Functional languages are also inherently concurrent something that is crucial to real world applications. There is no doubt that functional programming is now getting the spotlight.

Despite being unpopular the developer's community is absorbing more and more of functional programming into popular languages. Even though we purely functional languages will not be the norm anytime soon, we'll definitely more of it around, and perhaps we might not be able to escape it.

No comments:

Post a Comment