Gleam 0.16 compiles to JavaScript
gleam.run
gleam.run
I guess that's the magic behind most JS data binding libraries?
I do find the syntax on the Gleam side a little bit odd:
external fn query_selector(String) -> Element =
"" "document.querySelector"
Becomes: function query_selector(arg0) {
return document.querySelector(arg0)
}
I'm not sure what the empty string first argument is doing in this case.Most of the functions on Reflect can be done using built-in language features, I haven’t seen much use of it in libraries.
For reactive, magic data binding see Proxy, which allows a callback on object property access for arbitrary objects. Proxy is the magic behind Mobx for instance. Reflect fits in well because it can be used as the “default” or fallback implementation for Proxy methods. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
> The pervasive Promise type and the split between synchronous and asynchronous functions in JavaScript can be more difficult to learn and use than languages such as Erlang and Go that make no such distinction.
is most interesting to me. I first got interested in Gleam as a statically-typed language targeting the BEAM VM that supported Erlang's concurrency model. Supporting it on JS VMs will be a whole lot harder I'd imagine. Without it, Gleam isn't really that interesting to me on the front end. But if they can pull it off, it gets very interesting. I'd take the Actor / CSP flavour of concurrency over async-await every day of the week.
This is more an exciting new feature for people who are already using Gleam, they can now do more with the language.
Is there a language on the BEAM that has strong functional features of Haskell?
It's still pretty new though, so I don't know how well it works just yet.
Robustness aside the BEAM has other nice properties such as the concurrency model, the concurrent and predictably low latency GC, and it's distributed and parallel computing features.
I think it is unlikely many people will pick Gleam to make just a web frontend, but if you have a Gleam backend it may be more appealling to also use it on the frontend so that you can share code and type definitions between them. In future a full stack Gleam web framework may also take care of the typically JSON API boilerplate between the front and back ends.
I can see myself using Gleam on AWS lambda and on Android in the near future using the JavaScript backend.