return to table of content

Elixir is now a gradually typed language

nanna
5 replies
1d1h

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/

paradox460
0 replies
1d

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
0 replies
23h28m

Check https://github.com/josevalim/erl_phoenix

Writing Phoenix controllers, templates, plugs, and live views from Erlang
lawn
0 replies
1d

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.

kemiller
0 replies
1d

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.

djur
0 replies
1d

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.

sabellito
4 replies
21h26m

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.

norir
2 replies
20h27m

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
0 replies
19h24m

TypeScript's type system is, and it will always be, unsound by design [1].

Working with these constraints and still being able to deliver what they did is nothing short of incredible. They had the maturity and experience to ship something that wasn't Yet Another Copy Of Java's Type System, like Sorbet and Dart, for example.

[1] https://www.typescriptlang.org/docs/handbook/type-compatibil...

mavelikara
0 replies
19h18m

(Assuming this isn’t trolling)

Yes, AFAIK, Hejlsberg did the original TS type system. He, from what I can tell, wanted to build a usable type system for JS than any theoretical soundness. He seems to have succeeded in that.

faitswulff
0 replies
20h32m

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.

regulation_d
4 replies
23h34m

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
2 replies
22h18m

Thank you for the nice words, it is appreciated and it makes a difference whenever I am having a bad day. :)

bonif
0 replies
22h13m

I agree with all of it, you're a natural born leader. Please keep at it until you can !

AlchemistCamp
0 replies
6h29m

Your work has raised the level of projects solo and very small dev teams can build.

Elixir has been one of the nicest things I've discovered since becoming a dev back in 2010. I hope this new feature can improve the experience for larger orgs while keeping it great for indie hackers and new learners!

lkuty
0 replies
11h34m

I agree 100%. I have been using the language professionally everyday for a few years now, having converted our Erlang system to Elixir and Phoenix. The language is a joy to use, the community is great and José is doing a fantastic job in a kind way. I love being part of that community. Thank you for everything.

throwaway_64000
2 replies
20h29m

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.

fermuch
1 replies
16h26m

Typings in elixir are and will continue to be optional.

This announcement says it is detecting pattern matching and guards at build time instead of runtime, so nothing is changing.

And the "upcoming" (still in investigation) new types are totally optional. Only enabled if you use fat arrows.

You'll still have the advantages of having the core library and third party libs typed in your IDE, even if you don't use types.

AlchemistCamp
0 replies
7h10m

If I understand the comment you’re replying to, the loss is the competitive advantage.

I.e., if a desire for static types was keeping a large number of devs away, then this development will lead to far more devs using Elixir. This would erode some of throwaway_64000’s competitive edge as those devs also got the productivity gains of using Elixir.

pera
2 replies
22h34m
lkuty
1 replies
11h31m

Didn't know nitter. It looks like it allows to search twitter without having an account which is cool since I deleted mine a few months ago because I could not find relevant information anymore (the browsing experience was such a PITA).

arrowsmith
0 replies
3h32m

It's a privacy-friendly Twitter mirror (no tracking, no JS, no login required). Highly recommended.

Incidentally, 'nitter.net' isn't the only deployment. See here for a long list of alternative instances: https://github.com/zedeus/nitter/wiki/Instances

logicchains
2 replies
23h18m
realusername
1 replies
22h6m

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
0 replies
20h9m

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.

ilrwbwrkhv
2 replies
1d1h

Hope they learn from PHP. Their gradual typing is very pragmatic.

sodapopcan
0 replies
20h7m

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.

phplovesong
0 replies
12h57m

PHP's "typesystem" is anything but good.

eterps
2 replies
1d1h

Are there code examples or gists other than the tiny screenshot in the post?

pawelduda
0 replies
1d

Think it's announcement of announcement

ilikehurdles
0 replies
21h15m

There’s some context in the thread if you log in to X.

didip
2 replies
19h17m

So, is there a compile step to catch all of the type errors (and hopefully to perform AOT optimization later)?

di4na
0 replies
2h51m

Note that there are already some of this stuff in the compiler for AOT. Using these new specs for AOT optimisations is going to be a far taller problem than catching some of the errors

H12
0 replies
18h53m

My understanding is "yes, but only type errors that violate guards and pattern matching".

Jose's elixirconf keynote this year did a great job providing details on how how this new type system works:

https://youtu.be/giYbq4HmfGA?si=ZYf1g_GXr4LmHQ3H

tiffanyh
1 replies
22h22m

Does this help improve perf (in addition to preventing bugs)?

Is so, what's a ballpark of perf improvement?

josevalim
0 replies
22h9m

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.

sdn90
1 replies
17h44m

Very excited for this.

I used Elixir for a period and loved the language but I got fed up with using Dialyzer so I switched to other typed languages.

When this is done, I'll be coming back as I think Elixir does pretty much everything else better when it comes to writing web apps vs other languages.

seer
0 replies
14h42m

Hmm I’ve started doing some elixir as a side project and coming from typescript honestly I’ve found it a bit “dumb” and slow at the beginning. It didn’t allow you to write precise enough types, and would complain a lot about weird things.

As the project became more complex though, and I learned more about elixir, dialyzer became progressively more useful.

Most of the time when I chase a weird type error in TypeScript it turned out that the types were not correct enough and had to be fixed.

When I’m chasing weird dialyzer complaints, most of the time I discover that it was actually a bug in my code. Honestly sometimes I’m astonished how it can reason about very complex things so well. It’s just the error messages are usually very confusing, but with experience that kinda solves itself.

The difference to me so far has been that dialyzer finds bugs in my code, rather than in my types, which is quite nice.

If they make the built-in type system of elixir faster and with better error messages, I’ll be a very happy camper.

plondon514
1 replies
1d

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
0 replies
20h34m

switched companies recently and Elixir was the language of choice.

nice! i'm jealous.

photon_collider
1 replies
22h19m

Excited to see how this develops! I'm hoping that they share more examples of how this works in the near future.

josevalim
0 replies
22h11m

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.

pawelduda
1 replies
1d

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
0 replies
21h4m

Not to mention that Sorbet is a pita to use!

JonChesterfield
1 replies
18h7m

I like gradually typed languages but there seems to be no information here. Just a twitter screenshot. I can find a paper from early 2022 https://www.sciencedirect.com/science/article/pii/S259011842... - is there more information about this type system available?

iso8859-1
0 replies
16h28m

There are more details in https://youtu.be/giYbq4HmfGA

xutopia
0 replies
21h4m

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
0 replies
21h4m

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.

cpeterso
0 replies
20h6m

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.

_benj
0 replies
1d1h

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!

Snacklive
0 replies
20h32m

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.