The method signatures necessary to implement an interface to get to the fallbacks are the boilerplate in Julia.
I’m happy to fill in the interior of those methods. What I (and I suspect foobar_lv2) want is the ability to drop in a default implementation for my type where the interior of each is just error("IMPLEMENT ME")
. Then, I am confident that my type will satisfy whatever interface I’m trying to implement.
This is a solved problem in other languages. Rust’s LSP has a code action which will do exactly this for a trait and type combination. Julia is not Rust for a number of reasons, not the least of which is the static/dynamic split which makes solving these problems in Julia much harder, and to expect Rust’s static analysis for Julia is never going to happen.
However, the absence of a tool to do this in one form or another makes maintaining a large codebase across many developers with varying levels of expertise difficult. I would take the LSP autopopulating solution, or some kind of static analysis to tell me when a method is missing for a type. The best I’ve got right now is to manually check things in tests using something like RequiredInterfaces.jl
, which is functional but suboptimal because it requires running the test suite to discover what’s missing.
It’s hard to guide people to what they need to implement because it requires manually translating from one source to another (Julia arrays page to code).
It’s hard to know when compatibility has broken until it breaks during usage (because a new method was added to the interface).
It’s hard to know when an interface has changed and suddenly I need to index with a custom indexer type instead of an integer, because we added a new abstraction for indexing.
These are not problems developers face in (some) other languages. These are problems that I find myself facing daily in Julia, working on a team in industry. It is very possible to be extremely productive in Julia without interfaces, but as the size of your team grows, and the spectrum of experience widens, it becomes more difficult to maintain quality and conformity across a growing codebase. As someone who wants Julia to see wider adoption, that means improving the developer experience for individuals and teams.
I respect that this is not the priority for core developers, and I don’t have time to contribute to language to solve this problem myself, so I will continue being productive without it. My point is that this is a real problem that software developers working with Julia do face with practical consequences, and while I am able to be productive without it, both my and many other people’s lives would be easier if we had first class support in the language or tooling for this.