I’m currently working on the formal design of a statically-checked trait system for Julia building off of our work on subtyping and static typing for Julia. The system as a whole is sadly some ways out yet because of a number of fundamental challenges. This problem isn’t unique to Julia at all, and interestingly is particularly bad in C++.
Before I get there, however, I need some examples of bugs or problems in your experience that have arisen because of a lack of checked interfaces. I have a few “classic” examples, but these issues tend to be ephemeral and momentarily annoying when you try and fail to compose libraries. It’s hard to discover them with static analysis (or else we wouldn’t be here!) and the known ones tend to be buried in Git somewhere.
My go-to example is the 1:length
antipattern as discussed here. It’s pretty common to use length
on AbstractArrays
even though it’s not valid in many cases - and this can go unnoticed until you pass something like a StridedArray where you can’t just go 1:length
to index through it. This would be a faulty use case, a case where you’re trying to use a method that doesn’t exist for an argument vector.
I’m also interested in implementation-side bugs, where you should have implemented some method but forgot about it. Back in the 0.6.0 days, a few of the Core.Compiler implementations of AbstractArray had this by lacking methods called for in the AbstractArray documentation (iirc, size
). This has been fixed by now, but I’d be very interested in other examples.
Have you ran into bugs caused by insufficient interface specification, incomplete implementation, or incorrect usage?