Hacker Dudes// alternate deck. same feed.
FEED ~1/h SIGNAL
100%
SPOOLED 0/30 CYCLE 61319.850.52.17
8
Gleam doesn't compile to Erlang source anymoregleam.run
255pts/101 comments/12h/▼1
by ingve / hn> / « feed
▲▼ vortegne10:59 hn>

Congratulations to the team! I love Gleam and am genuinely having fun every time I write Gleam code.

▲▼ zachrip11:30 hn>

Shout out to Giacomo's twitch streams. He has taught me about some features of Gleam, Rust, and on top of that he's just a very chill person. He takes time away from his focus to answer questions politely and without judgement. There are dozens of programming streams where the streamer forgets to leave their ego at the door and he is not one of them. I highly recommend following it.

▲▼ speerer11:35 hn>

...And he animates his presentations by hand-drawing each frame transition, which speaks volumes.

[edit - this might have been ambiguous. I meant that it shows he really cares about the fine details.]

▲▼ jxf13:06 hn>

Do you have an example you especially like?

─ 3 more ─
▲▼ cod1r12:15 hn>

yea he is super nice.

▲▼ giacomocava17:23 hn>

Thank you! Too kind

▲▼ giacomocava14:31 hn>

Thank you so much!! Reading this really made my day <3

▲▼ oDot18:46 hn>

Thank you for Squirrel as well!

▲▼ olexsmir15:40 hn>

massive +1, been watching his streams from time to time, and the man is the definition of a humble and chill person

▲▼ giacomocava17:24 hn>

Aww thank youuu

▲▼ oDot18:44 hn>

The Gleam community is generally very very nice. I maintain about 200k lines of Gleam[0][1], and they have generally accommodated even my stupidest posts on Discord.

The language itself is as welcoming. Even LLMs are less cranky and output nicer code, not having to deal with React.

[0]: https://blisswriter.app/

[1]: https://nestful.app/

▲▼ 0x6942011:37 hn>

to those curious, erlang abstract form[1] is the AST representation used by the erlang compiler/etc. per [1], you can see that it's canonically made of erlang terms, and you have easy access to routines for manipulating this representation from the standard library; it's really comfy when you need it! it's also the target elixir compiles down to, and the representation manipulated by parse transforms, which in base erlang are the way syntactic sugar (notably qlc[2] and some of the more cutesy pattern matches in merl[3] (which, in turn, manipulates the very same representation to do its job. very meta!)) is done.

most BEAM languages actually settle on erlang abstract format. you'd think core erlang would be more common since it feels more like a traditional functional IR, but basically only LFE does this, because it's a moving target without any particular stability guarantees from release to release.

1: https://www.erlang.org/doc/apps/stdlib/erl_parse.html#t:abst...

2: https://www.erlang.org/doc/apps/stdlib/qlc.html#q/2

3: https://www.erlang.org/doc/apps/syntax_tools/merl.html

▲▼ lpil17:28 hn>
▲▼ phcreery11:44 hn>

The misuse of commas is distracting; at least it’s better than reading ai blogs.

▲▼ dominikh12:15 hn>

Which commas are misplaced?

▲▼ Joker_vD12:39 hn>

Before the "and", "but", "so", "while", etc. — while most European languages, indeed, (usually) require commas before conjunctions, English is following a somewhat reversed convention. Well, at least the author remembered that they need to omit a comma before "that".

─ 13 more ─
▲▼ gamache12:31 hn>

Your semicolon would be more effective as a comma followed by "but". HTH

▲▼ lexx12:11 hn>

Amazing news! Thank you!

▲▼ nwalkr12:14 hn>

idk, i'm not sure about wording. erlang abstract form still is erlang source, it's ast of erlang source text. one call to erl_prettypr:format and text source is back. word 'transpiler' is still there and there is nothing "pejorative" in it, it's transpilers all the way down everywhere.

but talking pejorative, i was surprised. my opinion of gleam was already pretty low, but i did not expect to see post-1.0 compiler emitting text erlang source. maybe it's not that good of idea to implement compiler in language completely foreign to target ecosystem.

