I think most of the important points have already been mentioned by someone else:
- F # allows you to solve problems the way mathematicians think of them.
- Thanks to higher-order functions, you can use simpler concepts to solve complex problems.
- Everything is invariable by default, which makes the program more understandable (and also easier to parallelize).
Of course, you can use some of the F # concepts in C # 3.0, but there are limitations. You cannot use any recursive calculations (because C # does not have tail recursion), and this is how you write primitive calculations in functional / mathematical order. In addition, the complexity of writing complex higher-order functions (which take other functions as arguments) in C # is difficult because you must explicitly write types (while in F # types are output, but also automatically generalized, so you don’t you must explicitly specify the generic function).
In addition, I think the following paragraph from Mark Gravel is not a valid objection:
From a maintenance angle, I believe that suitable named properties, etc. easier to use (over the full lifecycle) than tuples and headers / tails, but it can only be me.
This, of course, is so. However, the great thing about F # is that you can start writing a program using tuples and head / tail lists, and later in the development process turn it into a program that uses .NET IEnumerables and types with properties (and that I think a typical F # programmer works *). Tuples, etc. And the F # interactive development tools give you a great way to quickly prototype solutions (and when doing something mathematical, this is important because most of the development just experiments when you are looking for the best solution). Once you have a prototype, you can use simple source code transformations to wrap inisde F # type code (which can also be used with C # as a regular class). F # also gives you many ways to optimize your code in the future in terms of performance.
This gives you the benefits of easy-to-use langauges (like Python) that many use for the prototyping phase. However, you won’t have to rewrite the entire program later when you finish prototyping using an efficient language (for example, C ++ or possibly C #), since F # is “easy to use” and “efficient” and you can switch freely between these two styles.
(*) I also use this style in my book of functional programming .
Tomas Petricek Dec 19 '08 at 11:11 2008-12-19 11:11
source share