yeetosaurusrex
8 hours ago
I wanted to use functional programming in actual projects and Elixir's lack of static types almost stopped me from picking it up initially.
I tried it out and, although I do miss static types sometimes, immutability and not having to deal with inheritance and other OO abstractions has made the trade-off worth it for me.
Yes some people do claim that pattern matching makes up for the lack of static types. I don't agree with that, but can say that anecdotally the number of type related bugs I notice in *my* Elixir code is much lower than the number of similar bugs I used to write in languages like Python. Whether that's because of common usage of pattern matching, or community adherence to patterns like returning tuples of {:ok, result} | {:error, error}, or something else is anyone's guess.
An important point not in the heading is that gradual typing has been added without any new language syntax.
It's still not statically typed. Maybe it never will be, but this is a step in the right direction and at least they're trying.
neya
4 hours ago
If you use Phoenix, using types at the data model level using changesets and then trickling them down all the way to the UI is a very good compromise. As changesets provide type validations out of the box too.
steve_adams_86
4 hours ago
Do changesets incur a runtime cost?
asa400
3 hours ago
Ecto Changesets[0] are runtime constructs, yes. They're similar to libaries like Pydantic, if you're familiar with Python.
steve_adams_86
2 hours ago
Yes, this is exactly what I was wondering, thanks. Another version of this that I love is Effect Schema in TypeScript land.
The runtime costs aren’t trivial, especially on large datasets, but I’ve come to love this pattern a lot.
lo_zamoyski
8 hours ago
You might find Gleam[0] a better fit.
veqq
7 hours ago
If you're only willing to use languages with the same features, what's the point? Learning how a different paradigm manages without types can be more insightful.
yeetosaurusrex
7 hours ago
Yeah I agree learning new paradigms can give you new insights.
There's also a balance between learning new languages for fun and for the insights they give, and wanting to ship.
As an example: Prolog was mind-bending for me when I tried it and I had a lot of fun with it, but I can't imagine using it to build a product (I'm sure other people have though).
Perhaps my first comment sounded more critical than intended. I'm really excited to see where this initiative with set-theoretic types goes, and if it leads to a fully statically typed language then that will be a bonus. If that doesn't happen, then I'm still perfectly happy with the language as it is.
Elixir taught me that I don't need static types as much as I thought.
3836293648
6 hours ago
Because the BEAM has much more to it than a terrible dynamic type system?