News for hackers. Stuff that matters.
Re:Java 20 Is Out! by dgb23 on Tuesday March 21, 2023 @12:24PM (#35248444)
I don't see a huge benefit for pattern matching in JS outside of it being expression based rather than statement based.

Either way, the benefit has to be enormous. It's a feature that can easily break existing code.

Re:Java 20 Is Out! by int_19h on Tuesday March 21, 2023 @12:32PM (#35248600)
How would it break existing code?
Re:Java 20 Is Out! by dgb23 on Tuesday March 21, 2023 @01:32PM (#35249520)
Because it is an expression that introduces a new keyword.

You could say “return match…”

It’s not easy to introduce without breakage. Not saying it cannot be done.

But PHP didn’t manage to for example. It also isn’t real pattern matching but that’s a different issue.

Re:Java 20 Is Out! by int_19h on Tuesday March 21, 2023 @02:02PM (#35249953)
Oh, so you were referring to the specific syntax in the current proposal, rather than pattern matching in general?

Java and C# show how the syntax can be done in a fully backwards-compatible manner. It looks like it's just not the JS way by choice - apparently every new keyword that was added since ES5 is an actual keyword reserved in all contexts, not context-dependent?

Re:Java 20 Is Out! by dgb23 on Tuesday March 21, 2023 @03:33PM (#35251351)
That’s good to hear!
Re:Java 20 Is Out! by baq on Tuesday March 21, 2023 @12:45PM (#35248824)
In a world where upgrading node versions without language changes breaks existing code I wouldn’t be too worried.