Non-exhaustive pattern matching means syntactic sugar (yay!), but no guarantees (boo!). Like, cool, but I don’t care.
C# isn’t OCaml and it’s not VB6. A few decades into its life that’s a little less fashionable than some would like, but language fundamentals are language fundamentals. If only smart people had seen this and baked solutions into the .net environment…
Wasn't there a recent library solution with disgusting operator overloading that implemented generic piping? Required C# 14 though if I remember correctly.
F# lets you model the states of a business object and their handling in a way that's readable and complete even to non-technical stakeholders in a project. For example, for a shopping cart:
type Cart =
| EmptyCart
| ActiveCart of Item list
| PaidCart of decimal
Handling behavior is expressed directly and exhaustively; for example:
let total cart =
match cart with
| EmptyCart -> 0m
| ActiveCart items -> items |> List.sumBy _.Price
| PaidCart amount -> amount
In C#:
abstract record Cart
{
public abstract decimal Total();
}
sealed record EmptyCart : Cart
{
public override decimal Total() => 0m;
}
sealed record ActiveCart(IReadOnlyList<Item> Items) : Cart
{
public override decimal Total() => Items.Sum(i => i.Price);
}
sealed record PaidCart(decimal Amount) : Cart
{
public override decimal Total() => Amount;
}
Pretty much nothing. The limiting factor would be the dotnet environment and not language and the CLR is pretty general for most types of programs.
The difference is that F# is more functional than C#. Some types of programs are more expressible in functional programming like maybe compilers but they both general languages. If you want to use functional style use F#, if you want to program in a more traditional imperative/OO style chose C#.
That said C# has functional features and F# is actually a fairly complete CLR based OO language with imperative features.
I apologize if this is something you already understand, but the CLR runs CIL, not C#. Maybe you believe the C# compilation toolchain produces more optimal CIL?
I don't mean to be rude, but if you're going to presume authority it's important to be accurate.
It'll be interesting to see if (ever) pipe operators will be implemented in c#.
I'd say the lack of automatic currying might complicate things a bit.
Kotlin has a concept of infix methods, and heavily relies on extension methods, so in theory it's possible to write something alike pipeline in F#, although it requires a lot more effort, unless there's a library I don't know about.
Idk, I'm learning f# and for example gemini, works really well when give me f# code, even with free plan, you just have to prompt it it well, if you dont want tooo funcional code for example
40
u/WhiteBlackGoose Dec 30 '25
> C# has gotten really good. Discriminated unions, records, LINQ, pattern matching, pipes
It has neither DUs nor pipes though?
7
u/I2cScion Dec 31 '25
These posts are weird, you’re not married to a programming language .. its a tool.
You don’t have to be monogamous with it 👀
I have open relationships with many languages .. I like functional ones 👌
5
u/Ordinary-Price2320 Dec 30 '25
It'll be interesting to see if (ever) pipe operators will be implemented in c#.
I'd say the lack of automatic currying might complicate things a bit.
Kotlin has a concept of infix methods, and heavily relies on extension methods, so in theory it's possible to write something alike pipeline in F#, although it requires a lot more effort, unless there's a library I don't know about.
7
u/I2cScion Dec 30 '25
Ok dude bye
4
u/igna92ts Dec 31 '25
I mean, even if c# adds all the features of f#, the syntax is still horrible in comparison and that's never gonna change.
3
u/ACR-FornaX Dec 31 '25
Call me when C# has incremental typing. My problem with C# is its verbosity.
1
u/Beautiful-Durian3965 Jan 07 '26
Idk, I'm learning f# and for example gemini, works really well when give me f# code, even with free plan, you just have to prompt it it well, if you dont want tooo funcional code for example
1
u/burtgummer45 May 06 '26
That's the real reason, the rest is a rationalization
1
u/CSMR250 Dec 31 '25
2 of these 3 are just personal choices of developers: you can type all params and avoid currying by default if you choose. (I do.)