8

Possible Duplicate:
What are the benefits of using C# vs F# or F# vs c#?

After reading some on the subject and watching this video http://streaming.ndc2010.no/tcs/?id=29649A14-2F1B-428E-BB12-9A43A1676221 where Eric Lippert, Jon Skeet, Mads Torgersen and Neal Gafter discussing the future of C# its pretty clear that C# has some heavy baggage from earlier features added to C#. These features must be supported in later versions of the language even though they add complexity and makes adding new features more cumbersome. Probably why most languages die sooner or later.

F# is a new language and obviously don't have the same legacy to worry about, so since both are general purpose languages it seems tempting focusing more on F#. Do you think F# is going to take over C# as the language of choice within the .net world and in case how soon will this happen?

I know there is a difference between functional and imperative languages so you could argue they are too different to be compared but the fact that c# is getting more and more functional features I have to ask why not just make the jump directly to F#

Community
  • 1
  • 1
terjetyl
  • 9,497
  • 4
  • 54
  • 72
  • 3
    "I know there is a difference between functional and statically typed languages" Huh? Those are two orthogonal concepts. Many (if not most) functional programming languages are statically typed (often even more strongly than most non-functional languages). F# certainly is. – sepp2k Sep 04 '10 at 12:54
  • @sepp2k, Sorry. Writing mistake – terjetyl Sep 04 '10 at 12:57

5 Answers5

17

Firstly, don't think of the division being "functional" vs "statically typed" - F# is still a statically typed language.

Do I think F# is going to take over from C#? Not in many areas. In some niches it will definitely make its mark... but I personally think it's more important for a different reason: it will encourage people to think more functionally.

It's absolutely worth looking closely at F# - in order to improve your C#. You won't find that every task is suited to a functional approach, but it's definitely worth learning to think in a slightly different way.

At this point, I should probably plug Real World Functional Programming - mostly written by Tomas Petricek, with a tiny bit of help from myself. It's aimed precisely at developers who want to think more functionally, with a heavy bias to existing C# developers who are interested in F#. (And today - September 4th 2010 - the ebook is only $15. Use code dotd0904cc at the checkout :)

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 1
    I'll add one point to that... People still (for some reason completely unknown to me) use VB.NET in 2010, even for new projects. What does that say about peoples' willingness to learn new languages and move on, regardless of their merits? – Dave Markle Sep 04 '10 at 12:58
  • @DaveMarkle - not sure what point you are trying to make there. VB.NET has good and bad parts just as C# does – Matt Wilko Jul 08 '16 at 10:19
8

C# is here to stay. The majority of commercial developers (and almost all commercial .NET developers) are trained in and use C derivative, imperative languages/styles.

I don't think the development world is going to undergo such a radical paradigm shift that imperative OO will vanish in favour of functional hybrids unless of course you count C#'s own move into the realm of a functional hybrid.

(by and large) You just cant hire F# developers, You can't find a job as an F# developer, you can't convince most workaday C#'ers (those who aren't language fans or hobbyist coders in their spare time) that F# is anything more than an academic toy or is simple enough to make it worth their time learning.

I SO wish that wasn't true, the more I learn F#, the more I would love it to be the language I used on a daily basis.

In reply to your question: YES! learn F# as it's a wonderful language, but it's not going to squash C# overnight (or over the next decade).

jdoig
  • 1,472
  • 13
  • 27
4

Should you take a look at F#? Yes, but because F# is an interesting language, and you will learn new things; not because you're playing defense against the chance that "C# is on its way out and F# is the wave of the future". C# is well-established, a great language with a great community and lots of existing assets (tooling, samples, templates, ...) that make it extremely unlikely to be supplanted by any other .NET language in the near future. Learn F# to play offense: to grow your own skillset, and become an overall better developer (even if you still mostly develop in C#).

(Feature creep and legacy do slow languages down some, but not much. From what I gather, C++ is still in use, despite crushing legacy. :) You said that languages die "sooner or later", but I don't recall offhand any language that reached the mainstream but then died "sooner".)

Brian
  • 117,631
  • 17
  • 236
  • 300
  • Die was a strong word but java and c++ are not at the position they once were – terjetyl Sep 04 '10 at 13:09
  • 1
    as much as it pains me to write it, java is still pretty much not dead even 4 years later ;) It lost a bit of turf to .NET and it's not looking sexy compared to jvm languages that have appeared since, but it's still going pretty strong. – scrwtp May 11 '14 at 14:19
