What is the best practice for implementing a library for use in both Elixir and Erlang? My goals include:
- minimize code duplication
- feels idiomatic to both Elixir and Erlang users
- no syntactic function call remapping like
:lists.sort [3, 2, 1]or
- integrates seamlessly with common package management and build solutions
- doesn’t break any features like maybe hot code reloading (or anything else, really)
- written primarily in Elixir because I like
Without knowing better, the first strategy I’d probably try is implementing an Elixir library and making an Erlang wrapper. This seems good, except I’d have to manually keep the wrapper synced with the Elixir code. Are there recommended wrapper generators for this?
I’m not familiar enough with Elixir/Erlang/BEAM to know whether that approach might break any features. If so, would writing the library primarily in Erlang be any better?
I don’t have a specific project in mind yet. Just mulling over how I would approach this when the time comes. Thanks, everyone.