▲▼ lpil13:41 hn>

I don't think your "it is source as you can convert it back into source" argument holds water as all the Erlang formats can be decompiled into Erlang source code, including the final bytecode itself.

I think you're overthinking the cost of compiling to source, and also underestimating how common it is.

▲▼ __jonas12:55 hn>

Pretty exciting change that I didn’t see coming —- I wonder if someone will end up implementing an integration with the Whatsapp Erlang debugger

▲▼ lpil13:37 hn>

The only thing that would be needed for this is for 2 flags to be passed to the Erlang compiler. It would be very trivial!

▲▼ jazzypants13:11 hn>

Let me guess: still no string interpolation in a language ostensibly intended for building user interfaces?

▲▼ dematz13:19 hn>

gleam is very much a language of "no" which if you like that, cool, if not, also cool :)

▲▼ lpil13:42 hn>

Gleam is not ostensibly intended for building user interfaces.

▲▼ whalesalad13:53 hn>

I still don't know what gleam is for tbh. I like it conceptually. But interop with for instance elixir libraries is not as seamless as you'd like.

─ 2 more ─
▲▼ jazzypants14:34 hn>

Then, why is JavaScript a compilation target? If you're not using it on the client-side, then why not stay exclusive to the BEAM?

─ 5 more ─
▲▼ impoppy13:14 hn>

This raises an obvious question. Why Gleam team weren't doing that in the first place? Obviously they didn't have direct Gleam AST -> Erlang source pipeline, they must have had to build some their own custom Erlang AST representation that they then translated into the source code.

▲▼ lpil13:37 hn>