1

First of all, F# is a more specialized language than C#. Yes, you could write solutions to almost anything in F#, but you'll find it particularly useful at:

  1. Implementing complex algorithms with lots of transformations
  2. Implementing concurrent algorithms

You won't find F# that powerful at things like UI or DB access (it can be done all right, but you won't find that much a difference from using C#).

Second, I don't think that F# will take over C# overall, but there are certain niche markets (e.g. the financial industry) where F# have a real chance of getting prominent above other languages.

Lastly, the functional programming paradigm, as you yourself mentioned, has made in-roads in several other languages/platforms (Python, Ruby, C#, VB.NET, hopefully the next Java), so getting familiar with its concepts is going to be helpful, and right now, at least in the .NET platform, F# is the truest implementation of such concepts.

  • You won't find F# that powerful at things like UI or DB access Actually people are voting for adding F# as a server side language for mvc razor views, so I would not be so sure about that – terjetyl Sep 04 '10 at 22:09
  • I agree with TT. Given the move to XAML, I think F# actually is a better choice because of the simplicity of elegantly composing functional transforms. As to data access, F# is a tad noiser but not obtusely so. Also, check out Functional NHibernate: http://bitbucket.org/robertpi/functionalnhibernate/ –  Sep 05 '10 at 07:01
  • 2
    I don't think its fair to say F# is a "more specialized" language. If anything its features are a superset of what one can achieve in C#. The only real feather in C#'s cap is it tooling support, which is perfectly understandable given its relative maturity. – pblasucci Sep 05 '10 at 14:47
0

Short: You probably shouldn't use F# as a general purpose language* like C#, but add it to projects where appropriate.

General purpose problems do often differ too much from the functional paradigm that F# wouldn't really excel, but in some cases, F# is absolutely the right tool. It's worth a close look though anyway, since otherwise you won't be able to actually point out these cases where a functional approach (even if implemented in C#) is favorable.

Nice problems for F#:

  • Mathematics / Physics / Simulation / Visualization
  • Data extraction / processing
  • Reactive GUI
  • Asynchronous code (events, callbacks)
  • Parallel execution
  • Parsing (domain specific languages)
  • Language-oriented programming (customize the language using it's own features)

Edit: Clarification after being downvoted. Of course, F# is a general purpose in the sense that you can do everything with it and target the whole .NET framework as C# can, but because it can be used, that doesn't mean it should.

As I said, many "general purpose" applications are not inherently functional, heavily based on changing state or common object-oriented patterns. While you again can use F# there, it doesn't really shine in this cases, being kinda programmed against it's nature.

Why should you use a functional language when you don't solve a functional problem? And since you don't have to, just combine F# and C# where each fits best.

Community
  • 1
  • 1
Dario
  • 48,658
  • 8
  • 97
  • 130
  • Please comment: Why is this downvoted? – Dario Sep 04 '10 at 14:26
  • 3
    -1. F# *is* a general purpose language. – Mauricio Scheffer Sep 04 '10 at 16:25
  • @Mauricio Scheffer: Many languages are ... See edited answer – Dario Sep 04 '10 at 16:31
  • 2
    I disagree with the edited answer as well. F# is a *multi-paradigm* (functional/object-oriented) language. It can do OOP, and it's just as powerful (or even more powerful) than C# at this. – Mauricio Scheffer Sep 04 '10 at 16:54
  • F# has it's (admittedly nice) way of using *objects*, but you won't use it in an *OOP*-approach like C# or Java. These imply excessive inheritance and certain design pattern implementations that are simply not necessary in F# , since they're covered by the functional approach itself. – Dario Sep 04 '10 at 18:17
  • 2
    I know what you mean, but OOP does not imply excessive inheritance. See "composition over inheritance". I agree about design patterns not being necessary in FP, but then this proves that F# is actually a **more** general purpose language than C#, since it includes OOP *and* FP (C# has rather poor support for FP in comparison). I don't think there is any *technical* reason to choose C# over F# anywhere (only if IDE/tooling support is an issue). There may be *psychological, social or market* reasons to do so, though. – Mauricio Scheffer Sep 04 '10 at 20:41
  • 3
    Finally, I don't believe there are "functional problems" or "object oriented problems". These are only *tools* that you use (first in your mind, then in your code) to model problems. Take a look at Haskell: it has been used to build anything from games to wikis and other web applications to SMTP servers. – Mauricio Scheffer Sep 04 '10 at 20:42