odipus
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??
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
lud
I can’t remember a single person on this forum hating or even disliking typespecs or static types.
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.
APB9785
What those people want is for the typespecs to be strictly enforced, so you cannot compile the code if you have a mismatch. But as @stevensonmt mentioned, they are optional - basically just an extension of documentation.
Sebb
I’m just learning Elixir and I tried typespecs once, but I found the error-messages very cryptical. Also I find the handling of multiple function heads confusing.
Dialyzer is happy if just one function matches the spec.
Anyway I ended up deleting all typespecs and adding a TODO “add typespecs”
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.
LostKobrakai
To me it feels like most of the “dislike” for typespecs is not actually about the specs, but dialyzer and the comparison to static type systems. For me typespecs are a way to lessen the need to hunt down into implementation details of the input/output of functions at higher levels in the codebase. This is even more useful when working with third party code.
Say I have a
connand want to know how headers are stored on it. Looking atPlug.Conn.twill provide me with that without needing to search for something similar in running text documentation. Also typespecs describe the data instead of giving examples. E.g. a input ofpos_integer()is far more descriptive than having an example in the documentation use4as input.In my experience not having typespecs mostly means not having any information like that at all, which makes working with the code, but also reviewing it, more difficult.
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.