Beware of “functions are first class citizens” mantra.

Ohohohoh, sorry I keep laughing and can’t stop. Tonite I want to make fun of “functional programming” people. Let me state that clearly: they live in another world. Helloooo?! It’s 2010, the second half. Please don’t advocate anything for that. You would just waste your time. Beside I do know something about functional programming and its philosophy, I truly hate it! It’s just pointless and a straight way to spaghetti code (another funny topic I’ll start blogging about soon).

A few months ago I had to study a programming language that is a failure itself (besides it’s the best of them, probably the most modern one): OCaml. There is some coolness in it, but it’s still a functional programming language, so it really sucks nowadays, and don’t tell me the fairytale about automatic unit testing and crap like that, it’s just bullshit (sorry for being so rude).

So, why am I talking about all this? Simple, when I code using Python or C/C++, I take advantage of the fact that I can pass pointers to functions across functions themselves (as arguments). Well, every time I do that, I end up with an odd feeling: is my code readable? Is my code getting closer to spaghetti style? Unfortunately yes. Being able to pass functions across stack frames is cool and very handy at a first sight, but you’re going to pay the consequences in the long run, because your code will become harder to read and to maintain.

So please, use the mantra in subject with caution, in an event-driven model, passing callbacks over is good and generally accepted, any other use of it, in non-functional programming, is just very bad.

My today’s coding quality pill ends here. More will come about that. As you may have seen, I don’t want (for now) to get too much technical, I leave the exercise to you.


About lxnay

the creator of Sabayon Linux, Entropy Package Manager {Eit, Equo, Rigo}, Molecule release media buildsystem, Matter Portage buildbot/tinderbox and only God knows what else...

6 responses to “Beware of “functions are first class citizens” mantra.

  1. Not that Ruby doesn’t do the same just as well… which is why it’s so f*cking hard to read the Hobo code.


  2. Yep, functional language… despite the fact that many people think that JavaScript is an OOP language, it actually is a functional language, because object construction in the traditional way is always bound to functions which serve as constructors… and yes, JavaScript has no notion of classes as well, so your post correctly outlines this problem.

  3. Making fun of OCaml, eh? Sad to hear this, fellow.

    I fell in love in the strengths of OCaml the first time I compiled several example programs. Finally, I was able to write things like sudoku solver and some AI apps fast and without any stupid type bugs.

    And yes, I hate OCaml’s problems of no normal multi-threading support and lack of extensive libraries popular languages has. Syntax is also awful at times. User base is constantly decreasing and everybody admits that.

    But I still dream about those problems being fixed one day. These little languages like OCaml, Scala and many others are so much more powerful than your beloved Python and Java… At least in theory! Why didn’t you fall in love with OCaml, lxnay? It’s not the functional programming that matters. It’s the beauty of the language!

  4. HK

    Tautrimas, have you looked at Parallel Haskell at all?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

hello, twitter

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 583 other followers

%d bloggers like this: