Is there any way to build a useful application based entirely on the functional paradigm?

Asked

Viewed 221 times

15

The functional paradigm, in theory, is beautiful to see. Purism, immutability and determinism. This can facilitate development, decrease the incidence of bugs and help in maintainability. From this, there is how to build a useful application based fully in functional programming?

In my view, any external communication or side Effect as:

  • print on console;
  • consume the system date/time;
  • save/recover data from a database

breaks the purism of the functional paradigm.

So, how can you fully respect this paradigm to build a "useful" software? By useful I mean applications that communicate with external systems, such as databases, Apis, and receive user input.

If I want to build something, I should have part of my functional code and part impure separate into another paradigm that allows me to input external data? In general, how do functional languages (F#, Erlang, Elixir, Scala) handle this? Or they don’t even deal?

  • 5

    LISP allows you to get out of the functional world in Common Lisp, so the standard output for languages of this paradigm is to open some imperative points for pragmatic issues. I don’t remember exactly how the other major dialect (Scheme) deals with this, but I believe it is opening specific points to be an imperative programming as well. Another point to evaluate is: the solution can have a pure functional part that is fed by a non-functional layer, as if the programmer left the functional part only to do the computation itself, not to deal with all the details...

1 answer

12


There is how to build a useful application based entirely on functional programming?

Are compilers useful? It’s a domain where this paradigm works very well.

Big Data, Machine Learning are useful? Functional programming goes very well with this. Maybe not in all nuances of these technologies, but in several of them goes very well.

any external communication hurts the pillars of the functional paradigm. How does the construction of an application with functional programming work? There is no way to fully respect this paradigm to assemble something real/useful?

Purity of paradigm is difficult to achieve even. If you want to, and no language I know is 100% functional (some adapt the concept to say that your language is), then you could only make manipulations of existing data in the code itself, nothing external.

Nor is imperative usually 100% pure, even if it does.

If I want to build something, I should have part of my functional code and the impure part separated into another paradigm that allows me external interaction?

Basically that’s it.

In general, how do functional languages (F#, Erlang/Elixir, Scala) handle this? Or do they not even handle?

These, in general, do not handle, they are functional up to page 3 :)

There are languages that use Monads to deal with external communication encapsulating what is impure from the rest of the code, thus, in a way, we can continue to consider it as functional programming since the rules put in the Monad create a certain determinism and do not cause side effects, maintaining referential transparency, i.e., the Monad is pure even if internally it does unclean things, it does not contaminate itself (at least conceptually).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.