Re: Addicted to Pattern Matching
2012-02-01 02:29:59 GMT
OK, I will just have to assume Simon is being sarcastic and really does love pattern matching. I am so tired of the limitations of the C, C++, Java style switch statement. In C# I cannot believe how many times I switch on String cases - that small improvement is so incredibly useful. I am glad the Java is finally catching up in this regard, but both Java and C# are a far cry from Scala. Over the years I make much more use of switch in Java than when I used to rely more on chains of if-then-else (which can get really ugly). It may be true there are bugs or other issues with pattern matching in Scala, but I have not encountered them enough (if at all) to find it a problem. I used the programming language SR over almost 20 years ago, and I really love how well pattern matching work on events, but I have not had a chance to do that sort of thing again until recently when working with Scala. Now that I have been writing production code in Scala, I just keep finding more an more situations where I can clean up my code using match/case. Now it is becoming instictive and I write the code first based on match/case instead of the result of refactoring. When you think about it, one of the things the human brain is really good at is pattern matching. One of the reasons I keep stressing that there needs to be more good concrete examples of Scala code is that I can often look a well written piece of code and more easily infer what is going on than reading pages and pages of theory of how to write the code. Oddly enough, in the past I have often had trouble understanding people's example of pattern matching in Scala, but now that I have more experience with it I am finding those example easier to understand.(Continue reading)
RSS Feed