DEV Community

Pan Chasinga
Pan Chasinga

Posted on

Functional Languages are Fad

I don't understand the functional language fad. As much as those liberal nerds despise the term IT, it is my career as much as it is theirs. And in IT, you only use what works. Programming for fun? With passion? I have to put food on the table! I never get those who keep writing code in weird theoretical languages after work.

Let me put it in terms of code, because that's how we will understand the uselessness of learning a functional language.

Functional languages are concise

And that's the problem. In the IT world, especially with contractors, we get paid by the number of lines of code we deliver. Look at this beautiful code written in Java, my favorite language:


public static class SumOfSquaresHelper
{
   public static int Square(int i)
   {
      return i * i;
   }

   public static int SumOfSquares(int n)
   {
      int sum = 0;
      for (int i = 1; i <= n; i++)
      {
         sum += Square(i);
      }
      return sum;
   }
}

Enter fullscreen mode Exit fullscreen mode

That counts 16 lines of code. With a couple more classes and that's a payday. Here is the equivalent in F#, a .NET's own functional spinoff of one of the most hideous languages of all time, Ocaml (Frankly, Microsoft inventing this language to replace C# is downright disappointing):


let square x = x * x
let sumOfSquares n = [1..n] |> List.map square |> List.sum

Enter fullscreen mode Exit fullscreen mode

Holy moly! Two lines of code to do the same? How do you expect people like us to get paid, let alone anyone reading the code? You can even go further and make that a one liner with, ugh, lambda.


let sumOfSquares n = [1..n] |> List.map (fun x -> x * x) |> List.sum

Enter fullscreen mode Exit fullscreen mode

What abomination! What's worse is that language designers these days tend to get brainwashed by this functional cult and can't help hacking some functional features into their language. Even Javascript, which has been around since the birth of the internet, wants to be functional.


let sumOfSquares = n => [...Array(n).keys()].map(x => x * x).reduce((x, y) => x + y);

Enter fullscreen mode Exit fullscreen mode

Indeed, these are dark days to be a legit, serious programmer.

Inspired by Ten reasons not to use a statically typed functional programming language.

Oldest comments (31)

Collapse
 
joelnet profile image
JavaScript Joel

Hearts

Collapse
 
rhymes profile image
rhymes

LOL

Collapse
 
silvercore profile image
Silver-Core • Edited

I typed out a whole essay about how FP is relatively concise before I realized that this was a joke :p
Some people genuinely think like this though.

Collapse
 
eljayadobe profile image
Eljay-Adobe

With such concise code, where do you hide all the bugs?

Everyone knows the big consulting money is in maintenance of the monstrous monolithic shibboleths. Loquacious, garrulous verbosity is the cornerstone of How To Write Unmaintainable Code.

Collapse
 
pancy profile image
Pan Chasinga

Thanks for sharing. I like your first line. I feel the same. With a functional language, you either run it right (most of the time) or not. It's harder to run with bugs or copy paste solutions.

Collapse
 
eljayadobe profile image
Eljay-Adobe

I'm a fan of F#, and really enjoyed the tutorial The Book of F# by Dave Fancher. Did all my learning using Mono and Xamarin, on a Mac.

Fancher's book was much better than the other F# books I've read. I've not read Don Syme's Expert F# 4.0 book yet — reviews seem split between good and bad.

Thread Thread
 
pancy profile image
Pan Chasinga

Thanks a lot for the lead. I've been very interested in learning more about F#.

Collapse
 
igorganapolsky profile image
Igor Ganapolsky

It is interesting that you bring up this topic, Joe. I am an Android engineer, and am seeing a proliferation of functional-style programming with RxJava and Kotlin, etc. I think these technologies are great, but sometimes they complicate a project and slow down developers with steep learning curves.

Collapse
 
pancy profile image
Pan Chasinga

It's meant to be a satire, but thanks for pointing it out. I agree with you to a point.

Collapse
 
jhbertra profile image
Jamie Bertram

You almost had me

Collapse
 
pancy profile image
Pan Chasinga

But really, these are mindsets I've heard.

Collapse
 
pancy profile image
Pan Chasinga

Hehe, I managed to summon all the functional crowd here!

Collapse
 
pancy profile image
Pan Chasinga

It's just for the sake of satire. :D

Collapse
 
euler2718 profile image
John Corley

Lines of code? Good Lord.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.