Live data from Hacker News

“Mostly functional” programming does not work

queue.acm.org

21–30 of 58 posts

Re: “Mostly functional” programming does not work

#21
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…

By the same token, Windows is much better than Unix, McDonald's much better than a healthy diet, Justin Bieber is much better than [insert musician], ....

Re: “Mostly functional” programming does not work

#23
post #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…

I didn't say Haskell. There are numerous programmings languages which only permit pass by value (and no referencing) for "I'm-such-a-smartypants" reasons.

I was really bashing the single-paradigm purist approach in general. It's much too rigid and difficult for anyone who isn't a card carrying mensa member.

Re: “Mostly functional” programming does not work

#24
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 is something you learn, more than something you do. Every time you create a procedure without side effects, you're using the paradigm.

Learning when it's useful to use state, and restricting side effects to those parts of the program that require it, is a good skill to have. Now, pure functional languages may have had a slow adoption, but they are a good way to learn the paradigm that can be translated to other environments.

Also, if you think FP hasn't produced results you haven't been paying attention, or you don't program neither web applications nor database APIs. Declarative libraries like jQuery selectors and LINQ have spread like fire, and any programmer of complex asynchronous applications should take a look at Reactive Programming (which represent state changes in a functional style with the Streams and Futures abstractions) and Agent-based Models (which encapsulates them through message passing).

Re: “Mostly functional” programming does not work

#25

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 :)

Alright ... I didn't mean this to be confusing ... here I'll remove that --- I was referring the whole class of languages which are more driven by purist theory than by practical need. There's quite a few that only support pass-by-value intentionally

Re: “Mostly functional” programming does not work

#26
post #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 c…

I believe the whole fuss of monads is because they allow you to write pure functional programming while still doing I/O and similar things.

http://chris-taylor.github.io/blog/2013/02/09/io-is-not-a-si...

Re: “Mostly functional” programming does not work

#27
Erik's example of the using statement is a straw-man: you get exactly the same problems if you do this:

using(var file = File.Open(path)) { _someField = file; }

..and then use _someField in another method.

It's not so much a problem with understanding closures, but of the limitations of IDisposable.

Re: “Mostly functional” programming does not work

#28
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…

> why isn't more software written in a functional language?

Because (1) honesty the “industry” programming is in the stagnation. Otherwise the boring Java♯'d run on Martin-Löf type theory; (2) it may require more brain; (3) we all learn imperative programming first.

(And of course this reasoning is ignoring one aspect: we (mostly) don't want to write bug-free software. Who would pay for support?)

Re: “Mostly functional” programming does not work

#29

Earlier quoted context omitted.

Which functional language prevents you from passing buffers by reference? Edit: I see there are quite a few. Please tell me about one :)

Alright ... I didn't mean this to be confusing ... here I'll remove that --- I was referring the whole class of languages which are more driven by purist theory than by practical need. There's quite a few that only support pass-by-value intentionally

C only supports pass-by-value (unless I missed something recent) and it's generally not considered a pure functional language.

Re: “Mostly functional” programming does not work

#30
post #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 c…

In practice functional languages have ways to mark certain code as having side effects for I/O and the like, which stops the badness from escaping to the rest of the program.

You're right in thinking that software with no side effects at all wouldn't be very useful.

Post reply on HN