[HN Gopher] Elixir is now a gradually typed language
___________________________________________________________________
Elixir is now a gradually typed language
Author : sergiotapia
Score : 303 points
Date : 2024-01-08 16:29 UTC (6 hours ago)
(HTM) web link (twitter.com)
(TXT) w3m dump (twitter.com)
| _benj wrote:
| This makes me happy! Phoenix and RoR before it have proven to be
| incredibly productive but the issues with types and runtime
| errors IMHO made it easy to break stuff.
|
| Types should pass a whole range of runtime errors to build time
| error, which is a huge plus for reliable software!
| eterps wrote:
| Are there code examples or gists other than the tiny screenshot
| in the post?
| pawelduda wrote:
| Think it's announcement of announcement
| ilikehurdles wrote:
| There's some context in the thread if you log in to X.
| nanna wrote:
| Is it possible to work with Phoenix in Lisp Flavoured Erlang
| (LFE) [0], or any of the other Erlang based languages, instead of
| Elixir?
|
| [0] https://lfe.io/
| lawn wrote:
| Phoenix relies heavily on Elixir macros, so you'd first have to
| compile and then try to call the generated functions... But I'm
| not sure that makes a whole lot of sense as you'd be missing
| out of most of the benefits of Phoenix.
|
| A more pragmatic approach is to use Elixir for the Phoenix
| specific parts, and from there call the other Erlang based
| languages for your business logic.
| djur wrote:
| A lot of what Phoenix has to offer comes from Elixir language
| features and the Mix build tool. To the extent it's possible I
| can't imagine it would be pleasant or useful.
| kemiller wrote:
| These types are static and don't end up in the runtime (which
| has no notion of types), so no. LFE will need its own solution,
| like Gleam.
| paradox460 wrote:
| Yes, but it isn't exactly ergonomic. Elixir tries to namespace
| most of its stuff within an Elixir namespace, so you have to
| use that when calling functions out of it.
|
| All the Elixir macro magic, however, will not carry forwards,
| so you'll have to be using the compiled Phoenix bytecode
| marianoguerra wrote:
| Check https://github.com/josevalim/erl_phoenix
|
| > Writing Phoenix controllers, templates, plugs, and live views
| from Erlang
| ilrwbwrkhv wrote:
| Hope they learn from PHP. Their gradual typing is very pragmatic.
| zilti wrote:
| PHP really is something to exactly _not_ take as an example
| hu3 wrote:
| I find this this kind of prejudice towards technologies
| rather reductionist and limiting, to say the least. During
| interviews I conduct, broad generalizations towards any
| technology, be it Visual Basic or Rust, for example, are
| noted as red flags. My rationale is that engineers should be
| able to understand that tooling is a matter of context +
| tradeoffs.
|
| There are lessons to be learned in almost any technology.
| Even more so in battle-tested technologies. And PHP is still
| a very popular tool that has come a long way over almost
| three decades since its creation (mid 1994).
|
| Things that come to mind that are worth looking for
| inspiration in PHP:
|
| - package management (composer is great)
|
| - gradual typing (9 years of use-cases to learn from)
|
| - framework popularity (what makes Laravel so popular?)
|
| - staying power (why is it still so popular after 3 decades?)
|
| - governance and community development model (continuous
| improvements since inception and relatively little drama)
|
| - backwards compatibility (major changes of internals with
| very little compatibility breaks. PHP's engine had major core
| changes while still maintaining friendly levels of backwards
| compatibility. And JIT is on the way.)
|
| https://www.php.net/manual/en/history.php.php
| DarkNova6 wrote:
| PHP is indeed a good showcase how much improvement can be
| done, even if the foundation is flawed. In fact, limiting the
| scope to "how to introduce typing", PHP has done almost
| everything right. It even rejects nulls by default and I
| would have wished Python had been just as rigorous in this
| regard.
| sodapopcan wrote:
| Elixir, and Erlang before it, has always essentially had
| gradual typing through pattern matching and non-overloaded
| operators, they just get caught at runtime. This is bringing
| those checks to compile time.
| pawelduda wrote:
| Very nice. Lack of types in Elixir was off-putting to some
| people. And it's perfect time to add them, since language is
| mostly complete. In Ruby, I was not sold on sorbet, because it
| goes "against philosophy of dynamic language", but I like it as
| an extra layer of safety in some places (there are rough edges
| tho) and I'm pretty confident they will get typing right
| xutopia wrote:
| Not to mention that Sorbet is a pita to use!
| plondon514 wrote:
| Very happy about this, switched companies recently and Elixir was
| the language of choice. Coming from TypeScript, I missed a lot of
| the benefits of a typed language and having access to the data
| model from anywhere in the project. Elixir was already great, but
| this is a huge improvement, congrats to the team that worked on
| this!
| waynesonfire wrote:
| > switched companies recently and Elixir was the language of
| choice.
|
| nice! i'm jealous.
| regulation_d wrote:
| Jose, if you come across this, I just want to express my
| gratitude to you for Elixir and for everything you've done for
| the Elixir community. The thoughtfulness and adeptness you bring
| to the language and the community is so very much appreciated.
| This change is such an excellent example of the steadiness and
| diligence you have led with. So rarely does a single individual
| that I am not interpersonally close to have such an outsized
| impact on my day-to-day happiness. Thank you, Jose.
| josevalim wrote:
| Thank you for the nice words, it is appreciated and it makes a
| difference whenever I am having a bad day. :)
| bonif wrote:
| I agree with all of it, you're a natural born leader. Please
| keep at it until you can !
| logicchains wrote:
| Wow, that's very fast progress from https://elixir-
| lang.org/blog/2023/09/20/strong-arrows-gradua... .
| realusername wrote:
| Elixir is already one of the most static of dynamic langages so
| I'm not too surprised about the quick progress, the language is
| almost built for that already.
|
| It's much easier compared to typing Ruby or JavaScript in terms
| of difficulty.
| josevalim wrote:
| Exactly! The hard part was to find a type system that we can
| map most (if not all) Elixir constructs to, and set-theoretic
| types have been a great fit so far and we were able to
| develop the theory in the areas where it lacked.
| pera wrote:
| https://nitter.net/josevalim/status/1744395345872683471
| tiffanyh wrote:
| Does this help improve perf (in addition to preventing bugs)?
|
| Is so, what's a ballpark of perf improvement?
| josevalim wrote:
| It is not a goal of the type system at the moment, as we will
| focus on software correctness and developer experience.
|
| However, keep in mind the Erlang VM already uses typing
| information (from patterns, guards, and built-in functions) to
| optimize code through its JIT compiler.
| photon_collider wrote:
| Excited to see how this develops! I'm hoping that they share more
| examples of how this works in the near future.
| josevalim wrote:
| The examples will be very gradual - no pun intended - as we
| need to go through each Elixir construct and either add
| inference (if a pattern or a guard) or type checking rules.
| Right now we infer and type check one single construct
| (bitstring) but the foundation is there to build on.
| sabellito wrote:
| Jose Valim is one of the few people in the industry that I trust
| to implement a type system correctly. The other one is Anders
| Hejlsberg.
| faitswulff wrote:
| Valim seems to do a really great job stewarding Elixir
| initiatives with the help of experts, like his collaboration
| with Sean Moriarty (author of Genetic Algorithms in Elixir)
| leading to Nx and now his recruiting Dr. Castagna (a PL
| researcher) and Guillaume Duboc (PhD candidate) to implement
| gradual typing.
| norir wrote:
| Hejlsberg is an interesting example. Did he do the original
| typescript type system that was unsound or was that someone
| else and he cleaned up the mess?
| sabellito wrote:
| [delayed]
| xutopia wrote:
| This is exactly the kind of efforts I wished were built into
| Ruby. No wonder lots of Ruby devs are now doing Elixir. It's
| shaping up to be an amazing language!
| rufius wrote:
| I'm very excited by this. Always loved Elixir, but I have always
| had a hard time with code bases above a certain size when there's
| no typing.
|
| This will make it my default choice the next time I need to build
| a web app or service.
| Snacklive wrote:
| You need to see the talks of the elixir team and Jose especially
| about bringing types to elixir. They are being so careful and
| thoughtful to bring a good type system or none at all.
| throwaway_64000 wrote:
| Sadly, I have mixed feelings about this.
|
| I feel like an anti-evangelist. I actually like reading
| complaints about the language...that just means there is less
| competition.
|
| - K8s/microservices are better/standard.
|
| - Elixir is too slow.
|
| - Dynamically typed languages suck.
|
| - There aren't enough libraries/ecosystem. And a lot of the
| libraries look like they are dead.
|
| - No big companies use it for anything.
|
| - It needs a better auth library, something like devise for ruby.
|
| - It is a functional language, and everyone knows they are too
| hard to use.
|
| - It is too difficult to hire good people.
|
| But now, one of the standard complaints is gone. :(
|
| This means invariably more people finding out that you can build
| incredible products with tiny teams. :(
|
| Thank you Jose for your leadership and building an incredible
| community and ecosystem. Hopefully, as the language grows, this
| stays the same.
| cpeterso wrote:
| Will gradual typing allow Elixir to implement any new performance
| optimizations? Adding typing to dynamic languages like Elixir (or
| Python or Ruby) means developers pay a compile-time cost but
| still pay a runtime cost for the VM's dynamic type checking.
___________________________________________________________________
(page generated 2024-01-08 23:01 UTC)