Skip to content

Latest commit

 

History

History
111 lines (61 loc) · 5.61 KB

reference.md

File metadata and controls

111 lines (61 loc) · 5.61 KB

Gleam Reference

Warning

This is still, very, very, WIP. Some information is probably incorrect and there are many places that could use better wording.

When should I use Gleam?

Whenever or wherever you'd use BEAM or Javascript.

Is Gleam Imperitive?

Gleam is a functional programing language.

Does Gleam Have A REPL?

Gleam does not have a REPL right now. It is a higly desired feature though so it will probably be added sometime in the future. If you'd like to work on this just ask what the status of this is.

Targets

Reference: #109

Builtin

  • Erlang (BEAM)
  • Javascript (NodeJS/Bowser/Anywhere else JS runs)

Other

Wasm

  • Gleam->Erlang->Wasm
  • Gleam->Javascript->Wasm
  • Gleam->Wasm
    • WIP - The person working on this is doing it as part of a school project, so not public at the moment.

IoT / Microcontrollers / Embeded Devices

Desktop

Andriod

Does Gleam Have A Garbage Collector?

Gleam does not have it own runtime. It compiles to Erlang and Javascript which both have garbage collectors. Don't let having a garbage collector fool you into thinking it's slow though, Erlang (BEAM) powers giants like Discord and WhatsApp.

Division By Zero

Gleam doesn't throw errors unless explicitly told to do so. So it just doesn't throw an error. There is also this article that goes into more details. Also see the Int and float docs.

Views On Crashing / Throwing Errors

See the Division By Zero section.

Gleam Written In Gleam (Bootstraping The Gleam Compiler)

No, this is probably never gonning happen. It's easier to bootstrap a language when it's still young and small, not when it hits 1.0. And as Louis said:

"It would be many years of rework to get back to the same point and we’d have worse performance. Big waste of time as even if it went perfectly we’d just be back to where we were before minus whatever we would have gained from using those years on the existing compiler."

Name For People Who Use Gleam

Gleamlins. There's also Glemlins, Gleamers, and a few other ones, but we prefer Gleamlins.

Can Gleam Interop With...? (FFI)

Gleam has builtin FFI support for Javascript and Erlang. Any other languages have to be done through Javascript's or Erlang's FFI for your language. For example WASM for JS and NIFs for Erlang. There's also this blog post about Gleam's FFI.

Operator Overloading/Defining New Operators

No. Gleam is designed to be simple and this would defeat that. If you realy want this than look into some sort of templating.

Constants/Variables Aren't Immutable?

Actually, they are. You're reallying just seeing shadowing in effect. The original value isn't mutated, it's just hidden by another defintion by the same name farther down. Shadowing only affects local scope and doesn't mutate the orignal value.

Does Gleam Have X Datastructure?

This blog post explores why Gleam only has data and functions, and not a multitude of data-structures.

InteliJ Support

Unfortunately InteliJ doesn't support LSP§, the standard protocol for IDE tooling. Due to their unwillingness to implement the LSP protocol, IDE tooling maintainers either need a complex LSP to InteliJ translation layer or rewrite all their tooling for one single editor. Both options are terrible, so it's unlikely that Gleam will have offical support for InteliJ. There are however a few (old) community projects for InteliJ support.

§ - Basic support is in paid version but very basic and not in free version

No Loops?

Gleam is a functional programing language which don't have loops. In functional languages you just use recurrsion. Infinite recursion is also very efficent in functional languages. Details as to why can be found here.