# Standard interface definitions for Julia?

**URL:** <https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [June 3, 2022, 11:49am UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181 "2022-06-03T11:49:52Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 3, 2022, 11:49am UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/1 "2022-06-03T11:49:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 3, 2022, 12:10pm UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/2 "2022-06-03T12:10:56Z")

</div>

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:

[https://github.com/JuliaLang/julia/issues/5](https://github.com/JuliaLang/julia/issues/5)

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

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

[https://github.com/JuliaLang/julia/issues/5#issuecomment-513605441](https://github.com/JuliaLang/julia/issues/5#issuecomment-513605441)

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.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 3, 2022, 12:15pm UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/3 "2022-06-03T12:15:23Z")

</div>

Probably this issue is more on-point:  
[https://github.com/JuliaLang/julia/issues/6975](https://github.com/JuliaLang/julia/issues/6975)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 3, 2022, 12:54pm UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/4 "2022-06-03T12:54:42Z")

</div>

Thanks for sharing the related issues!

---

<div class="post-metadata">

**Author:** ![Akatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/akatz/32/15164_2.png) [@Akatz](https://discourse.julialang.org/u/Akatz)\
**Post date:** [June 3, 2022, 1:21pm UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/5 "2022-06-03T13:21:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [June 3, 2022, 3:21pm UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/6 "2022-06-03T15:21:49Z")

</div>

Also see this Invenia blog post on the matter:

> **[Development with Interface Packages](https://invenia.github.io/blog/2020/11/06/interfacetesting/)**
>
> Over the last two years, our Julia codebase has grown in size and complexity, and is now the centerpiece of both our operations and research. This implies that we need to routinely replace parts of the system like puzzle pieces, and carefully test if...

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [June 3, 2022, 6:52pm UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/7 "2022-06-03T18:52:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 3, 2022, 9:41pm UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/8 "2022-06-03T21:41:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [June 3, 2022, 11:25pm UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/9 "2022-06-03T23:25:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 4, 2022, 12:03am UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/10 "2022-06-04T00:03:45Z")

</div>

> [@Henrique\_Becker](#):
>
> 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.

Well, this is true for any standardization effort. But without standardization large markets cannot exist.  
Worth reading: [Standardization - Wikipedia](https://en.wikipedia.org/wiki/Standardization)

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.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [June 4, 2022, 12:55am UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/11 "2022-06-04T00:55:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [June 20, 2022, 2:55pm UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/12 "2022-06-20T14:55:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Maximus\_Shtefan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maximus_shtefan/32/37638_2.png) [@Maximus\_Shtefan](https://discourse.julialang.org/u/Maximus_Shtefan)\
**Post date:** [July 16, 2022, 6:43am UTC](https://discourse.julialang.org/t/standard-interface-definitions-for-julia/82181/13 "2022-07-16T06:43:39Z")

</div>

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