4 ms·
Elixir looks pretty interesting however lack of static types has held me off from picking it up. Curious what the experience of people with typespecs and Dialy
by jatins 6y ago
Elixir looks pretty interesting however lack of static types has held me off from picking it up. Curious what the experience of people with typespecs and Dialyzer has been:
1. How close do you think it comes to static types?
2. Does it have good IDE plugins providing type errors as you code?
- g5becks 6y agoIt comes nowhere close, if you are used to programming in languages with static types, the devx is just not on the same level. That being said, pattern matching is very powerful, and gives you a lot of what static types gives you in terms of safety. I’m just to spoiled by the level of productivity I get from editors when using a languages with static types at this point and using elixir full time would feel like taking a step backwards.
- Touche 6y agoBy contrast I'd rather not go back to meticulously decorating source files to add types where they aren't needed, so Elixir seems like the perfect language to me.
- dugmartin 6y agoIf you squint sideways pattern matching on structs plus guards is sort of like type checking (but not really). The map checking mentioned in the changelog will be a nice addition. I've been doing both a lot of TypeScript (for work) and Elixir (for personal projects) for the last few years and I do get a stronger sense of safety from TypeScript (especially during refactoring) but Elixir feels much more concise and fun to work in and the Phoenix event ticketing app I've been running for the last 3 years has been rock solid. btw I've been programming for 30+ years with all sorts of untyped, dynamically typed and statically typed languages. I still haven't found "the one true language". Something like strongly typed CoffeeScript that runs on BEAM would be close (I've been watching Gleam for a while and I plan to play with it after it matures a bit more).
- vendiddy 6y agoWe've used Elixir at our company for several years. Overall I've loved it, but I hope some experiments are done with a type system. (I don't find dialyser that strong in terms of performance and code editor help.) I think Typescript would serve as good inspiration because (1) it's a type system for a dynamic language underneath (javascript) and (2) it uses structural typing which fits well with pattern matching.
- dnautics 6y agoHow close do you think it comes to static types? Somewhere between 20-30% of the way there. In practice (especially with vscode/elixir-ls plugin) in my experience it does fulfill the 80/20 rule, it catches enough errors that the runtime recovers from the remaining ones (type errors do not cause the vm to panic; just your running "green thread will die and get restarted") with no real customer facing issues. If you need static types because your team has scaled then it's likely inadequate, but I don't have experience with that.
- dorian-graph 6y agoI won't directly answer 1 or 2, but here's my experience. For my job I was primarily using Elm and Go then for my new job it's been all Elixir. I thought I would miss Elm's compiler (Go, I do not miss). It's hard to explain, but I find that instead of thinking about what well-defined thing I'm reasoning about, it's about the flow of the data and what shape it happens to be in. In saying that, with structs and Ecto schemas, we pass those around primarily and pattern match on them too.