4 ms·
I tried to find out why I would try gleam, what I would use it for. What I found convinced me it wasn’t for me. 1. Language behavior depends on the back end.
by fn-mote 2y ago
I tried to find out why I would try gleam, what I would use it for.
What I found convinced me it wasn’t for me.
1. Language behavior depends on the back end. Int doesn’t necessarily mean Int.
> When running on the Erlang virtual machine ints have no maximum and minimum size. When running on JavaScript runtimes ints are represented using JavaScript's 64 bit floating point numbers.
2. If it’s not an Int it’s a Float. Short numeric tower. I guess that’s ok. No BigInt with a guarantee it will not overflow? No exact Rational?
3. Type annotations [are optional and] “don’t change how the program runs”.
Ok this sounds like Python. Supposedly there are guarantees indicating “if it compiles it runs” but I’m worried. How do you even know the inferred type of your function is what you really think it should be? (I’m familiar with inference gone crazy from Haskell.)
- roetlich 2y ago> How do you even know the inferred type of your function is what you really think it should be? By adding a type annotation? Am I missing something?
- lpil 2y agoIt's not anything like Python. The language that it is most like is probably F# or OCaml. Python's type checkers are optional. They only verify code with annotations. Gleam's type checker is mandatory, so it is impossible to compile code without type checking being performed. Type inference and checking are always fully performed, and adding type annotations doesn't make the compiler perform any extra checking. > How do you even know the inferred type of your function is what you really think it should be? (I’m familiar with inference gone crazy from Haskell.) Gleam doesn't have subtyping so this is typically trivial, but idiomatic code has all functions annotated for clarity. You can also hover in your editor, or read the documentation Gleam generates and publishes from code automatically.