Comment by rileyphone
3 years ago
The real reason why you shouldn't use this is that Python is wrong about typing and classes. In OOP, classes are not types; interfaces are [0]. ABCs are a poor replica of this. Guido, having clearly avoided any relevant literature, states, in PEP-3119 [1]:
> ABCs are not intrinsically incompatible with Interfaces, but there is considerable overlap. For now, I’ll leave it to proponents of Interfaces to explain why Interfaces are better.
Let me try: interfaces are better because the protocol of an object isn't tied to its implementation, but in a properly encapsulated world an interface represents the information available about a class as a type [2]. A subclass may just be reusing an implementation without adhering to the same protocol, or two interchangeable classes might have no inheritance relationship.
Python is in a lot of ways a nice language, and I've certainly enjoyed programming in it, but many points of its design seem intentionally unobservant of prior work and research in programming languages, though perhaps it's equally an indictment of that research that the most popular languages ignore it so much. Typescript handles this much better, though neither it or Java eschew using classes as types entirely.
[0] https://dl.acm.org/doi/10.1145/96709.96721
> In OOP, classes are not types; interfaces are [0].
Depends on which OOP language we are talking about, Smalltalk definitly doesn't have interfaces unless we are talking about later dialects like Pharo, which introduced traits into the language.
The paper you linked to, makes its point exactly by moving beyond Simula and Smalltalk into their own view of OOP.
So like anything else on the OOP ecosystem, it is only yet another view about what OOP should be like.
Yes, but ABCs and also method resolution are particularly hackish in Python.
Generally, in Python one always has to understand the implementation and mentally execute the code, because everything is informally specified and nothing is declarative.
"Python is wrong about typing and classes. In OOP, classes are not types; interfaces are."
That might be true if there was one single definition of OOP that everybody agreed on. Like with most other religions, this isn't the case.
There's certainly a way to consider classes as types coherently, with added subtyping. In this view, interfaces are collections of types. That is, they correspond most closely to type classes.
> Guido, having clearly avoided any relevant literature […] unobservant of prior work
Same thing can be observed for his blog opinions on parsing. Sadly, this gives rise to a whole generation of programmers who believe (on account of perceiving him as an authority) that Peg are actually good.
Agreed. Unintentional ambiguities are a problem of PEG parsers. Ironically, the old Python parser also failed to detect ambiguities.
There is a strong aversion in the Python space for unambiguous formalisms. A parser that resolves ambiguities by earliest match first seems to satisfy the dynamic mindset.
I've been interested in PEGs recently. Do you happen to know of any literature on what's bad about them?