Hacker News new | ask | show | jobs
by lindgrenj6 2220 days ago
Check out the Elixir "protocol" feature, it's similar to interfaces: https://elixir-lang.org/getting-started/protocols.html
3 comments

Protocols + the Typeclass library [0] makes for some of the most extensible Elixir code I've worked with.

[0] https://github.com/witchcrafters/type_class

Hi Elixir friend! Have you done a blog post on this by chance? I'd be really interested in reading one.
I haven't, but the creator of the library (Brooklyn Zelenka / @expede) has given a few excellent talks that reference her libraries. This is a personal favourite: https://www.youtube.com/watch?v=JD0FJTmuV_Q
I've used protocols, and they are useful as a kind of bare minimum interface/implementation abstraction. But they're nowhere even close to something like Rust traits. Which is totally fine given Elixir's goals.
I'm pretty deep into Elixir and have been learning a bit of Rust on the side this year, so this is interesting. Could you elaborate a bit?
I was just about to say, protocols fill the interface slot pretty well