RFC: Language Support for Traits — Yay or Nay?

If what you’re really asking about is “why isn’t this in the core language yet?”, I think the issues are that

  1. bare dispatch-leveraging (“Holy”) traits do work, and since we use them in a couple of places in Base’s own code they should be documented
  2. there are packages that implement nicer syntax
  3. there are some uncertainties about the impact widespread trait-usage would have in terms of ambiguities, which becomes more serious given that
  4. implementing a nice trait system and then making Julia exploit it would likely be a multi-month job, and
  5. if someone did that work, it’s possible it would be a breaking change and thus wouldn’t be merged unless we think that it + the sum of other Julia 2.x changes would be worth it.

All in all, no one has stepped forward to invest that kind of time.

IMO, a better approach would be to generate enough unity/enthusiasm in the package community that a core framework gets adopted by multiple packages and there are clear demonstrations of the benefits. Then eventually that core framework might just move into Julia. But part of the point is that it doesn’t have to move into the language to become ubiquitous: packages are nearly on the same footing as Base, especially now that we can cache native code. So my recommendation is that if someone wants to make this happen, the best place is to start with the package ecosystem. ArrayInterface is perhaps a poster-child for such efforts, but it doesn’t focus on syntax as much as what traits we actually want to have (which I think is a good thing).

24 Likes