3 ms·
The company I started working for a few months ago wrote their whole web app with Elixir/Phoenix LiveView. It's been a real pleasure to work with after years of
by plondon514 3y ago
The company I started working for a few months ago wrote their whole web app with Elixir/Phoenix LiveView. It's been a real pleasure to work with after years of React and Next.js. The main thing I miss are types though.
- actionfromafar 3y agoAre there no typed languages on BEAM? Or some Typescript style front for Elixir?
- lkurusa 3y agohttps://gleam.run/ https://gleam.run/ Gleam is super promising.
- bryanrasmussen 3y agowhy would you use Gleam instead of Elixir, is there any benefit to using both of them?
- bryanrasmussen 3y agoah ok, reading more compiles to JavaScript, generates typescript definitions, can reuse code from all Beam supported languages. So maybe Gleam as an easier way to integrate JS and Erlang / Elixir?
- victorbjorklund 3y agoThe benefits would be if you prefer gleam:s syntax and static typing. In the end all compile down to the same Erlang byte code that runs on the BEAM so neither has any performance benefits.
- pawelduda 3y agoTypes in Elixir are on the roadmap [1] but I don't think there's concrete ETA For now you have typespecs and dialyzer that tries to infer types and detect incorrect assumptions in code but I found it cumbersome to work with. Testing in Elixir is first class so I prefer that for now. You get doctests (documentation that is also a runnable test), like in Python, which I find very useful when looking at some package source. [1] https://youtu.be/giYbq4HmfGA?si=BjNyOc5cjWWA7ER6 https://youtu.be/giYbq4HmfGA?si=BjNyOc5cjWWA7ER6
- cpursley 3y agoI’ve found that function head pattern matching and guards get you very close to the benefits of types.
- Thaxll 3y agoElixir gets a lot of praise but very rarely mention that is't a dynamically typed language, people will talk about Dialyzer/type hints but it's vastly inferior to strongly typed language.
- chem83 3y agoJose Valim is investigating set-theoretic types, as you may have heard: https://news.ycombinator.com/item?id=37593967 https://news.ycombinator.com/item?id=37593967
- sodapopcan 3y agoI know people mean different things when they say this but Elixir is strongly typed in that it doesn't auto-cast. Furthermore, it goes farther than most languages in that it doesn't overload many operators. For example, string concatenation is done with `<>`, not `+`. This rules out many of those "subtle bugs" you would get in many other dynamic langues. For instance: `def compound_word(left, right), do: left <> right`. Even though there are no types specified (or even patterns of guards) this function can only every succeed with strings. Yes, it's still dynamic and will only be caught at runtime, but there are things about Elixir that make it a really nice dynamic language.
- impulser_ 3y agoPython gets a lot of praise too despite being a dynamically typed language. People will talk about MyPy/type hints but it vastly inferior to statically typed language. (Elixir is strongly typed btw) Elixir is essentially the functional python.
- Thaxll 3y agohttps://elixir-lang.org/getting-started/typespecs-and-behaviours.html#types-and-specs https://elixir-lang.org/getting-started/typespecs-and-behavi... "Elixir is a dynamically typed language"
- jerf 3y agoBEAM is pretty deeply untyped due to its fundamentally untyped [1] communication protocol. There's some logical reasoning behind this choice, which is that by not having a typed communication protocol, it can defer handling mismatched types to the application layer. Since it is deeply designed with the knowledge that it will be used in a clustered context and that it is inevitable that there will be version mismatches within a cluster (during upgrade if nothing else since simultaneous anything is impossible within a cluster, including upgrades), this is a somewhat reasonable compromise approach to the problem. If you do add typing on top of BEAM you still need some sort of solution to this problem with will probably have some sort "unsafe" equivalent. [1]: In the sense you mean here, anyhow. It has a selection of atomic types, int, list, tuple, etc., but there's no "user" types as one would have a strong typing system for. It's not an exact match but if you imagined a programming language that had nothing but JSON, not Javascript, Javascript has user types, literally just JSON as your underlying data model, you get pretty close to BEAM/Erlang.