andre1sk
Would it make sense to have some central repository for protocols to make interop between apps/libs easier?
So we would have packages that just define a protocol that could be used by various libs apps?
(So we have protocols decoupled from packages that implement it?)
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
I’m posting this in response to Jose’s recent tweet (Cr. link) :
People are sleeping on Elixir for a coding harness:
Hot-code swappi...
New
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes.
We’re a small ...
New
I’ve just put together a small POC exploring PDF inspection from Elixir/Phoenix:
The idea is pretty simple: drag & drop a PDF in a...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
ericmj
What is the problem you’re trying to solve? What interop problems exist when the protocol is inside the library?
andre1sk
multiple libs can implement same common protocol why would I want to depend on a package just to pull in the definition of protocol if I want to use implementation from different package. As example say we had CC processing protocol and a bunch of libs implementing it.
ericmj
With CC processing do you mean credit card processing? For that I think it’s wrong to use protocols because the credit card is a single data structure or can you show where the extension points are?
You might have the inversion of control in the wrong direction. It’s usually the library that defines the protocol that is using it, for example with a JSON encoder protocol only the JSON library is calling the protocol.
Can you give a practical example of a current protocol existing inside a library that would be better outside of the library?
andre1sk
I agree credit card processing is contrived example but if we extend to say payment processing in general might be more practical example. You might be doing a charge against CC or against bank Account or whatever else payment method etc.
ericmj
What is the data structure you are implementing the protocol for in your example and what is the purpose of the protocol? Credit card processing can mean many things, is it validation of the card, making a charge against the card, associating the card with a subscription or customer. Is the data structure the transaction itself, why should the transaction data structure be different for the payment method?
I can’t think of any protocol in the wild where the point of the protocol is that the user should call it. All protocols I can think of it is actually the library that defines the protocol that calls the protocol. I am probably missing some instances, but this makes me feel you are trying to use protocols for something where there are better abstractions.
I think you need to show an example of something existing in the wild that would be improved by your proposed change, it’s hard to discuss around hypotheticals and hypothetical improvements shouldn’t be the basis of a large change to the library ecosystem.
andre1sk
I am definitely not suggesting any major change just wanted to get opinions. OK lets use JSON that you brought up
say my app depends on Poison and implemented the relevant protocol for my %domainSpecificThing{} now for the sake of argument @OvermindDL1 created super optimized mega fast JSON lib I want to switch to using it if the protocol was defined in some separate package would not need much changes on my end. Getting back to payment processing operations are generally the same yet data structures would be different e.g. for bank account in US it would ABA number and Bank Account number for cc credit card number and expiration date etc.
michalmuskala
Hearing about an ultra fast JSON lib, I feel somehow summoned
The chance is, that the protocol requirement for that ultra fast lib would be different and it might offer different callbacks or options - maintaining a 100% compatibility for all the features is generally hard. Additionally, usually when implementing protocol for some library you use functions from that library in the implementation (poison is a great example, when you usually delegate the rendering back to poison after building some data structure). There’s a very high chance that switching the consumer of the protocol would require switching the implementation.
OvermindDL1
This sounds more like an plugin API rather than a protocol API. Though I’ve thought about building an in-system optimizing plugin API, I’ve not done so yet.
The reason it sounds like a plugin API instead of a protocol API is that the examples you give seem to be:
Where Protocols are for dispatch based on the type/shape of a binding’s value to different code.
Although using something like ProtocolEx you could define such a ‘plugin’ interface and even enforce only one thing implementing it pretty easily (the resolve function!), I’d not do so.
The way I would do it is via a method that even Erlang has built-in,
behaviours.Specifically you have a behaviour. You have the application configuration (in Elixir it is those nice
config.exsand so forth files) and one of the options specifies the library name to use for that, then the behaviour definition module just passes calls to that specified module. Now it would not be quite as efficient as doing the same in ProtocolEx (you can get rid of one of the two cross-module calls, though technically if you made macro bouncers in the behaviour it would fix that too) it is the method the BEAM is built for.And with behaviours you can even enforce at compile-time if the specific module implements it fully or not. ^.^
Hehe, use Jiffy I think it’s called, it is a C NIF JSON parsing libary that blows Poison away (though no derivations I think). ^.^
andre1sk
You are prob. right
CptnKirk
I’ve wondered the same thing for stream-based processing. For example, in the JVM world we have Reactive Streams: http://www.reactive-streams.org/. It defines a low-level API for other projects to implement. This low-level API allows each project to interoperate while providing higher-level APIs to their users.
This is how the JVM supports multiple RS projects (Akka Streams, JDK9 Stream, Swave, etc), with the ability of each of these projects to interoperate with each other.
In this case Elixir could have defined a reactive-streams protocol and then implemented GenStage and Flow on top of this protocol. Another project could implement this protocol and support additional DSLs or processing semantics while supporting interop (in theory).
At least I think it could have gone this way. I’m still not quite up to speed on advanced Elixir though.