Re:Phoenix 1.7 for Elixir: Edit a Form in a Modal
by turdprincess on Tuesday September 12, 2023 @05:10PM
(#37488420)
I feel like a common refactor in a large project might be a complete redefinition of a model layer exposed via a bunch of structs.
How does immutability or patter matching save me from runtime errors caused by changing the fields or types inside a struct? Wouldn’t the pattern matching just fail and go down the wrong code path since it was matching for the old pattern?
I feel like immutability is great, pattern matching is great, but static typing is also great and there is no reason why it can’t happily live along side the other two.
Re:Phoenix 1.7 for Elixir: Edit a Form in a Modal
by AlchemistCamp on Thursday September 14, 2023 @08:33AM
(#37508065)
In this specific case, the question is moot.
Elixir structs have compile-time checks: https://elixir-lang.org/getting-started/structs.html
Immutability and pattern-matching get you at least the 80-20 of what a rigid type system does for larger code bases, and your team won't have to be as large when you're using a language like Elixir or Clojure.