odipus
Why is there so much hate for typespec?
Since i dont have much expericen with elixir i dont know why most of you think typespec doesnt help much. Any eg where typespecs doesnt work as like some other staticaly typed lang??
Most Liked
stevensonmt
No one hates them. The issues people raise with respect to static typing is that typespecs are opt-in and not really enforceable. So you can still compile your code and end up with runtime errors due to mismatched types. I admit to struggling with the syntax of typespecs for a while, but now I find them very useful for not only reading code but also organizing my thinking while writing code.
lud
I can’t remember a single person on this forum hating or even disliking typespecs or static types.
sb8244
I don’t use typespecs because the time to utilize them is too long (in isolated CI), I find the syntax a bit hard to grok, and I believe that it’s very easy for the specs to not reflect reality. I once worked on a project where the team wanted to convince me that specs were a good thing. I looked through the existing source and a good many of the (passing) specs were completely incorrect. That was a major red flag about the specs being more harm than good.
This goes with another one of my general beliefs that “documentation kept separate from code will diverge 100% of the time”. Even putting them in the same file (on top of each other) is not enough. In order to truly be effective, they’d need to be used on every compile and fail to compile if they were invalid. Or be evaluated dynamically in the test suite such that any input/output that doesn’t match the spec raises an error (does this exist?)
I do let Dialyzer run via my VSCode extension and I actually find it fairly enjoyable. However, I view that as a development tool and not something I want to add 10+ minutes to CI for.
Last Post!
sb8244
Oh yea, good point regarding usage of code more difficult. I forgot to add to my post that published libraries absolutely should have typespecs for the reasons you mentioned. It provides great documentation and people that do use typespecs benefit from it. My post was regarding my private applications.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #elixirconf-us
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









