Live data from Hacker News

The Gleam Programming Language

gleam.run

111–120 of 189 posts

Re: The Gleam Programming Language

#111
I’m trying Gleam out right now, and having most recently been writing Go, I’m really loving: - No nil, instead Option and Result - ADTs - Pattern matching + destructuring - Immutable everything by default - `use` syntactic sugar (weird at first, but once you’re used to it it’s pretty elegant) - LSP server works great for such a young language

But most of all I think the overall simplicity of the language is really what’s standing out to me. So far I think the lack of ad-hoc poly and macros are a plus - it really reduces the impulse to write “magical” code, or code with lots of indirections. In the past I’ve definitely been guilty of over-abstracting things, and I’m really trying to keep things as simple as possible now. Though I’ve yet to try Gleam with a large project - maybe I’ll miss the abstractions as project complexity increases.

I suspect Gleam will be a great language for small to medium sized projects written with LLM assistance (NOT vibecoded) - the small language, strong typing and immutability gives good guardrails for LLM-generated code, and encourages a simple, direct style of programming where a human programmer can keep the whole structure in their head. Letting an LLM run free and not understanding what it’s written is I think where projects run into big problems.

Re: The Gleam Programming Language

#112
post #73

Earlier quoted context omitted.

This is the same as Elixir, you need to specify what Erlang function to use in that language if you want to use Erlang code. The only difference is that Gleam has a more verbose syntax for it.

In Elixir you just call the Erlang function directly. It's basically the same as calling an Elixir function, just with a different naming convention. In Gleam, you first have to declare the function type and THEN you can call the function directly. This is probably the lightest way you can bridge between statically and dynamically typed languages, but it's not the same as Elixir.

Sorry, I've been unclear.

The runtime behaviour and cost of calling an Erlang function is the same in Elixir and Gleam, however the syntax is more verbose in Gleam as it asks for type information, while in Elixir this is optional.

Re: The Gleam Programming Language

#114
post #81

One of the best things about erlang/elixir is the repl driven development/manual testing. Gleam has no `interpreted` story, right? Something like clojure, common lisp, etc. I think this matters because debugging on beam is not THAT great, there are tools in erlang/elixir to facilitate debugging, like inspect() or dbg(). If anyone has experience in this language, what is the mindset with gleam? How you guys debug?

> If anyone has experience in this language, what is the mindset with gleam? How you guys debug? There is the echo keyword now, which is comparable to elixir's dbg(), I use that a lot. Lacking a REPL, what I normally do is make a dev module, like 'dev/playground.gleam' where I'm testing things out (this is something that the gleam compiler supports, /dev is similar to /test) and then run it with 'gleam run -m playgro…

Cool, thanks! I really like Erlang syntax, will try that in the afternoon.

Re: The Gleam Programming Language

#115
post #61

Earlier quoted context omitted.

Raku looks sweet, but what is the point of this comparison? :)

I love coding in Raku - and I am sure that Gleam is nice too. But I get the feeling that Raku is underappreciated / dismissed by many due to the perl5 / perl6 history. So my thinking is, when I see a new language showcase an example on their website, presumably a carefully chosen snippet that showcases their language at its best, I like to see how Raku compares to that. You know the take-aways from the comparison are…

I think comparing 'printing hello world' programs isn't particularly useful, except that from how you describe it, Raku sounds more like a scripting language, which Gleam is not.

In comparison with Gleam, I would be more interested to see how good Raku is at helping the programmer prevent errors through static analysis, how easy it is to build with concurrency, how much value the language puts into being easy to understand and reason about, and whether it can run on the server as well as compile to JS.

I have no negative predisposition, I don't really care about the history of pearl or whatever, I have looked at Raku before but I find the syntax very foreign, and the fact that it seems to (maybe optionally?) incorporate glyphs that I can't easily type with a keyboard.

I love the butterfly though, so I'd love to get to know the language more.

