Live data from Hacker News

“Mostly functional” programming does not work

queue.acm.org

11–20 of 58 posts

Re: “Mostly functional” programming does not work

#11
post #5

To play devil's advocate for a minute: Nearly all useful, reusable software today is written in a mostly or entirely imperative language. This is despite the fact that functional programming has been around for at least 20-30 years. So, my basic question is, if functional programming is so much better, why isn't more software written in a functional language? Or put another way, why are there so many blog posts promo…

That's a red herring: You're asking why the majority of software is written in imperative languages instead of functional ones, which is a very complex question with very many factors. It is not an argument which invalidates nor counters the author's claim: Namely that "mostly functional languages" is unfeasible and only increases the bugs caused by side effects.

Re: “Mostly functional” programming does not work

#12
OK, this points out a couple of things that "do not work" in these sorts of situations:

- lazy evaluation with side effects - replacement optimisations based off of referential transparency when there are side effects - general side-effectiness

This is basically saying that functional programming doesn't work when it isn't functional... but we can still have functional "chunks", and monads _are_ an effect system.

I don't really understanding what he's trying to prove, of course purely functional semantics fall apart when side effects are introduced.

Re: “Mostly functional” programming does not work

#13

The author needs to be less aggressive in the accusations. This current trend which supposedly "doesn't work" actually runs the vast majority of the modern web consistently and reliably. Placing onerous restrictions on what someone is permitted to do in order to satisfy some formal abstract programming model - that is the thing that really doesn't work too well. This makes arbitrary programming arbitrarily difficult:…

There are advantages to both methodologies, but I must say I agree with you. The accepted academic practice is to find/develop the right formalism and then implement from there.

Despite this being akin to heresy, I much prefer to implement, then formalise later. I find it easier to "get the job done" that way.

Re: “Mostly functional” programming does not work

#14
post #5

To play devil's advocate for a minute: Nearly all useful, reusable software today is written in a mostly or entirely imperative language. This is despite the fact that functional programming has been around for at least 20-30 years. So, my basic question is, if functional programming is so much better, why isn't more software written in a functional language? Or put another way, why are there so many blog posts promo…

After reading the article I tend to agree. Just this excerpt seems to confirm:

Pure functional programming is programming with mathematical functions. ... Calling a function with the same arguments will return the same result every time.

That leaves a whole lot of other functions, the non-mathematical ones, the real-life ones where you read files or I/O or user input out of the "Pure" definition, if I understand it correctly that is. And by that logic, means '"Pure functional" programming does work, but only if...'. Or, in other words: '"Pure functional" programming does NOT work in real-life software'

Re: “Mostly functional” programming does not work

#15

The author needs to be less aggressive in the accusations. This current trend which supposedly "doesn't work" actually runs the vast majority of the modern web consistently and reliably. Placing onerous restrictions on what someone is permitted to do in order to satisfy some formal abstract programming model - that is the thing that really doesn't work too well. This makes arbitrary programming arbitrarily difficult:…

You need to better learn what you are talking about. Passing data by pointer is perfectly allowable in functional programming, how do you imagine passing something by pointer has side effects?

Data.ByteString is basically a pointer to a byte array, and it's one of the most common datastructures in Haskell.

Even more importantly, the optimizations the Haskell VM is allowed to do because of the immutability and purity constraints means that even naieve and trivial solutions using Data.ByteString on general I/O problems like webservers perform in the best of class amongst native competitors like Nginx.

edit: And the majority of the web is ran consistently and reliably? You mean apart from it being threatened by huge security vulnerabilities almost every month for the past 20 years? With so much insecure systems still connected that DDOS attacks are a day to day concern for system administrators?

Re: “Mostly functional” programming does not work

#16

The author needs to be less aggressive in the accusations. This current trend which supposedly "doesn't work" actually runs the vast majority of the modern web consistently and reliably. Placing onerous restrictions on what someone is permitted to do in order to satisfy some formal abstract programming model - that is the thing that really doesn't work too well. This makes arbitrary programming arbitrarily difficult:…

Which functional language prevents you from passing buffers by reference?

Edit: I see there are quite a few. Please tell me about one :)

Re: “Mostly functional” programming does not work

#18
post #5

To play devil's advocate for a minute: Nearly all useful, reusable software today is written in a mostly or entirely imperative language. This is despite the fact that functional programming has been around for at least 20-30 years. So, my basic question is, if functional programming is so much better, why isn't more software written in a functional language? Or put another way, why are there so many blog posts promo…

Functional programming has been around since the late 50s/early 60s, depending on what you count as the start of LISP as a programming language.

In some ways the reason it isn't used a lot is for historic reasons as much as anything else. Functional programming, for a long time, was seen (often rightly so) as more computationally expensive than the same imperative code for most tasks. For a long time, that meant that you weren't going to use functional programming: when every single byte and cycle matters, you're going to go with assembly or whatever is closest to it/translates really well to it. (e.x. C)

We now live in a world with abundant memory and excessive unused clock cycles. If I remember correctly, there's also been a good bit of research and work in the last 20-30 years The historic reasons for not using functional programming are gone for many (but definitely not all; people still hand roll assembly, too) of the original use cases. However, you then have 30+ years of programmers who were largely trained in and almost exclusively used imperative languages over the course of their career. That kind of market share is hard to compete with (because it's similar to market share; if everyone is using imperative languages, you need to be familiar with them too if you want to stay in most parts of the industry), and is self perpetuating (if you want to work in CS, you're going to need to know imperative languages for most jobs).

I'm also fairly certain there's a good number of useful, reuseable programs that're written in functional languages, but I'm in an airport and nothing immediately comes to mind.

Post reply on HN