As I’ve mentioned in my earlier post, I have decided to stop focusing only on C++ and go back to F#. As I’ve said, I remembered that F# programming was fun, and felt more safe – programs were less bug prone, and often did exactly what I’ve wanted after first time I’ve compiled them. Besides that, programming in F# was often straightforward, code closely resembling my solution to a problem without much boiler plate
While I plan to invest more efforts in F#, I have come to a conclusion that learning C# along with it is extremely important and helpful. In the following text I will explain why I think so. However remember that I am at beginning stages at both right now, so take everything I say with a grain of salt.
I believe that besides learning the core language and functional programming idioms, there are two things one needs to get comfortable to become good with F#. First, one needs learn to combine objective oriented, imperative and functional paradigms, because F# is a multi-paradigm language. Second one, is understanding the .Net platform – which is one of the reasons why F# stands out from other functional languages and that makes it powerful.
To learn the language part, there is no way around it – one needs to write more F# code. Which is what I’ve been doing for a while – you can see some examples here. Which helped me to feel more comfortable with the language, however, as you can see those are just book examples, which are arguably not that interesting. In order to build something more interesting – one needs access to good libraries.
Which brings me to my first point.
Many F# libraries are just C# libraries.
As I’ve said earlier, one of the reasons that I think that F# is powerful is that it has access to whole .Net ecosystem. However many tools that exist there are implicitly or explicitly designed to work with C#. Being able to work with C# helps there. I wish that when new .Net tool is released by MS, F# would be taken into account too. However, this is not the situation right now.
Another language gives you more tools.
While I believe that F# is better (easier to code, has similar performance characteristics and less bug prone), being able to work in more than language makes you more powerful. For some tasks, C# is still more appropriate – when your problem fits more Imperative/OOP style, you have a library that is works only with C#, or there is a solved problem for which you can easily find code examples in C# but not F#. When you wan to write wrappers around C# lbrary, C# knowledge obviously gives you an advantage there. Also, when you require better performance on .net – there are much more resources on how to optimize C# code, than F# code. So if you want to get fast performance, C# is also required (at first at least – I am sure it is possible to get F# performance to match C# performance in almost every case).
C# can help you get a job
While I am a hobbyist programmer, many people do that for living. At the moment of writing, there far more C# jobs than F# jobs. So if you decide that you want to get paid for it, for now F# is not your best bet (I hope this will change in future).
While F# is a nice language to use, C# helps you become more productive with the platform F# runs on and also more practical from economical point of view. Hence, if you are F# programmer and haven’t learn C# yet, you should give it a try.