News for hackers. Stuff that matters.
Re:“No, we’re telling everyone we are using Java” by YorkshireSeason on Saturday March 09, 2019 @03:30PM (#19348302)
What's wrong with Scala's pattern matching?
Re:“No, we’re telling everyone we are using Java” by macintux on Saturday March 09, 2019 @04:45PM (#19348692)
I shouldn't have said "crippled." It's just much more limited than when used in Erlang.

From digging a bit it appears to be somewhat the JVM's fault[0] and quite a lot of it is simply that it's a different type of language from Erlang.

In Erlang, nearly every line of code involves pattern matching, regardless of whether the developer takes advantage of it or not. Every assignment statement, every function return, every function parameter, is an exercise in pattern matching. It's at the core of the language, not an add-on.

As I mentioned in another comment, a closely-related feature that really shows it to its full advantage is multiple function heads/clauses.

[0]: https://www.scala-lang.org/old/node/11982

Re:“No, we’re telling everyone we are using Java” by YorkshireSeason on Saturday March 09, 2019 @05:07PM (#19348809)
OK, I also don't like Scala's inability to deconstruct in the parameter list. I come from an ML background where that is possible. But I found it less bothersome in practise than I had originally anticipated.

Erlang has pattern matching on bits [1] which is convenient, that would be nice to have, especially when writing networking software.

[1] P. Gustafsson, K. Sagonas, Efficient manipulation of binary data using pattern matching.

Re:“No, we’re telling everyone we are using Java” by macintux on Saturday March 09, 2019 @05:18PM (#19348859)
Good point on the binary pattern matching. I’ve rarely used it, but it is quite powerful.

I was pleased to discover Python’s tuple pattern matching in function heads, only to be disappointed that it was removed in Python 3.