3 ms·
Having written a fair bit of Elixir and Erlang code over the years, I don't feel like I miss static types much when I can readily pattern match on tagged tuples
by yellowapple 4y ago
Having written a fair bit of Elixir and Erlang code over the years, I don't feel like I miss static types much when I can readily pattern match on tagged tuples.
- sethammons 4y agoHaving written Elixir code for about a year and coming from Go, I miss static types dearly and specs are not enough. I have to dive into the code to know what I'm working with locally. My largest frustration is all the unhandled errors and exceptions that will not have the required context when they finally crash some process. It is apparently uniodiomatic to capture details in structured logs.
- vasergen 4y agoWhat is your experience with refactoring, especially a big project? This is where static typing helps a lot ihmo. Especially if you are in a startup like environment where things tend to change quickly.
- yellowapple 4y agoFunny you ask that, since I have indeed refactored OTPCL (a sort of Erlang-flavored Tcl-flavored scripting/config language I've been on-and-off hacking on for the last couple years) multiple times now, namely to rewrite the parser and to rewrite how command exports work - so the commit history should reflect some of the pitfalls and boons I encountered. I actually did pursue static typing (w/ type annotations and Dialyzer) at one point, but quickly lost interest, since it didn't really seem to add much. Having comprehensive tests, on the other hand, was crucial - especially since I could use pattern matching within those tests to make assertions about expected inputs and outputs. I will say that there were bugs that compile-time type checking probably would've caught, but tests also readily caught them. The same can likely be said for current bugs. It's ultimately the same idea: validate that your code adheres to the expected API and behavior; only difference is that the validation happens in different places.
- chasers 4y agoPattern matching and structs get you 90% of the way there imo. And Elixir started emitting warnings if you try to access a field in a struct and it doesn't exist.