user2859458
user2859458

Reputation: 2505

Can I use .NET core with only F# or will I need to learn C# too?

F# has recently caught my eye as something I'd like to learn more about, but I have never used the .NET platform and know very little about it. If I want to write a small website in .NET core can I do that with only F# or will I need to expand my learnings to include C#?

Upvotes: 3

Views: 312

Answers (3)

mhsc
mhsc

Reputation: 79

There are some libraries that I could never get working nicely in F#, so I tend to have some C# projects built into my solution to handle things that I just could not find an elegant way of doing in F# - like using the high level "Nest" Elasticsearch driver. It is designed to give you very elegant code in C# but I found it was the exact opposite in F#, sort of defeating the point of using a high level driver.

C# is nothing to fear though, it is readable and intuitive for the most part. I came into F# with no knowledge of .NET and have learned what I've needed as I've gone along without any troubles.

Upvotes: 1

Reed Copsey
Reed Copsey

Reputation: 564413

You can definitely use .NET Core with pure F#. There is no C# knowledge required, though it can be beneficial to familiarize yourself with it enough to understand usage and library documentation.

The official Getting Started with F# guide has a section on using .NET Core with "just F#", which you can use as a starting point.

As for writing a website, I highly recommend looking at the SAFE Stack intro, docs, and samples. It shows how you can use only F# for full stack web development, all using .NET Core.

Upvotes: 8

Fyodor Soikin
Fyodor Soikin

Reputation: 80744

This depends on your learning and working style.

Technically, F# does not need any support from C#. You can write complete programs of any kind whatsoever without ever touching C#.

However, a lot of F# resources online are geared towards migrating from C# to F#, and as a result are phrased in terms of the differences between the two. Something like "you've been doing this thing in C# before, but here's how it can be done way better in F#".

Additionally, a lot of .NET libraries are written in C#. The binaries are, of course, completely compatible with F#, so you don't need to do any sort of special tricks to use C#-written libraries. However, if you ever want to look at the source code, that's where C# knowledge would come in handy.

To be fair, there is quite a large number of F#-exclusive libraries out there, but the majority of .NET libraries are still in C#. So chances are, you will end up using some of them. Whether you would actually want to look at their source - that depends on your style.

Upvotes: 7

Related Questions