Friday, May 14, 2010 4:41 PM
Can F# Displace C# on .NET?
I just read How to Design a Popular Programming Language, which is very similar to Paul Graham’s Being Popular essay from 2001 about language popularity. Both make the point that languages become popular because they become the default way to program a very popular platform.
This is a point I make often. I care about what language I program in somewhat, but I will do whatever it takes to get the deployable I want. So, at Atalasoft, since I want .NET assemblies, I need to use a .NET language. For the iPhone, I need to use Objective-C. It wouldn’t matter if I prefered Java (I don’t), because Java can’t make what I want.
On .NET I have a few choices. There is basically no output difference between C# and VB.NET, so I can consider the language itself apart from what it makes. Atalasoft primarily programs in C#, but nothing we make in C# couldn't be made in VB.NET. The choice is arbitrary and largely a matter of taste.
Now, with Visual Studio 2010, F# is thrown into the mix. Atalasoft has a close tie to F# because one of our DotImage architects, Rick Minerich, is an MVP for Microsoft (largely because of his F# community contributions) and is a co-author on a new F# book coming from Wrox, Professional F#. So, we tend to know more about F# than most development groups.
Like VB.NET, F# can create any result that C# can, since it has full support for the .NET object model. If tomorrow, all of our C# code was in F#, no one would know. But, C# is by far the dominant language on .NET – on many platforms, dominance has advantages.
Looking at the first article I linked to, we see these reasons why dominant platform languages are hard to displace:
- Nobody has figured out how to make cross-language interoperability work well.
- The network effects from language adoption are immense. Programming is, despite appearances, a deeply social profession. To write successful software quickly, you must exploit the skills of other programmers — either directly, by hiring them, or indirectly, by using library software they've written. And once a language becomes the most popular in a niche, the supply of both programmers and libraries for that language rapidly accumulates to the point where it becomes economically irrational to use any other language.
Well, Microsoft has figured out how to make cross-language interoperability work well – we have VB.NET customers using our C# code quite happily. Microsoft has also made C++ work pretty well with C#, and we have customers who do that as well. On .NET, you can freely mix any well-implemented .NET language.
The second point is more convincing and it breaks down like this:
- It’s easier to hire developers for more popular languages
- It’s easier to find libraries for more popular languages
Well, #2 isn’t true for .NET languages, because of the good cross-language interoperability. So, F# can displace C# if either
- More Developers learn F#, getting rid of the only reason not to use it instead of C#
- F# can take advantage of some part of the .NET platform that C# cannot, and that part of the platform becomes popular (virtually forming a new platform that it can dominate)
Either of these might actually come true – some things that may cause it to happen
- Developers might form a taste for F# coding – it’s got a brevity and expressivity that might attract developers that care about that kind of thing.
- Many-core is coming and F# is designed to produce code for it, whereas mutable state in C# will hold it back.
- Functional programming and language-oriented programming are getting more popular and might displace object-oriented programming for more and more tasks. These styles are both natural in F# and not really possible in C#.
F# is not without its problems – the main being secret advantage #3 for dominant languages – code generators. In Visual Studio, if I am making a WinForms or WebForms app, VS generates a lot of code for me, but only C# and VB.NET, not F#, yet.
So, it’s very possible F# could displace C# on technical merits, but it will still have a lot to do to overcome things like industry momentum, politics and other factors that will favor C# for some time. One obvious way to overcome that is a popular killer app that is widely known to be made in F# and has either brevity or many-core advantages that C# can’t replicate.