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

Asked

Viewed 3,325 times

20

Recently (Okay, it’s been a few good months) I’ve been interacting with f-language#, which is Microsoft’s response to offer a functional programming language on the . NET platform.

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

Therefore:

  • In which cases the functional programming makes possible solutions that the object-oriented programming is fault / time consuming / impossible?
  • Is there any case of using this language/paradigm in known projects (or open-source)?
  • From the professional point of view, for the demands of our (Brazilian) market, it is worth deepening the knowledge in this paradigm?
  • 1

    I think it’s the same as asking "what are the real cases where I would use mathematics?"

  • 1

    your question is very broad, and maybe it runs away from the site proposal. But I hope that answer is what you wanted to know.

  • 3

    To give an idea of the use of functional programming in the industry, see this page here http://www.haskell.org/haskellwiki/Haskell_in_industry

  • @korbes: Cool! Thanks for the link.

2 answers

17


Although the programming paradigm Imperative be the most popular among programmers [professionals], it is only one among several means of "giving orders" to a computer. Besides it and the Functional, we also have the Programming in Logic (ex.), Dataflow (e.g.: the internal engine of a spreadsheet), 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 one uses one paradigm or another is its expressiveness: At first, we could all be programming on Turing machines, but beyond the difficulty of reading/writing/understanding such programs they would also be too extensive in relation to what they do useful. Similarly, different paradigms offer a higher degree of expressiveness for specific domains (although the language as a whole is Turing-complete).

As to the F# in particular, I will quote an answer a similar question in Stack Overflow:

My expectation is that F# will be used for parts/parts of some specialized systems - the parts that involve threading complex / 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. Support for threading (thanks to the 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 "ecosystem" Microsoft (preferring to develop in free software), but in general the opening of the minds of Brazilian programmers for functional programming I believe would be very welcome!

  • 2

    Cool! Thank you so much for your explanation. A lesson for me.

6

From what I understand of the language, its use would be something similar to Matlab.

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

On the very link you passed on functional programming there is the following excerpt:

Functional programming languages, especially those purely has been used more academically than in development software commercial

In the commercial area is more common you 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 portion of the processing would be calculated by a script written on it.

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

  • Thank you @Guilherme for your reply. Your approach has already made it clear to me that usage is targeted, not a widespread trend. That’s what I needed to confirm.

  • The first two lines of your answer are wrong. Matlab is a specialized language for numerical computing, F# is a general purpose language such as Ruby, Haskell, Clojure, C# etc.

Browser other questions tagged

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