Standard interface definitions for Julia?

I think a standard way to define interfaces in Julia, combined with a standard way to test if type satisfies all interfaces that are defined on it would be useful to improve the quality and reliability of the Julia package ecosystem.

What do you think?


No one disagrees. Someone just needs to come up with a good design and implementation. It’s the oldest open issue on JuliaLang/Julia, issue number 5:

Find a good design, implement it, and you’ll have it.

The issue is that it’s hard. See for example:

Just solve that issue if you want it.

For now, I think @oxinabox had a package for testing interfaces, and maybe JET.jl can be used to cook something up (@aviatesk ?), but it’ll take a bit more to get it into the language.


Probably this issue is more on-point:


Thanks for sharing the related issues!

I think both of those are applicable since the trend these days is to create untyped / ad hoc trait interface packages which avoid type tree lock in.

In any case, it seems to be a hard problem but people at Jan Vitek’s group are actively working on it…I’d recommend anyone who wants to contribute to contact them as they’ve already done a lot of pre-requisite hard thinking and research.

Also see this Invenia blog post on the matter:


I prefer informal interfaces. I think the time to adopt formal interfaces is past, and any effort directed to improve quality and reliability in this aspect should go in writing test suites for checking if a type satisfy an interface.


But again, without an official way to define interfaces this will hardly happen. Without a clear definition you cannot test anything. And if every package uses a different approach to define interfaces not many package authors will adapt any of the approaches because the learning effort is too high.


You do not need any change in the language to allow interface writers’ to give clear definitions. What you call a different approach? The way the tests work will be different for different interfaces anyway, some interface tests can take only already constructed objects, other will need some hooks for object creation, other will connect to system resources and may need special handling. What this “official way” will bring to the table that will be neither irrelevant nor exceedingly restrictive? Because anyway, there will be legacy code that will not use them, and people that may prefer to not use them, so alternatives will exist, even if a “official way” is added.

1 Like

Well, this is true for any standardization effort. But without standardization large markets cannot exist.
Worth reading: Standardization - Wikipedia

I think there are a number of packages for defining interfaces, like SimpleTraits.jl, WhereTraits.jl, BinaryTraits.jl etc…

To make a function like @test Base.satisfies_all_interfaces(MyType) possible one of these (or a combination of them) needs to be integrated in Base.


I think I now kinda get your point, and the reason I disagree with you is that I think you are being too optimistic. I do not believe in the possibility of existence of a function like @test Base.satisfies_all_interfaces(MyType). I think it will be impossible to get this level of convenience even with if a standard way existed and was ubiquitous. The interface testing will invariably need some particularities for every kinda of interface and every implementation, I do not dream of an automatized way of testing everything. So my reason for disagreeing with you is not that I think standardization is a bad thing, but I do not think it will possibly obtain a level of convenience without serious restrictions that will make the “official way” to not be used because it will not cover all possible cases.

Moreover, I think we may be discussing different things. Traits are another thing, I do not conflate them with interfaces, and I do not see the need of any of these packages (or traits in general) for writing good interfaces and code which use interface implementations.


Interfaces are one of the most requested feature as far as I know.

When it comes to standardization, we really need core dev people to opine and possibly drive. While julia is an open source project, many key functionalities are designed and implemented by that group, I think.

Maybe @StefanKarpinski could shed some light about the current thinking? And/or address that at the upcoming JuliaCon?


This post was temporarily hidden by the community for possibly being off-topic, inappropriate, or spammy.