34 ms·
Gleam: a type safe language on the Erlang VM
- singularity2001 3y agorelated: what is the state of the Erlang VM in Wasm?
- dang 3y agoRelated: Things I like about Gleam's Syntax - https://news.ycombinator.com/item?id=38031342 https://news.ycombinator.com/item?id=38031342 - Oct 2023 (54 comments) Gleam v0.29 – Gleam gets autocompletion - https://news.ycombinator.com/item?id=36044484 https://news.ycombinator.com/item?id=36044484 - May 2023 (1 comment) V0.28 released of Gleam, a type safe Erlang-family language - https://news.ycombinator.com/item?id=35425855 https://news.ycombinator.com/item?id=35425855 - April 2023 (4 comments) Gleam v0.25 – Introducing use expressions - https://news.ycombinator.com/item?id=33731871 https://news.ycombinator.com/item?id=33731871 - Nov 2022 (4 comments) The Gleam Language Server - https://news.ycombinator.com/item?id=31143792 https://news.ycombinator.com/item?id=31143792 - April 2022 (1 comment) Gleam v0.18 Released (gleam language on the erlang vm) - https://news.ycombinator.com/item?id=29464307 https://news.ycombinator.com/item?id=29464307 - Dec 2021 (1 comment) Gleam 0.16 compiles to JavaScript - https://news.ycombinator.com/item?id=27538919 https://news.ycombinator.com/item?id=27538919 - June 2021 (24 comments) Gleam 0.15 - https://news.ycombinator.com/item?id=27061500 https://news.ycombinator.com/item?id=27061500 - May 2021 (78 comments) Phantom Types in Gleam - https://news.ycombinator.com/item?id=26284976 https://news.ycombinator.com/item?id=26284976 - Feb 2021 (11 comments) Gleam 0.14 – Type-safe language for the Erlang VM - https://news.ycombinator.com/item?id=26185690 https://news.ycombinator.com/item?id=26185690 - Feb 2021 (51 comments) Lean HTTP Server for Gleam - https://news.ycombinator.com/item?id=24265936 https://news.ycombinator.com/item?id=24265936 - Aug 2020 (5 comments) V0.10 of Gleam, a statically typed language for the Erlang VM, is out - https://news.ycombinator.com/item?id=23706211 https://news.ycombinator.com/item?id=23706211 - July 2020 (1 comment) Gleam: A statically typed language for the Erlang VM - https://news.ycombinator.com/item?id=22902462 https://news.ycombinator.com/item?id=22902462 - April 2020 (109 comments) Hello, Gleam - https://news.ycombinator.com/item?id=19686413 https://news.ycombinator.com/item?id=19686413 - April 2019 (1 comment) An interview with the creator of Gleam: an ML like language for the Erlang VM - https://news.ycombinator.com/item?id=19547418 https://news.ycombinator.com/item?id=19547418 - April 2019 (0 comments)
- bcardarella 3y agoGleam is awesome
- m8s 3y agoIt really is. A typed BEAM language (that also compiles to Javascript), a fantastic community, and a growing ecosystem. I’m really excited for the future of Gleam!
- christophilus 3y agoLooks decent. I somehow missed the previous thousand discussions. I’d love to hear from anyone running it in production. I have always been BEAM-curious, but never felt comfortable running it in production, as it feels like a big black box, and I’m not confident that I’d be able to diagnose problems as readily as I can in .NET, Go, or Node. I’m not sure why I feel that way about BEAM.
- dudul 3y agoI'm not sure either why you feel that way. The BEAM has amazing tools to debug at runtime and explore/modify your system while it's running. Yeah you'd need to learn it, but it's like any other tool.
- avtar 3y agoSome comments about the prospect of using Phoenix with Gleam: https://news.ycombinator.com/item?id=38037082 https://news.ycombinator.com/item?id=38037082
- chii 3y ago> I’m not sure why I feel that way about BEAM. unfamiliarity? Plus the problem of 'nobody ever got fired for running IBM' plaguing your work.
- bmitc 3y agoI think it might actually be easier to inspect the BEAM over those other VMs. For one, it is much older and stable. And secondly, the BEAM has a lot of self-introspection features. I highly recommend the talk The Soul of Erlang and Elixir by Sasa Juric which shows off the essence of the BEAM. https://youtu.be/JvBT4XBdoUE https://youtu.be/JvBT4XBdoUE
- cpursley 3y agoDefinitely way easier than tracing Node for any type of async exceptions.
- 3y ago
- dudul 3y ago[flagged]
- rkangel 3y agoIt's some way down, in a section about community. An important recent learning about programming adoption is that a good community is absolutely key to drive growth. Makes sense to establish the principles.
- jrsj 3y agothis has nothing to do with community or even inclusivity and everything to do with signaling political allegiance & telling people who don’t agree that they aren’t welcome It is quite literally the opposite of what you and others supporting this are claiming it to be All you have to do is remove the weird bit about “nazis”, which is irrelevant and adds nothing of value to the statement anyways, and you’re not really going to scare any normal person off. But this is just over the top and literally the only purpose it could serve is as an exclusionary political signal.
- pvg 3y agowho don’t agree Who are the excluded people here and what do they not agree with?
- jrsj 3y agoCasually using “Nazi” like this in context of American politics just means “anyone to the right of me” it’s ambiguous but the implications are clear If you are a Christian, someone who would use this phrase would likely call you a Nazi. If you don’t want to abolish the state of Israel, they might call you a Nazi. It could be any issue really. But to actually be “safe” in an environment like this you have to align yourself roughly to the politics of the DSA or you aren’t welcome. I guess you could say at this point that “Nazi” has devolved into being a sort of a political slur referring to anyone who is not sufficiently leftist.
- tines 3y agoCan anyone comment on Gleam's type system? Is it similar to Haskell's?
- turboponyy 3y agoNo, it is not. It has no plans to introduce type classes and allows for impure (effectful) functions. It is perhaps most similar to OCaml.
- Jeff_Brown 3y agoHaskell's is much deeper but Gleam gives you algebraic types, generics and type aliases. I believe Gleam offers deeper pattern-matching facilities. That is of course not the type system, but feels closely related to me.
- CooCooCaCha 3y agoI really hope gleam takes off. We need more typed scripting options.
- bmitc 3y agoYou could use F# for that purpose.
- cpursley 3y agoDoes F# compile to distributed Erlang?
- sshine 3y agoNot practically. There are some one-person attempts at compilers from F#/OCaml to BEAM, but they haven’t seen an update for some years.
- Conscat 3y agoCaramel is a very similar language (ML dialect) that builds for BEAM. https://caramel.run/ https://caramel.run/
- yashrk 3y agoNo updates on GitHub since Aug 2022. Isn't it abandoned? Supported and battle-tested OCaml or StandardML for BEAM would be great, of course. I'm waiting for something like this for years.
- CooCooCaCha 3y agoI want something more like rust or typescript. Not Haskell.
- bmitc 3y agoThen F# it is. :) Rust was partially inspired by F# and OCaml and actually had a much more ML-like syntax early on. Probably something similar goes for Typescript. And actually, the same for Gleam as well. F# doesn't really relate to Haskell at all. They are very different languages. F# is a multiparadigm language that easily supports concise code in the imperative, OOP, and functional styles. It sounds like you maybe don't know much about F# if you think it's like Haskell, which is okay. But that's also why I would recommend checking it out.
- alilleybrinker 3y agoGleam is written in Rust and is a nice example (besides Rust itself) of what it looks like to write a language in Rust. By my own tracking (https://github.com/alilleybrinker/langs-in-rust https://github.com/alilleybrinker/langs-in-rust) Gleam is one of the most popular languages written in Rust and is one of the few top languages in that list which isn't a reimplementation of an existing language!
- saghm 3y agoI feel like making programming languages is an area where Rust can really make use of its advantages without the commonly cited pitfalls. You won't be dealing with any I/O other than filesystem APIs (outside of making a standard library or something), so you can entirely avoid needing to decide whether to use async or not, and you can go pretty far just using value types and copying without it being a likely performance bottleneck. Most languages won't use much concurrency in their compiler either; Rust itself parallelizes builds per crate with Cargo, which invokes rustc separately for each compilation unit. I'm sure some people might read all this and conclude that they might as well just use OCaml or Haskell, and those are really good languages for compilers too! The tooling and ecosystem make Rust more appealing to me personally though, and I suspect that there are probably others who would find Rust's ecosystem a bit more approachable as well.
- sitkack 3y agoModern compiler tooling that supports IDEs are almost all incremental, so all that async machinery and multithreading can be put to use there as well.
- cmrdporcupine 3y agoI think Haskell or OCaml would do a better job on the ADTs for a parse tree. When doing this, I found Rust's enums... anemic... and got very annoyed by the awkwardness of having to Box recursive types. I was reaching for the ability to continue to be able to pattern match on nodes while attaching common attributes (line numbers, etc.) and ended up having to bury everything 1 level deep in a struct which ended up feeling awkward. That and Rust's iterators are terrible at introducing ownership agony. In any case, I've ... done it (https://github.com/rdaum/moor/blob/main/crates/compiler/src/parse.rs https://github.com/rdaum/moor/blob/main/crates/compiler/src/...) but can't say I liked it. I do really like "pest" as a parser generator though. In general, yes, the Rust ecosystem is bigger/richer, and growing.
- lkjaldfwltjohw 3y agoAt a glance the type system is quite barebones and nominative. I'd like to see Gleam add support for structural types and maybe set theoretic [1] [1] https://arxiv.org/abs/2302.12783 https://arxiv.org/abs/2302.12783
- m8s 3y agoFor what purpose? Is Gleam today unable to do things you’d like to be able to do?
- andrewstuart 3y agoI know a company that has built their entire technology stack on some Erlang VM based language. There was really no reason to do so at all - it's an ordinary company building an ordinary application. But some CTO or dev lead years ago thought it important to use whatever the fancy tech of the day was to build a fairly ordinary business application. But now they have trouble hiring people because there's a tiny pool of people who know that language. And it is years down the track and all their technology is built with whatever that language/framework is - too expensive to easily bail out, but probably necessary anyway. In 2023 you've got to have really good reasons for not using C#, or Java, or Python, or TypeScript for building your web project. Maybe Golang - it's getting some good traction in the DevOps space. If you make decisions about technologies and this latest thing appeals to you - maybe use it for your personal projects. The CEO has employed you to make responsible decisions not play toys.
- siwatanejo 3y agoI hire based on ability/intelligence, not knowledge.
- andrewstuart 3y ago>> I hire based on ability/intelligence, not knowledge. Well, yeah that's really your only choice if the experience you need is not easily available. Don't tell me, you are the guy who puts in the not mainstream technology and needs to defend that with justifications such as "when we use (non mainstream technology X) we get super motivated job applicants because anyone with an interest in non mainstream technologies is inherently passionate and interested". That's not a sound hiring strategy.
- inopinatus 3y agoAnd you are the guy who left Visual Basic, COBOL, Perl, and FORTRAN off their "obviously safe choices for hiring in the future" list, despite them all having once been perceived as such. These inconvenient counterexamples blow up the entire thesis. In practice, the "safe choice" for longevity is only evident in hindsight. If anyone is hiring for TypeScript in 2050 I'll eat my hat
- pmontra 3y agoI browsed the docs and found no mention of OTP. I might have missed it but it would be strange to have a language on BEAM with no native interface to those modules. I looked for examples of supervision trees and gen servers.
- Ndymium 3y agoOTP is a work in progress available in the gleam_otp [0] package, supplemented with the lower level gleam_erlang [1]. Or you can call OTP things manually with FFI. [0] https://hexdocs.pm/gleam_otp/index.html https://hexdocs.pm/gleam_otp/index.html [1] https://hexdocs.pm/gleam_erlang/index.html https://hexdocs.pm/gleam_erlang/index.html
- ungamedplayer 3y agohttps://github.com/wmealing/gleam-otp-design-principals/blob/main/gleam-otp-design-principals.org https://github.com/wmealing/gleam-otp-design-principals/blob... This is what I wrote regarding using otp in gleam. One of the issues I'm working on next is to send typed messages to processes, which has me a little stumped. At the moment the typed channels work, you can't register () a channel or a pid. I will likely continue working on this document once I have my current project completed.
- kimi 3y agoThey seem to have rewritten/wrapped OTP, but it's not production ready. https://github.com/gleam-lang/otp https://github.com/gleam-lang/otp YMMV, but a BEAM language without OTP severely limits its appeal and usability.
- MarkMarine 3y agoThis hits the mark for me, good type system, backed by Erlang and BEAM, access to Phoenix live view, but doesn’t have (imho Terrible) ruby syntax
- whitepoplar 3y agoAs someone who loves ruby syntax, I'd be very interested to hear which parts of it you don't like.
- philwelch 3y agoI haven’t used Elixir but I used Ruby as my main programming language for a few years and my biggest complaint with Ruby syntax is decision fatigue. There’s almost never a single clear and obvious way to do something. Overall I find Ruby syntax to prioritize cutesy aesthetics over practicality.
- tokamak-teapot 3y agoIf you use Elixir for a while you may find that there is a lot more consistency, and almost no ‘cutesy’ code around. Elixir’s syntax only looks a little like Ruby at first glance.
- arrowsmith 3y agoYeah, as a seasoned Ruby dev I found the "similarities" between Elixir and Ruby to be surface-level. They're very different languages. Even the syntax isn't that similar once you get past your first impression. But don't listen to me - take it from none other than José Valim, Elixir's creator: > Folks tend to understate the influence of Erlang and overstate the influence of Ruby on Elixir. … Ruby did influence the syntax and the names in the standard library, but the latter was also done in a more "democratic" fashion: I would look into Ruby, JavaScript, Clojure, Haskell, and choose a name that was common and closer reflected the semantics that would fit Elixir (for example, the term "protocol" come from Clojure). https://news.ycombinator.com/item?id=36604054 https://news.ycombinator.com/item?id=36604054
- xixixao 3y agoI'm really impressed by the syntax. I have yet to find a piece of syntax I wouldn't like. Labelled arguments for example are delightful: pub fn replace( in string: String, each pattern: String, with replacement: String, ) { // The variables `string`, `pattern`, and `replacement` are in scope here } replace(in: "A,B,C", each: ",", with: " ")
- hota_mazi 3y agoFYI Swift did this years ago.
- wiml 3y agoSwift probably did it for ObjC compatibility, and ObjC got it from Smalltalk.
- 698969 3y agoThe only part that rubs me the wrong way is, > The pipe operator will first check to see if the left hand value could be used as the first argument to the call, e.g. a |> b(1, 2) would become b(a, 1, 2). Optimizing for one less _ typed is a really bad trade-off in terms of clarity here.
- xixixao 3y agoI actually agree, this is the most questionable piece. I prefer (and have argued for in JS) Hack-style pipes, where the value "placement" always has to be specified. That allows arbitrary expressions on the RHS of the pipe, so for example this would be valid Gleam: pub fn main() { io.println( "Hello" |> (_ <> " world") ) }
- pharmakom 3y agoGleam has curried functions by default so F# style pipes make sense imo.
- rbjorklin 3y agoIf this piqued your interest you might also be interested in: https://github.com/leostera/riot https://github.com/leostera/riot
- m2lb2912 3y agoGleam is looking to be a nice alternative to Rescript. The docs are a little sparse on this (being initially focused on BEAM), but the discord & community is very helpful which makes up for it. It's a very neat and well thought out language.
- fbn79 3y agoI was wondering if it's Hindely-Milner, and yes it is according to this interview: https://blog.lambdaclass.com/an-interview-with-the-creator-of-gleam-an-ml-like-language-for-the-erlang-vm-with-a-compiler/#:~:text=What%20kind%20of,in%20Erlang/Elixir https://blog.lambdaclass.com/an-interview-with-the-creator-o....
- ecmascript 3y ago> People from around the world, of all backgrounds, genders, and experience levels are welcome and respected equally. Except that if you don't agree with the authors political opinions: > Black lives matter. Trans rights are human rights. No nazi bullsh*t. Yet another project run by people who shoves politics into unnecessary spaces. I would never dare to use a project run by people that pushes their personal agendas on their website for a programming language. I do believe that there is only two genders, man and female. Am I a nazi now or what do Gleam mean by this message? Don't use projects like this.
- s0l1dsnak3123 3y agoPersonal projects are driven by personal agendas. Also water is wet. If you don't like it and you can't find the motivation to build something better, perhaps that's because your agenda doesn't drive you enough.
- ecmascript 3y agoWhy would I build something better? I am maybe not in the business nor have the interest of making a programming language. I don't really care that they have this message (except that I find it to be pretty insulting), I just think it's an unnecessary thing to do if you want people to use what you've made. I won't and I will encourage people not to use it just because of this.
- Capricorn2481 3y ago> I don't really care that they have this message (except that I find it to be pretty insulting), I just think it's an unnecessary thing to do if you want people to use what you've made. I won't and I will encourage people not to use it just because of this. Sounds like you care a lot if you're gonna actively discourage people from interacting with the project.
- ecmascript 3y ago> Sounds like you care a lot if you're gonna actively discourage people from interacting with the project. If someone would ask me in the future if I heard anything about Gleam, yes then I would actively discourage people from interacting with the project. If I read about it in a positive manner in the future here or in other forums, yes then I would probably write a comment warning people about it. If you think that is caring a lot then I care a lot. I don't consider that to be caring a lot though.
- stefanka 3y agoCan I write time critical functions in Rust and make it available to gleam as a module? This would be an interesting way of building a distributed framework (e.g., on a cluster for scientific computing like ML) in rust.
- joisig 3y agoYes, the BEAM VM allows you to write native code in a few different ways and call it from BEAM-native languages. For Rust there is a library called Rustler that simplifies the process a lot.
- stefanka 3y agoNice! Thanks
- crabbone 3y agoTo expand somewhat on the other comment. The experience of writing such functions is quite different if you have ever done this for something like Python. Processes are central to how Beam works, and you would have to incorporate this notion into design and execution of your bindings when interfacing with Beam from native code. I.e. you'd have to consider that the scheduler needs to be able to suspend / resume your function, think about how work can be done in small time slices, preferably w/o blocking and w/o starting own processes or threads. If you are interested in practical guidance, search for Erlang port drivers and NIFs. Often times when interfacing with eg. Python from native code, you'd run into marshaling problem. I.e. when you need to pass large and/or structured data to the native code, you'd have to do a lot of packing and unpacking of Python objects before you get something usable out of them in the native land, similarly, the other way around. Erlang's ports are designed with some idea about how to deal with this problem. NIFs are intended for simpler things, where continued / stateful communication between two worlds isn't necessary.
- ThinkBeat 3y agoA side note: There are a lot of new languages coming out these days, which I find interesting and positive. It gives hope for evolution and better solutions to come along. A problem is that on the surface they have similar syntax and keywords. I can get confused as to what language I am programming in since some syntax nearly transfers between more than one programming language. There are of course differences, and those differences can be profound which is what gives us a richer eco system but my brain gets confused by it.
- fyokdrigd 3y agoand you never know which party you're trusting when you download those thousands of unvetted code into your build dependency
- samtechie 3y agoGleam is a fantastic language but I didn't see much about testing apart from a very small package called gleeunit which is a binding to Erlang eunit. If I don't know anything about Erlang, how do I do tests in Gleam? I need some more guidance on this.
- Ndymium 3y agoGleeunit also works on the JS target so you can run tests on Node.js (if you're targeting JS).
- samtechie 3y agoGleeunit seems a bit sparse. I just see a few functions. For example how do I do mocks? Is this the the whole testing story assuming I am not targeting JS?
- lpil 3y agoMocks are deliberately not supported by Gleeunit as I (the maintainer) believe they are strictly worse than using dependency injection, and often result in dramatically lower quality code.
- samtechie 3y agoFair enough. In your opinion, is Gleeunit sufficient as a testing framework for Gleam or is it a work in progress which is also understandable as the language is still relatively young?
- bdavid21wnec 3y agoSo no one is disappointed gleam dropped function overloading, that was one of my favorite parts of elixir