Hacker News new | ask | show | jobs
by DeathArrow 1669 days ago
C# 10 didn't introduce many new features.

I hate they delayed the introduction of Algebraic Data Types again. Maybe they will appear in C# 11.

Using ADT in F# makes it a breeze to do domain modeling.

2 comments

Record classes and pattern matching get you 90% of the way there thankfully. Not perfect, but good enough. It's funny how much of a difference being able to write each case in a single line and have equality and all that stuff automatically taken care of makes. Honestly that's more important than the exhaustive pattern matching you get with ADTs. I can live with "default: throw".
C#10 brings some nice quality of life, which is always welcomed. Not all releases have to be about huge changes.

For example file scoped namespace is a very simple but great change, improvement for lambdas, improvement for structs, all of this make it nicer and simpler to write readable code.

Edit: I would also love to see ADT in C#!