Hacker News new | ask | show | jobs
by chc 3665 days ago
Yes, but you could say the same about "object-oriented programming" (is it about inheritance? message passing? N/A?) and even something as well-defined as "pass by reference" (many people apply this term to Java, many others think that is completely wrong).

Ultimately, we have to live in a world where words are kind of ambiguous, but I think we should try to avoid useless definitions. The definition where "a functional programming language is one that can pass functions around" is extremely useless, because it applies to every modern programming language including C and C++. Whatever you want the term to mean, it shouldn't be that, because that distinguishes nothing.

2 comments

> "Whatever you want the term to mean, it shouldn't be that, because that distinguishes nothing."

It's not extremely useless when you consider most programming languages cover multiple PL paradigms.

Functional languages are a spectrum. On one end you have pure functional languages like Haskell where you're forced to use functional algorithms for all computation, but there are languages in the middle of that spectrum like C# which support a bunch of functional language constructs (take a look here for a selection: http://www.codeaddiction.net/articles/13/lambda-expressions-... ) even if they aren't purely functional.

My argument is, any definition of functional programming that ignores the mid part of the spectrum is useless, as it ignores that most languages do not strictly follow a single approach like Haskell but allow you to adapt to different styles (i.e. most programming languages are multi-paradigm). Even F# and Ocaml allow you to write in an imperative style if you so choose, and many people would class them as 'functional' languages.

> functional languages like Haskell where you're forced to use functional algorithms for all computation

No you're not. Haskell supports mutable, imperative, algorithms just fine.

https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-I...

https://hackage.haskell.org/package/base-4.9.0.0/docs/Contro...

https://hackage.haskell.org/package/stm-2.4.4.1/docs/Control...

Thanks. If anything that backs up my main point that most programming languages are multi-paradigm.
Yes, but it doesn't bolster your argument as much as you think. The state monad in Haskell offers a more principled (some say annoying) way of dealing with mutation.

IORef's if I recall correctly offer the type of mutation similar to what is colloquially thought of as mutation.

These add to your argument a bit, but they're usually seen more of a last resort

Sort of. My very opinionated point of view would be that Haskell demonstrates that the functional paradigm is the correct setting for the imperative style.
Agreed.