What would be real cases of using functional programming in the .NET (F #) world?

18

Recently (ok, already a couple of months ago) I've been interacting with language F # , which is Microsoft's response to providing a functional programming language on the .NET platform.

But it has not been clear to me the real cases and advantages of using this paradigm over "traditional" object-oriented languages that are already well established (in this case, C # or VB.NET).

Therefore:

  • In which cases the functional programming enables solutions that object-oriented programming is faulty / slow / impossible?
  • Is there any use case of this language / paradigm in known projects (or open-source )?
  • From the professional point of view, for the demands of our (Brazilian) market, is it worthwhile to deepen the knowledge in this paradigm?
asked by anonymous 18.12.2013 / 21:03

2 answers

15

Although the Imperative programming paradigm is the most popular among [professional] programmers, it is just one of several means of "giving orders" to a computer. In addition to it and Functional , we also have Logical Programming (eg Prolog), Dataflow .: the internal engine of a worksheet), Function-Level (programs do not manipulate data, but other programs), etc. And, of course, the most conceptual / theoretical Turing Machine - to which all previous paradigms are computationally equivalent.

Each of these paradigms has advantages and disadvantages, and it is common as programming languages "evolve" that they incorporate aspects of other paradigms. The main reason for using one paradigm or another is its expressivity : at first, we could all be programming in Turing Machines, but beyond the difficulty of reading / writing / understanding such programs they would also be too extensive in relation to what they make useful. Similarly, different paradigms offer a greater degree of expressivity for specific domains (although the language as a whole is Turing-complete).

As for F # in particular, I'll quote an answer to a similar question in the Stack Overflow in English:

  My expectation is that F # will be used for parts / pieces of some specialized systems - parts that involve complex threading / math / financial calculations / modeling / etc, where F # fits well. In most other areas (UI, Data Access Layer, etc.), a general-purpose language like C # seems (in my opinion) preferable.

     

One of the advantages of F # is that (in theory) you can prove that the code is working, instead of just testing it. Threading support (thanks to immutability and asynchronous use of ! ) is also good (although PLINQ can compete in threading ).

(Comment: I disagree with the author of this answer in the sense that it is possible to prove that an imperative program is correct - it is only more laborious ...)

I can not comment on our market, since I do not participate in the Microsoft "ecosystem" (preferring to develop in free software), but in general opening the minds of Brazilian programmers to functional programming I believe would be very well coming!

    
18.12.2013 / 21:27
6

From what I understood the language, its use would be somewhat similar to that of matlab .

And it would be used where you need to perform complex mathematical calculations.

In the link that you have been given about functional programming there is the following excerpt: / p>

  

Functional programming languages, especially the purely   have been more widely used academically than in the development of   commercial software

In the commercial area it is more common to find use in the area of image processing (or video).

This does not mean that an entire application would be made in that language, but a part of the processing would be computed by a script written on it.

A practical example of use: the payroll system of the state where you work has all its visual part (the modules and screens that the employees operate) made in a language that facilitates the creation of forms . But payroll processing, which results in a gigantic volume of calculations, is run in C / C ++ scripts. The priority in this case was to gain in processing, since the calculations themselves do not involve such complex functions. Everything compose a single system, but with some parts written in different languages.

    
18.12.2013 / 21:26