3 ms·
> It's incredibly hard to go back to a language without even basic ADTs after seeing the light. How did we ever prioritize implementation inheritance over ADTs
by paulddraper 2y ago
> It's incredibly hard to go back to a language without even basic ADTs after seeing the light.
How did we ever prioritize implementation inheritance over ADTs?
I don't know, but it was a mistake.
- JoshTriplett 2y agoHow widely understood and appreciated were algebraic data types at the time Cfront was first floated as the precursor to C++? To what degree had they shown up in mainstream languages?
- tialaramex 2y agoWell if you want to compare to why C++ has multiple inheritance, you need to first explain which mainstream languages in the mid-1980s had multiple inheritance so we can contrast. Like algebraic data types, multiple inheritance wasn't novel, but what were the big famous languages from that time which showed this was a must have for Bjarne's language?
- JoshTriplett 2y agoThat's not the comparison I'm making. It's possible for a proposed language to add something despite not being popular at the time, but that's not the default. I'm suggesting that if ADTs were not already popular at the time, it would be the unsurprising default for them to not be in a new language. In today's language landscape, by contrast, it would be surprising and disappointing for a new language to not have either ADTs or a specific alternative they propose for solving the same problem.
- tialaramex 2y agoBut the actual answer is revealing. Bjarne implemented multiple inheritance in C++ because it was easy. It's a New Jersey language. The priority is simplicity of implementation. It's not about what was popular, or that Stroustrup was at Cambridge not Edinburgh (all the exciting Programming Language theory stuff in that era like ML was from Edinburgh as you perhaps know). If ADTs were easy, C++ would have ADTs.
- tubthumper8 2y agoCfront being around 1983 would mean at least ALGOL68 and Pascal would've been well-known at the time. Ada is cited as an influence on C++. ML languages were definitely not mainstream but if Wikipedia is to be believed, ML was an influence on C++ as well. The idea would've been well understood, but if the goal of C++ was "C with classes" or more accurately "C + Simula" then it just wasn't part of the goal. And of course we got 20 years of essentially forgetting that sum types existed outside of ML languages until they were "rediscovered"
- bazoom42 2y agoProbably bescuse OOP was a great fit for desktop GUI’s. This drove OOP into the mainstream. ML-style languages never had a similar killer application.
- munificent 2y agoI think a similar but perhaps more accurate question is how did we prioritize virtual dispatch over ADTs? And I think the answer has a lot to do with the expression problem [1] and which kinds of extensibility were needed in the kinds of programs that languages at the time were designed for. OOP with subtyping and virtual dispatch makes it very easy to define an interface with a set of methods, and then have an open-ended set of concrete classes that all reliably implement those methods. It makes it easy to say "I don't know what data types I'll need yet, but I do know what operations I'll need." ADTs flip that around. That make it easy to express "I don't know what operations I'll need yet, but I do know what data types I'll need." For the kinds of simulations that Kristen Nygaard and Bjarne Stroustrup were writing, and then later the large GUI applications that C++ users were building, it seems that the former was more useful than the latter. [1]: https://journal.stuffwithstuff.com/2010/10/01/solving-the-expression-problem/ https://journal.stuffwithstuff.com/2010/10/01/solving-the-ex...
- paulddraper 2y agoThat's a good way of putting it. Dynamic dispatch is for a fixed set of operations and open-ended data. ADTs are for a fixed set of data and open-ended operations.