Skip to content

Commit 4a03b49

Browse files
committed
More detail about Elixir types
1 parent 1509c59 commit 4a03b49

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

documentation/frequently-asked-questions.djot

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,32 @@ popular and a great language!
149149

150150
Here’s a non-exhaustive list of differences:
151151

152+
- Elixir and Gleam both have compile type type checking, but their respective
153+
type systems are very different, so they offer a different development
154+
experience.
155+
- Elixir's type system is gradual, so portions of the codebase can be
156+
dynamically typed. Gleam is always fully statically typed.
157+
- Elixir's type system is structural, while Gleam's type system is nominal.
158+
This means Elixir's types can be more precise in some respects, but it
159+
cannot distinguish between types that are semantically distinct but
160+
structurally the same.
161+
- Elixir does not support type annotations, so the programmer cannot restrict
162+
the type beyond what Elixir infers them to be. Gleam supports type
163+
annotations, but they are not required.
164+
- Elixir does not support generics, while Gleam does. This makes Gleam's type
165+
system more precise in some respects.
166+
- Elixir's type system does not integrate with any other system. Gleam's type
167+
system generates BEAM typespecs, TypeScript definitions, and API type
168+
information can be exported to be used by other external tools.
152169
- Elixir is gradually typed, while Gleam is fully statically typed.
153170
- Elixir's type system does not support user provided type annotations at the moment,
154171
while Gleam's type system does.
155172
- Elixir has a powerful macro system, Gleam has no metaprogramming features.
156173
- Elixir’s compiler is written in Erlang and Elixir, Gleam’s is written in Rust.
157174
- Gleam has a more traditional C family style syntax.
158175
- Elixir has a namespace for module functions and another for variables, Gleam
159-
has one unified namespace (so there’s no special `fun.()` syntax, but in Gleam
160-
variable names can shadow function names).
176+
has one unified namespace (so there’s no special `fun.()` syntax, and Gleam
177+
variables can be used to shadow functions).
161178
- Gleam standard library is distributed as Hex packages, which makes
162179
interoperability with other BEAM languages easier.
163180
- Elixir is a larger language, featuring numerous language features not present
@@ -173,13 +190,13 @@ Here’s a non-exhaustive list of differences:
173190
and full support for tools such as code coverage, profiling, and more.
174191
Gleam’s support is much weaker due to going via Erlang source, resulting in
175192
less accurate line numbers with these tools.
176-
- Elixir interactive and remote shells support writing both Elixir
177-
and Erlang code. Gleam shells require writing Erlang code.
193+
- Elixir has an interactive shell, while Gleam does not. Gleam programmers can
194+
use Erlang, Elixir, or JavaScript shells to work with Gleam code.
178195
- Elixir and Gleam both use Erlang's OTP framework. Both languages can
179196
use Erlang/OTP modules directly, though it is more ergonomic and
180197
requires less boilerplate in Elixir. Both languages offer their own
181198
additional abstractions, with Elixir providing new functionality
182-
and Gleam providing type-safe interfaces.
199+
and Gleam providing type-safety.
183200
- Elixir currently has superior deployment tooling, including support for OTP
184201
releases and OTP umbrella applications.
185202
- Gleam’s editor tooling is superior due to having a more mature official

0 commit comments

Comments
 (0)