6 ms·
Gleam v1.12
- Alupis 1y agoSome highlights from this release are listed here[1]. The best part of Gleam in my opinion is the language's design. It's just so elegant to read and write. Take this example code snippet from the release notes: pub fn find_book() -> Result(Book, LibraryError) { case ask_for_isbn() { Error(error) -> Error(error) Ok(isbn) -> load_book(isbn) } } It's a trivial code snippet, but I'm finding this kind of "first class" pattern matching produces very readable, elegant-looking, well organized code. There was a discussion the other day about the pipe operator being added to PHP 8.x. Gleam was my first language which included a pipe operator. Now, having used it a bit, I feel every language should have something like it. pub fn hello_test() { telephone.ring() |> should.equal("Hello, Joe!") } The pipe skips so much boilerplate and clearly communicates intent. Absolutely love it. [1] https://gleam.run/news/no-more-dependency-management-headaches/ https://gleam.run/news/no-more-dependency-management-headach...
- steve_adams_86 1y agoI'm so envious of this. In TypeScript I use ts-pattern and Effect Schema, and while they make this logic way nicer, it's insanely verbose and doesn't offer any of the niceties of being first class.
- Alupis 1y agoI have not used it at all, but Gleam does have a javascript target in it's compiler/build-tool. So in theory, you can write Gleam (strongly typed, etc) and produce js. I've exclusively used the BEAM/Erlang target so far - but the js community within Gleam seems quite interesting.
- steve_adams_86 1y agoI've been considering trying this, but my team already struggles to properly adopt TypeScript so I'm fairly sure introducing Gleam would cause a few people to throw me out a window.
- giraffe_lady 1y agoGleam is so much smaller and easier than typescript and the type system works harder for what it is. TS gets you because it is similar to javascript in some ways that make it easier to start the transition. But a complete js -> ts transition is about as big a deal as it would be from js to any other language, except you can use the same external libraries.
- anon3459 1y agoNo just no
- giraffe_lady 1y agoSorry but yes. Pure structural typing is a dead end hindley milner is the future.
- fpauser 1y ago;)
- giacomocava 1y agoOmg yes, pattern matching is such an amazing feature I miss it dearly in languages that don't have it!
- ZpJuUuNaQ5 1y ago>It's just so elegant to read and write. Interesting. I was just about to write the opposite. I tried Gleam to solve last year's Advent of Code, and it felt like a weird mix between Rust and Elixir. You can't write code as elegantly as you'd do in Elixir, which was somewhat disappointing. I switched back to Elixir after a couple of days. I think the biggest advantage of Gleam is static type system.
- lpil 1y agoIf you've examples of code you have in Elixir that you could not express well in Gleam I would be very happy to help you out with that. The two languages are almost the same at the value level, so code should translate across well.
- Alupis 1y agoDepending when this was, it was likely pre-1.x days? Things moved very quickly there for a while - it's worth checking back in again. Gleam seems to have a lot of obvious influences from Rust, and the creator is a rust dev. While the Gleam ecosystem is vastly less mature than Elixir's or Rust's (because it's literally younger), the language itself, I've found, is vastly more pleasant to read/write. YMMV of course.
- lpil 1y ago> Gleam seems to have a lot of obvious influences from Rust, and the creator is a rust dev. Hi! That's me! Gleam the language doesn't have any Rust influence really. It's a happy accident that some of the syntax ended up looking the same, but that's likely due to both being inspired by similar languages such as OCaml and the C family. Most the syntax and the semantics predate Gleam's compiler being rewritten in Rust. The build tool is a rip-off of Cargo for sure though.
- Alupis 1y ago> The build tool is a rip-off of Cargo for sure though. Hey, great artists steal, as the saying goes... It's all shaped up really nice. I'm a big fan of Gleam and your work in general.
- thijsvandien 1y agoError(error) -> Error(error) has strong if err != nil { return err; } vibes, and I don't consider that a good thing.
- Alupis 1y agoThis is a trivial snippet. Often you will transform/map your error into another type (or deal with it in some way), so it's not so much `if err != nil { return err; }` vibes like you're thinking here. The beauty here is being compelled to handle both the happy and sad paths. You cannot just pretend the sad path doesn't exist.
- samdoesnothing 1y agoGood Go code also wraps errors...
- wavemode 1y agoIt's not just about wrapping. use-expressions, result.try and result.map eliminate the boilerplate of checking for errors entirely: https://erikarow.land/notes/using-use-gleam https://erikarow.land/notes/using-use-gleam
- samdoesnothing 1y agoOne man's boilerplate is another man's explicitness.
- debugnik 1y agoThat's what Gleam's use expressions[1] are for (the last example is exactly this case). Most languages with the same heritage as Gleam have grown a similar syntactical feature, such as OCaml's binding operators or F#'s computation expressions. Although I appreciate how simple Gleam's is while having similar power. [1]: https://gleam.run/news/v0.25-introducing-use-expressions/ https://gleam.run/news/v0.25-introducing-use-expressions/
- 1y ago
- no_wizard 1y agosnake case convention is the only thing that always feels odd to me. Perhaps its because I deal in TypeScript all day, every day, but it never stuck with me. That said, small price to pay for a very nice runtime!
- Alupis 1y agoI come from a background where everything is camelCase. Naturally I wrote my JSON this way as well, among other things. Switching to snake_case was challenging at first - I kept writing things in camelCase. Now, I've become pretty fond of snake_case and have a tough time going back into environments that require camelCase - funny thing, that is. Thankfully Gleam's build tool/language server has a fairly strongly opinionated formatter built in, so it will let you know pretty quickly and help you fix it.
- zelphirkalt 1y agoOne thing I disliked is black, the Python formatter, with its utterly naive rules, that treat all code the same. It required me to workaround in many places, like always using a trailing comma for any list or tuple, to keep the items on separate lines, instead of black fumbling around and putting them on the same line. It was utterly annoying. This made me very vary of "opinionated" (read: inflexible unconfigurable pieces of software) formatters. Hopefully Gleam's formatter isn't as stupid as black is.
- __jonas 1y agoI come from js/ts as well and I find snake case much more readable than camel after using it in other languages for a bit. There are even js/ts projects that use snake case despite the camel case convention, for readability https://github.com/sveltejs/svelte/issues/3479#issuecomment-526676597 https://github.com/sveltejs/svelte/issues/3479#issuecomment-...
- plainOldText 1y agoYeah, CamelCase for modules, snake_case for functions and variables. Your brain can instantly tell what entity you’re dealing with.
- ASalazarMX 1y agoThe official website has an interesting footer > As a community, we want to be friendly too. People from around the world, of all backgrounds, genders, and experience levels are welcome and respected equally. See our community code of conduct for more. Black lives matter. Trans rights are human rights. No nazi bullsh*t. On one hand I applaud that their community standards are inclusive, but on the other hand, it shouldn't be that blatantly ideological from the get go. It's just another programming language, not a political platform.
- SwiftyBug 1y agoThe Gleam community has been the best, most welcoming community I've ever seen on the internet. And I've been a around for a while. I attribute this in part to their clear stance.
- steve_adams_86 1y agoI was welcomed too, and strongly encouraged to contribute. It was really nice. Though the signals might appear abrasive to some, it doesn't represent an abrasive group of people at all.
- Alupis 1y agoJoining their Discord and getting greeted by the language creator himself within a few minutes was pretty cool. Most other languages, their creators/maintainers seem so unapproachable and distant. You can talk directly with the core team on there, ask questions, etc. Louis really has built a pretty fun community around Gleam.
- batisteo 1y agoThe good thing is, you don't have to be tolerant with the intolerant. And that's exactly what they are advertising. It let the nice people flow in, as you experienced.
- steve_adams_86 1y agoI used to be on the fence with this, finding the ideology-forward attitude fairly abrasive. I've since decided that while I don't love it, I see the perceived necessity of it that some people have. I enjoy the privilege of living somewhere and being a person who no one cares to cause problems for. Some people don't have that experience, and are targeted routinely and unfairly. I see it like they put up these barriers and deterrences because they need to, not just that they want to. People who support them participate in that endeavour because it matters enough. For guys like me, it seems like a needless distraction from what matters. Unless I consider living a life in which there are people who don't want me to exist, or something. Then yeah, I might throw up a few "please fuck off" signs, I don't know.
- brightball 1y agoGreat talk on Gleam from August last year. https://youtu.be/vyEWc0-kbkw https://youtu.be/vyEWc0-kbkw
- okkdev 1y agoThe link should probably point to the excellent 1.12.0 post on the website: https://gleam.run/news/no-more-dependency-management-headaches/ https://gleam.run/news/no-more-dependency-management-headach...
- mistahchris 1y agoI really like gleam. I have a few unfinished side projects in gleam with about 10k lines of code, so I've had enough of a taste to know I like it. I can't wait to see how it matures. I plan to write more gleam in the future. I am particularly excited about the possibilities of sharing more code between webapp frontends and backends. Gleam has so much potential and is already quite productive. I am not that online of a person. But I joined the discord to say hi and ask a few questions and I have to say the community really does have great vibes. If I were spending more time online, I would likely bias to spending it in the gleam community. They're a bunch of very friendly, and smart people working on a wide variety of interesting projects.
- ninetyninenine 1y agoI tried to make a c-compiler in gleam. One thing I really didn't like is the lack of interfaces/type-classes and lack of composition operator.
- Alupis 1y agoGleam has a note regarding type-classes on their website[1]. The language itself seems to aim to remain simple - which is a pretty good thing in my opinion. [1] https://gleam.run/frequently-asked-questions/#will-gleam-have-type-classes https://gleam.run/frequently-asked-questions/#will-gleam-hav...
- ninetyninenine 1y agoI don’t like it. Makes it feel like golang it’s like they want to keep it simple so they remove something fundamental. Golang says the same shit in their faq and there’s a whole slew of people who gave golang so much shit for it. Especially the fp community. Golang for the longest time had no generics. Now it doesn’t have sum types. When you try to build something truly complex like a compiler, you’ll see the abstractions start to screw up because can’t use interfaces in gleam.
- kamilap 1y agovideo walkthrough for v1.12 from a core team member: https://www.youtube.com/watch?v=KYvydMeTpzQ https://www.youtube.com/watch?v=KYvydMeTpzQ