Gleam 0.15
gleam.run
gleam.run
> Gleam is a type safe and scalable language for the Erlang virtual machine, and today v0.15.0 has been released! Let’s take a look at some of the highlights.
Might I ask for some more guidelines on how to incrementally incorporate Gleam into existing projects in BEAM languages? A guide on interpolation with a phoenix codebase and toolchain would be wicked cool.
The focus for now is on Gleam tooling, but once we have that down we can work more on Elixir tooling for Gleam.
[1]: https://www.youtube.com/watch?v=UCIcJBM_YDw [2]: https://github.com/gleam-lang/plug/
The Rust ndarray library as a "ndarray for numpy users" [0] which I thought was a very nice idea to help people from the python world convert their numpy code to Rust.
[0]: https://docs.rs/ndarray/0.15.1/ndarray/doc/ndarray_for_numpy...
Edit: In my experience almost all Rust tutorials are either for complete beginners or for developers with systems programming experience (like C/C++).
This is an intro blog post though, perhaps you expected some more depth.
But where it describes the map-dictionary duality, it says: "There is no map literal syntax in Gleam, and you cannot pattern match on a map. Maps are generally not used much in Gleam, custom types are more common."
But it doesn't say why or how this would be done. It seems that, if this point is going to be mentioned, there should be enough context to make it actionable.
The last thing I read was that the plan was to re-implement a GenServer alike from scratch in Gleam rather than anything built over the top of the existing GenServer implementation. I can see why that might be necessary but that's slightly concerning given how battle tested the existing GenServer implementation is and all the edge cases it handles.
https://github.com/gleam-lang/otp
It is not a wrapper around gen_server etc, but instead it is a full implementation from the ground up using a very small Erlang core (~200 lines). This was done because:
a) Erlang OTP cannot be typed, we need different abstractions are designed with types in mind
b) We want to be confident that our abstractions are powerful enough to build something like OTP, rather than cheating by relying on type casts.
I'm very happy with how Gleam OTP is going, but it is not the focus now that an initial version is out. Tooling and documentation is more important at the moment.
I've always kinda felt that there's a lost opportunity for extensible syntaxes by doing things this way rather than having the main surface of a language be some sort of intermediate representation (A la Wasm, LLVM IR, JVM, et al)
Congrats on the release regardless. It's good to see big stable projects in this niche in the BEAM-verse. The world needs more type safety.
[1] https://github.com/alpaca-lang/alpaca [2] https://blog.erlang.org/core-erlang-by-example/
Alpaca looks very neat, and ML is right up my alley. thanks again for showing this!
I can admit I am no BEAM expert and it seems my thought offended the experts, but I just like the aesthetic of modularity played out to the logical conclusion of syntactic extensions unto intermediate forms.
Who knows? I didn't find the musing particularly off putting.
As Alpaca is apparently dead there's also LFE[1] and Hamler[2]. Most devs in the space stick to either Elixir or Erlang so ymmv.
I am very fond of the ML syntax, but I think it is the semantics and type system that really matter, so I am very happy to sacrifice syntax in order to make Gleam more widely accessible.
It's superficial, you get past it quickly, but it's the first thing you encounter and that can affect whether people give a language a 'proper' go.
I think the ML people like me are kinda used to not getting their favourite syntax. Alas!
That's very cool, I wouldn't have thought that the trend would swing that way. I suppose it makes sense in a conventional wisdom kind of way.
How long ago was the switch? I'd like to read (code or prose, idc) about your experiences switching the syntaxes out. That's a hard thing to do right, but maybe not so much if it was really early on?
I had hoped that Go would eventually kind of serve this role in the PLT world, years ago when it was first announced. Sadly, it's morphed a lot over the years into something entirely different.
def foo(bar, baz):
...
is a valid (empty) python functionie: from typing import Any, NoReturn
def foo(bar: Any, baz: Any) -> NoReturn:
raise NotImplementedErrorElm's compiler will prevent you from creating a production application with a `Debug.todo` still in place.
Haskell has "typed holes": https://downloads.haskell.org/~ghc/7.10.1/docs/html/users_gu...
It's just a code comment, but by default Credo will exit non-zero if it sees one so if Credo is part of your CI pipeline it will fail it by default.
I'm one of those annoying people who puts # TODO comments all over my code though, so I set Credo so that TODO's wouldn't fail the build.
I expected we'll have an initial offering within the next half year.
More generally, Gleam doesn't have any concurrency primatives in the core language currently. We have a type safe OTP library, but it implemented in userland with a core of ~200 lines of Erlang rather than being built in to the compiler.
In the other direction, to quickly discover how to call Gleam functions from Erlang/Elixir, one option is to explore your project with IEx's auto-complete functionality; it's the same as using Erlang functions in Elixir, as Gleam compiles to Erlang.
Later we will have more docs on how to work with Gleam from Elixir specifically, thank you.
I read the "Why Gleam" page, and it reads like "Why have static types" and "Why work on a virtual machine" + "Why we're as good as Erlang". That's not much of a pitch (especially if you're not already into Erlang.)
It's tricky to condense into a short reply, but the Erlang virtual machine and way of programming are in some respects second to none. It is build with scalability, concurrency, distributed computing, and fault tolerance in mind. It's really good at handling high load. It uses the actor model and it's not uncommon to have hundreds of thousands of actors in an Erlang programs (in fact the creator of Erlang says that's a "boring" scale) without any deadlocks or fiddly race conditions.
Erlang programs also have mechanisms for self healing when errors arise (bugs, hardware failure, whatever). Kind of like k8s style system but very fine grained and baked into the very language and with 35 years production usage.
This is a bit of an off-the-cuff fanboy-y ramble, but basically it's just a really nice ecosysem to work in when making networked services. I've personally found it makes things a lot easier than most other ecosystems I've worked in.
1. I'm not much of a VM person, but I'm always doubtful of claims by VM-based languages to be "fast".
2. "the ... virtual machine and way of programming are in some respects second to none" - We don't easily notice any of those respects on the "Why Gleam" page.
3. "It is built with scalability, concurrency, distributed computing, and fault tolerance in mind" <- That's rather vague. Also, is this a benefit of Gleam, Erlang, or the Erlang VM?
4. "It uses the actor model" <- Many, perhaps most, languages, don't "use the actor model", so I wouldn't know why this it is superior to other ways of programming.
5. "it's not uncommon to have hundreds of thousands of actors in an Erlang programs" <- Well, I didn't see actors in the examples, so I can't tell why this is impressive.
6. If Erlang is so nice, what's wrong with it to make me prefer an non-Erlang, but Erlang-sih language?
7. "Erlang programs also have mechanisms for self healing when errors arise" <- In the most general interpretation, this is Turing-complete, so such a feature is impossible. But perhaps you mean something like exceptions and error codes? Transactional data structures? Something else?
I'm not trying to be facetious, just to understand why this is interesting. Also see my comment about the project CoC, it's pretty scary.
2. Yes! More documentation will come as the language matures. For now we will have to defer to Erlang and Elixir documentation and studies.
3. All three. Gleam aims to provide scalability with development through excellent tooling and static analysis, Erlang and the VM provide runtime scalability with fault tolerance, concurrency, parallelism, and distribution at runtime.
4. Quite a tricky one to explain quickly but it's concurrency model based around the idea of having many sychronous subsystems working together in a system similar to how people work together. It's often said to be one of the easiest to use concurrency models. To paraphrase one of Erlang's creators: "It's hard to write a web server that can process 1000,000 concurrent requests, it's easy to write a web server that can handle 1 request and run 1000,000 of them".
5. Most languages will only have 1 thread or 1 per CPU on the machine, so having millions is quite unusual. Golang is another language that has this property and it has proven very valuable.
6. I'm sorry, I don't understand this question. What do you mean?
7. It's not analysis, so turning completeness isn't an issue! The fault tolerance is purely a runtime behaviour. It covers exceptions and such, but also works for hardware failure, network issues, memory corruption, etc.
Anyway, about No 6: The why Gleam page and your previous posts do not differentiate Gleam from Erlang. The benefits you described are seemingly shared by Erlang and Gleam, and yet a non-Erlang language was created.
Seriously, if you're even the slightest bit curious you should watch the talk, I'm very confident that you'll find impressive what the BEAM brings to the table.
would somebody use Kubernetes to get the same benefits in a non-fault tolerant language? or do people still use BEAM in kubernetes?
I like to say that Erlang's supervisors are to k8s what k8s is to datacenter failover. Similar things, different level of abstraction.
And yes it's common to use Erlang with k8s, though there is a little redunancy. It's still good for all the other k8s features.
https://github.com/gleam-lang/gleam/blob/main/CODE_OF_CONDUC...
It says that if you're a contributor, people can make anonymous complaints about you, and you will be judged and punished without being afforded the right to face your accuser and full access to the accusation and the evidence (that is, a "confidential" adjudication procedure).
Naturally, you can be punished for very vague offenses, under the title of any "conduct which could reasonably be considered inappropriate in a professional setting". It's not even any conduct which _is_ inappropriate in the setting of the project - it's enough that someone could subjectively consider it inappropriate, and in a different professional setting. In other words: Very easy to cook up charges as necessary.
If all of that is not enough - anyone who is deemed not to follow the code of conduct in good faith - i.e. it's not enough that you follow it, you have to show good faith about it - is an offender automatically. Even failing to actively _enforce_ the CoC is an offense.
Now, Gleam may not the only project with this kind of repressive project-criminal code; but this is quite saddening to see in a Free Software project.
Rest assured that violations nor CoC trolling will not be tolerated in any way.
Perhaps the way the project actually runs is fine - after all, I don't know you nor the project. But generally, that's not the case. When I consider collaborating/contributing significantly to a project, and I see something like this CoC, it is a large red warning light. (Which is a bit ironic considering it's supposed to enforce inclusiveness and a welcoming atmosphere...)