odipus

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

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

lud

I can’t remember a single person on this forum hating or even disliking typespecs or static types.

sb8244

sb8244

Author of Real-Time Phoenix

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

sb8244

Author of Real-Time Phoenix

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.

Where Next?

Trending in Questions Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
tj0
I’ve been following the steps here for the upgrade from 1.6 to 1.7 and it has gone relatively smoothly all the way till the phoenix_view ...
New
cgraham
Hi! What is currently the best library/method for parsing text and tabular data out of PDF files in Elixir or Erlang?
New
stefanchrobot
Hi, I need a way to handle data migrations in my application. I found an article by @wojtekmach about manual migrations: Automatic and ma...
New
stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New

Other Trending Topics Top

GenericJam
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
JesseHerrick
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
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
webofbits
Squid Mesh is an open source workflow automation runtime for Elixir applications. It is aimed at Phoenix and OTP apps that want to defin...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
kip
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New

We're in Beta

About us Mission Statement