r/functionalprogramming • u/effinsky • Aug 23 '23
Question Switch statement discouraged? Match expression encouraged?
I get the sense that in imperative programming, OO first and foremost, using the switch statement is generally discouraged in favor of "coding to the interface" and the ensuing dynamic dispatch and runtime polymorphism as something more maintainable, extensible etc. At the same time, in FP, I feel like using match expression is very much encouraged. They do differ in power etc, but what do you feel is the reason for the difference between how the switch is discouraged and match encouraged?
11
Upvotes
View all comments
Show parent comment
1
u/Flyyster Sep 27 '23
The struggle is real if you have big software, and besaid "shape" object gets an update. Then you have to touch every single switch that switches on the shape structure. This in itself is a pain.