We did not (and still don't) have an internal Erlang AST representation in the compiler. Previously we did have a Gleam AST -> printing algebra -> Erlang source pipeline, now we construct a buffer of bytes with the data encoded as Erlang Term Format.

Source was the previous target as at the time Erlang Abstract Terms was not established as the go-to format (Core Erlang was more popular but it did not have a stable API outside of the BEAM, so Gleam's in-Rust compiler could not construct it), and due to the newness of the language having an "escape hatch" where one could abandon Gleam and eject to Erlang was highly valuable. It also meant we could use the Erlang build tool until the Gleam one was ready for use.

▲▼ MichaelNolan13:30 hn>

Gleam is such a beautiful language. I wish I had the opportunity to use it more. If it could compile (transpile) to a native target like rust or go, it would be truly perfect.

▲▼ whalesalad13:49 hn>

I am working on a language called blasphemy which intends to do this.

▲▼ znpy14:51 hn>

Looking forward to be able to claim to be “proficient in blasphemy” on my cv! /s

▲▼ packetlost14:25 hn>

I feel like Go would be a great backend target for Gleam

▲▼ lpil14:52 hn>

Go's garbage collection isn't well suited for an immutable language like Gleam, so the performance would likely be disappointing compared to other targets.

─ 6 more ─
▲▼ phplovesong16:35 hn>

For that there is Lisette. Close to gleam, compiles to Go.

▲▼ rapnie15:37 hn>

I would love to see support for wasm and wasi.

▲▼ phplovesong16:34 hn>

You just described Lisette. Its very close to gleam, and compiles to Go.

▲▼ karel-3d13:47 hn>

What is Gleam? Where would I want to use it?

All I understand from the frontpage is that it's typesafe. Good I guess? Then there is something about Erlang which I never used.

▲▼ lpil14:56 hn>

Gleam is a simple functional programming language which leans into static typing , friendly tooling, and a one-way-to-do-it style. You'd want to use it if you enjoy the programming experience it provides.

▲▼ jeltz14:57 hn>

It is if you want Erlang but typesafe and with a modern syntax. And why would you want Erlang? Erlang was built for making it easy to build fault-tolerant concurrent applications, for example in telecom.

▲▼ giancarlostoro14:21 hn>

Erlang is one of those runtimes I've loved since learning about it all the way back in 2008, but I never took time to learn the syntax, but Elixir and Gleam have had me fiddling with the Erlang VM over the years. Happy to see Gleam growing into maturity.

▲▼ ch4s314:53 hn>

I'd say if you know and like Rust, then Gleam should be easy to pick up but otherwise I'd try Elixir. You can learn most of the language in a few days and be experimenting with BEAM and supervision concepts basically on day one. As a learning exercise I think its worth peoples' time because actors/processes are one of the concurrency models you don't see everywhere but solve interesting problems well.

▲▼ lpil14:57 hn>

I don't think that's the case, Rust and Gleam have almost nothing in common beyond having static type systems, and those type systems are very different too.

https://gleam.run/frequently-asked-questions/#How-does-Gleam...

─ 13 more ─
▲▼ ryan-duve16:12 hn>

I just learned Erlang this year and I love the syntax. Ending expressions with periods took getting used to, but capital first letters distinguishing variables, non-rebindable variables, semicolons between function clauses, a lack of boilerplate (defmodule et al), a fraction of end keywords, commas separating expression, ... all make for a very fun to use and ergonomic language, IMO.

I haven't tried Gleam yet, though. I'm interested in the focus on simplicity but a little wary because I understand they sacrificed niceties to minimize the language footprint, e.g., pattern matching in function heads. I intend to give it a shot the next time I'm greenfielding something.

▲▼ SoftTalker18:43 hn>

I'm the same. I thought I was an oddball because so many people seemed to prefer Elixir but I like Erlang and its syntax. I wish I had more chances to use it at work but so far it's just been for hobby projects or playing with.

▲▼ macintux19:41 hn>

I was fortunate enough to use Erlang professionally for a couple of years. I agree: the syntax is quite comfortable.

▲▼ mahboi19:41 hn>

Erlang is my favorite functional language out of all the ones I've tried. The matchers, guards, etc are all done very well. But I don't like functional. I used to think it was cool, gave it a real chance using Erlang for years, and eventually decided it's not a good fit for many use cases. Like at some point the neatness of doing all loops as recursion wears off and it's just tiring. It's not like CS algo homework, and even there you often want DP/memoization.

▲▼ olexsmir15:37 hn>

I love seeing how gleam gets better and better with every release, sadly I dont have any projects where I could use gleam :(

▲▼ capitanazo7716:10 hn>

When will they change their image to not look like girl toys?

Imagine a doctor about to do surgery and opening a toy box

▲▼ omnimus16:13 hn>

It's not surgery is it. It's programming language and their maintainers like it.

▲▼ atollk16:14 hn>

I have never seen a software developer be insecure about their manhood because of the programming language they use. This is equal parts funny and sad.

▲▼ hinkley18:57 hn>

I’m old enough to remember VB developers so unfortunately cannot concur.

▲▼ throwaway2744816:14 hn>

I'm struggling to imagine how this even comes up.

▲▼ ginkogruen16:27 hn>

Imagine your doctor is about to begin surgery and walks in with a camel, a crab and a gopher.

▲▼ hinkley18:58 hn>

And a weird little guy who looks like an artist’s eraser.

▲▼ tiffanyh16:53 hn>

The title is a bit misleading because one might imply that Gleam no longer compiles to something Erlang can use (not true).

From the article:

>Over the last few months Giacomo Cavalieri has entirely rewritten Gleam's Erlang code generator that has an entirely different design, and most notably, outputs a different format. Previously Gleam generated Erlang source code, now it generates Erlang abstract forms.
▲▼ lpil17:21 hn>

The title says it no longer compiles to Erlang source. That's true, it now compiles to an IR of the Erlang compiler.

▲▼ PKop17:26 hn>
>"Transpiler" means a compiler that outputs a human-readable format, such as source code. It's a cool sounding word, but most the time people use it to imply that a given compiler is in some way inferior. This is very silly, as there is nothing about compiling to a human-readable format that makes a compiler easier to implement.

Ok but this footnote comes at the end of a paragraph describing how the previous transpiler implementation was inferior to the new compiler. It's ok to make these distinctions.

▲▼ tasuki19:19 hn>

...and many other improvements!

I was surprised to find Matt Mullenweg among the sponsors.