logoalt Hacker News

Gleam: A Basic Introduction

126 pointsby Alupis10/11/202468 commentsview on HN

Comments

cedws10/11/2024

I've been interested in Gleam, but I didn't realise it just transpiles to Erlang, I thought it compiled directly to BEAM bytecode. Bit of a turnoff to be honest, I really don't want to deal with transpilation.

show 6 replies
drdaeman10/12/2024

One niche feature of Erlang that I love is live module upgrades, particularly via gen_server's code_change/3 callback. It's a neat little trick that seems to be rarely used in practice, but every single time I've used it I just loved how everything simply clicked together, providing zero disruption with nearly minimal effort (for simple state upgrades or downgrades).

I wonder if it's supported with Gleam and/or gleam_otp? Don't see it in the docs.

show 2 replies
systems10/11/2024

the gleam tour is also very good https://tour.gleam.run/

very very good

show 1 reply
jeremy_k10/12/2024

Gleam has been great as I've started messing around with it recently. Coming from primarily Ruby, it feels much different and I'm liking expanding my thought process around programming. I'm struggling a bit with learning how to think in the type system though. Without unions and a requirement that case statements all return a single type, I just haven't quite grasped the right pattern to make it all click. Enjoying the process none the less.

floodfx10/12/2024

I like the look of Gleam over Elixir for sure. I’d love to see some example code showing Gleam-based LiveViews but I haven’t been able to find it anywhere. Is it possible? Anyone have some code to point me at?

show 2 replies
asplake10/12/2024

“Gleam is a statically-typed language, meaning you must declare the type of a variable before using it.”

That second part is wrong. Gleam has type inference.

show 1 reply
written-beyond10/11/2024

I honestly gave gleam a serious look, considering it to build a system that might really benefit from it's concurrency model. However the lack of Macros/macro-style reflection capabilities really put me off. It makes working with SQL databases needlessly verbose. It's the same with go, though go posses the capabilities to directly unmarshal SQL rows into a structure with tags, it's far from straightforward.

show 3 replies
vivzkestrel10/12/2024

golang concurrency vs gleam concurrency vs rust concurrency? for a webserver?

rixed10/12/2024

> Gleam is a statically-typed language, meaning you must declare the type of a variable before using it.

What year is this from?

show 1 reply
pipeline_peak10/12/2024

> fn add(x: Int, y: Int) -> Int

Why do language authors insist the majority of programmers want to type this way? Meaningless arrows and redundant colons.

Is it constructive, like it will lead us to think differently? It feels more like a contest in overcomplicating something as innocent as:

int add(int x, int y)

show 5 replies
oldpersonintx10/12/2024

[dead]