Re: The Gleam Programming Language

#116
post #86

thought I’d try the showcase example in Raku ( https://raku.org ), so this Gleam import gleam/io pub fn main() { io.println("hello, friend!") } becomes this Raku say “hello, friend!” well maybe you really want to have a main() so you can pass in name from the command line #!/usr/bin/env raku sub MAIN($name) { say "hello, $name!” }

Oh God, they actually put that awful logo front and center. I'd always thought it would be a go-like thing where the put the mascot away for everything except for the minor hero section or buried in the footer. RIP Perl.

lol - I had the temerity to raise the "how about a new logo" topic last week and it's going to time time for me to (hopefully) convince the community of the need to let go

Re: The Gleam Programming Language

#117

I’m trying Gleam out right now, and having most recently been writing Go, I’m really loving: - No nil, instead Option and Result - ADTs - Pattern matching + destructuring - Immutable everything by default - `use` syntactic sugar (weird at first, but once you’re used to it it’s pretty elegant) - LSP server works great for such a young language But most of all I think the overall simplicity of the language is really wh…

The use <- syntax is even more crazy when you realize that it's a programmer-friendly way of doing continuation-passing style.

Re: The Gleam Programming Language

#118
I am really interested in whether anyone has evaluated the performance of Gleam? The language is simple, easy to understand, like `Go` for example, but is it really performant like Go, or does it have any performance cost since it runs on top of a VM?

Re: The Gleam Programming Language

#119

I am really interested in whether anyone has evaluated the performance of Gleam? The language is simple, easy to understand, like `Go` for example, but is it really performant like Go, or does it have any performance cost since it runs on top of a VM?

I would look at benchmarks for Erlang and Elixir to get a rough idea of how Gleam performs at runtime. It's faster than Python generally, but not by a lot. It's for this reason that I really wish Gleam had a LLVM or Golang backend instead of JS / BEAM.

Here's some webserver benchmarks that cover a handful of popular languages: https://stressgrid.com/blog/webserver_benchmark/

I believe BEAM got a JIT compiler built into the runtime not too long ago (after that post, iirc), so it might perform a bit better now.

Re: The Gleam Programming Language

#120
post #108

Earlier quoted context omitted.

I love coding in Raku - and I am sure that Gleam is nice too. But I get the feeling that Raku is underappreciated / dismissed by many due to the perl5 / perl6 history. So my thinking is, when I see a new language showcase an example on their website, presumably a carefully chosen snippet that showcases their language at its best, I like to see how Raku compares to that. You know the take-aways from the comparison are…

> But I get the feeling that Raku is underappreciated / dismissed by many due to the perl5 / perl6 history. Yes that would be me! If you like making these comparisons, can you write the following pattern matching in Raku? import gleam/io pub type Fish { Starfish(name: String, favourite_colour: String) Jellyfish(name: String, jiggly: Bool) } pub fn main() { handle_fish(Starfish("Lucy", "Pink")) } fn handle_fish(fish:…

sure...

  role Fish { has Str $.name }

  class Starfish  does Fish { has Str $.favourite-colour; }
  class Jellyfish does Fish { has Bool $.jiggly }

  sub handle-fish(Fish $fish) {
    given $fish {
      when Starfish  { say .favourite-colour }
      when Jellyfish { say .name }
    }   
  }

  handle-fish Starfish.new: :name("Lucy"), :favourite-colour("Pink");
I would probably reach for multi-dispatch...

  role Fish { has Str $.name }

  class Starfish  does Fish { has Str $.favourite-colour; }
  class Jellyfish does Fish { has Bool $.jiggly }

  multi sub handle-fish(Starfish  $fish) { say $fish.favourite-colour }
  multi sub handle-fish(Jellyfish $fish) { say $fish.name }

  handle-fish Starfish.new: :name("Lucy"), :favourite-colour("Pink");
Post reply on HN