开发者

What are the advantages of F# over C# for enterprise application development? [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

What are the benefits of using C# vs F# or F# v开发者_如何学运维s c#?

My team is currently using C# .NET to develop enterprise applications for our company. We have a history of Winforms dev, but are now moving over toward SilverLight.

My boss recently saw a video on F# and thought it looked pretty exciting, and he has asked me to check it out. My question is this - what advantages would a functional language (like F#) give over an OO language (like C#) in the realm of enterprise application development?

I really want to see if there are any compelling reasons to even begin contemplating a shift. Some F# and C# comparison code might be nice to see as well.


You can express a lot of concepts much more concisely in a functional language like F#.

Functions are first class objects, and can be applied directly to collections to perform transformations/filtering much more efficiently.

Immutability is encouraged in functional languages, and this makes (for instance) multi-threaded code much more reliable (you know data structures aren't changing under you).

By being able to write multi-threaded code more reliably and more easily it's much easier to take advantage of multiple processors/cores (increasingly important now Moore's law doesn;t apply so much).

Note that you can use your existing C# objects within F#. As such, you may want to write certain parts of your code in F# and other parts in C#. You should be able to mix and match according to your requirements and the suitability of each approach.


I just ordered the Manning 'Real World Functional Programming' which does a fantastic job of explaining all of the nooks and crannies of F#, functional programming, and especially how it compares to C#, and OOP

What I'm coming down to is that functional programming in general increases the 'rigor' of your programs, assuming you conform to the principles of side-effect free functions, and immutability.

Additionally, there seem to be benefits to thinking about code in a declaritive sense, rather than an imperative sense. In OOP I tend to think of the steps it takes to accomplish something, but in FP it seems like you're more concerned with how you want to apply functions to data to obtain results.


firstly you ask "functional language (like F#) give over an OO language (like C#) i" f# is both functional and OO. any thing you would write in c# can be directly translated to f#. F# is a multi paradigm language but the advantage comes from the functional part in my opinion. f# and other functional langauge are a clear winner when it comes to writing multi threaded applications due to the higher possibilities for the compiler to reason about what can safely be run in parallel.

When it comes to web development f# has a very cool tool kit that allows you to write all code (as in server side and client side) in the same language aka f#. the client side will be translated into JavaScript by the web toolkit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