Why pattern Matching in C# ?

fiveminds

New member
Joined
Feb 20, 2020
Messages
2
Programming Experience
10+
According to this article Intro To Pattern Matching - Covers C# 9 C# 9 and 10 will have all F# pattern matching! Why C# need pattern matching?! and other new features! the language will blowing-up and it will be like C++! is that correct? I need to hear some opinions from C# profi?
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
2,860
Location
Sydney, Australia
Programming Experience
10+
What's the problem if the language has many features? There's no need for you to use them if you don't want to. People who want to use them will be able to stick with C# and do so, rather than move to a different language. C# doesn't NEED pattern matching but it needs to support the features that people want if it is to keep its audience. Microsoft are trying to anticipate what those features are and add them preemptively.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
1,227
Location
Virginia Beach, VA
Programming Experience
10+
There is a trend towards the function programming style of programming. Pattern matching helps make writing code in the the functional style in C# have less friction.
 

Sheepings

Senior Programmer
Staff member
Joined
Sep 5, 2018
Messages
1,141
Location
UK
Programming Experience
10+
Maybe I'm just being picky but your use of " ?! ", makes it appear as though you have an issue with this?

Talk about a convenient discussion Skydiver, and we were only talking about this the other night...

Actually, if it wasn't for Microsoft taking this avenue, I can personally see myself reverting back to C++ or even moving to an entirely new language eventually.

I also agree with both John and Skydiver, if you don't want to use them, then don't. The only way I can see patterns and new C# features being a problem for some; is if you are unwilling to learn them, or if you're working in an environment where you're required to read other people's code who will be encouraged to write using the new features.
 

fiveminds

New member
Joined
Feb 20, 2020
Messages
2
Programming Experience
10+
There is a trend towards the function programming style of programming. Pattern matching helps make writing code in the the functional style in C# have less friction.
But the trend does not come from nothing. I think because OOP has enough problems
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
1,227
Location
Virginia Beach, VA
Programming Experience
10+
Yes. Functional programming tries to get rid of the "hard part" of OOP where state is mutable by switching over to immutable objects. It bring around it's own set of headaches if things were to be implemented in C++ where every bit of memory needs to be micro-managed, but C# and the .NET Framework offers a lot more freedom since the programmer won't be stuck in the minutea.
 
Top Bottom