gleam-lang / language-tour

👩🏽‍💻 Learn Gleam in your browser
https://tour.gleam.run/
83 stars 61 forks source link

Clarify docs on floats (and ints) #131

Open PallHaraldsson opened 5 days ago

PallHaraldsson commented 5 days ago

I see that you understandably inherit the limitations for Float64, from Erlang/OTP, i.e. Gleam and Erlang are not suitable for high-performance) numerical computing, e.g. no divide by zero exception.

I suppose you have those integer limits and sizes: https://www.erlang.org/doc/system/memory.htm

On 64-bit architectures: -576460752303423489 < i < 576460752303423488 (60 bits). Large integer At least 3 words.

Float [32-bit.. ] On 64-bit architectures: 3 words.

Do you use the smaller tagged 64/60-bit integers (or 3-word larger)? It's not a big limitation, though a speed-bump in either case, even more for 3-word ints or floats.

A way to clarify might be "60-bit ints" and/or link to that URL.

Is there a way to escape those limitations? You can compile to JavaScript, and does that mean executing in the browser only, or also elsewhere? I suppose you can just get the outputted JS (and run locally, even change it though not recommended, and JS has fast JIT, still likely missing out on SIMD optimization).

Is there a way to compile to WebAssembly, or planned, i.e. targeting one-word machine integers as is (not just 60-bit) and one-word floats, with full IEEE semantics (not sure JS does), also allowing for SIMD? And even 32-bit or smaller for both?

Another way is calling C or other language, or even compiling to C. I would suggest compiling to Julia (I discovered Gleam on Julia subreddit).

I suppose you fully support UTF-8, and likely only, e.g. for source code, as I see OTP now supports (before only ISO-8859-1 (Latin-1), and do you have anything only supporting it, or it better?).

lpil commented 1 day ago

Good suggestion, let's make this more clear in the documentation.

There are no plans for additional compilation targets presently.