Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Pattern matching is a key feature of functional programming languages; it predates Java by 20 years and remains widely used today. See https://en.wikipedia.org/wiki/ML_(programming_language)

For some examples relating to business logic, see https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/...

Lots of compilers are written in functional languages and use pattern matching for traversing abstract syntax trees, dispatching on the node type. The OO way to do this is to put all logic relating to a particular class in the class itself. The functional approach is to put all logic for a given method/function in one place and handle all the different types. They are two different philosophies both with different tradeoffs, and which is best depends on the type of program you're writing. But it's nice for a language to support both, so you can pick and choose which approach is best for a given problem.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: