1

I'm trying to understand the differences between C# and F#. To me, C# and VB are pretty much the same thing and I'm happy to use one or the other and I've dabbled with C++ to understand why to use it, however F# remains a mystery to me.

Now, I know F# is used for functional programming (or so I've read) but the details I've found are not conclusive as to why I would want to use it over another language. There are many similar questions already here but a lot of the answers suggest they are also in-fact very similar.

Can any one give a simple example of 2 real life situations where it would be preferable to use one language over the other (assuming there are any)? Or do we feel that it could be down to preference?

4

3 回答 3

2

See here, although the question has been closed, this response gives a good overview of when you'd use a functional language like F# over an imperative language.

于 2012-09-13T09:22:35.000 回答
2

The base class library is the same for both languages and there's nothing you can't solve in one than you can solve in the other. However some tasks such as mathematical computation or working with hierarchical data (e.g. a parser/type checker) is usually easier in FP than in OO other tasks where you model reworld objects and wish to give the user an experience of manipulating that real world object OO might lend it self better to the task

于 2012-09-13T09:25:55.097 回答
1

F# is a functional programming language it is particularly useful for mathematical computations.

From MSDN :

Functional programming is used for writing the core components of an application. It is used to elegantly implement main algorithms, the processing of data, or other key tasks. Code written in the functional style is often safer and easier to reason about. For example, functional languages avoid using the null value. It can also elegantly model the problem domain and solve problems in that domain.

于 2012-09-13T09:17:02.767 回答