3 ms·
I have the same objection but coming from the other side. The mainstream languages used to have pervasive mutation and side-effects. Now they have pervasive m
by mrkeen 2y ago
I have the same objection but coming from the other side. The mainstream languages used to have pervasive mutation and side-effects. Now they have pervasive mutation and side-effects with lambdas.
But my question is: what is missing from the OO side? What would it take for C# and/or others to "do OO well"?
- LAC-Tech 2y agoTo be clear I don't really come from "the other side". I very much enjoy and like functional programming. But again, that's what F# is for, right? If we push the state of the art in another directrion, the whole landscape benefits more - because I think we both agree C# is never going to be a better FP language than F#. As for what C# could do better, the OO solution to the problem pattern matching solves is multiple dispatch - with single dispatch languages you need things like the visitor pattern. Making that a first class part of C# would be fantastic. https://shawnhargreaves.com/blog/visitor-and-multiple-dispatch-via-c-dynamic.html https://shawnhargreaves.com/blog/visitor-and-multiple-dispat...
- lyu07282 2y ago> What would it take for C# and/or others to "do OO well"? Multiple inheritance. (j/k)
- LAC-Tech 2y agoUnironically this. Having "interfaces" and "abstract classes" is just a kludge, multiple inheritance covers all of this with one language construct. The "diamond problem" is a C++ issue, every other language solved it.
- lyu07282 2y agoI think they solved the problem by not supporting multiple inheritance, instead supporting interfaces and/or traits. But also "composition over inheritance" pretty much won, thankfully imho.
- hakanderyal 2y agoMixins via inheritance is a sweet pattern that I miss in C# sometimes.
- mastry 2y agoC# has default interface implementations now, that can be used to create mixins... https://learn.microsoft.com/en-us/dotnet/csharp/advanced-topics/interface-implementation/mixins-with-default-interface-methods https://learn.microsoft.com/en-us/dotnet/csharp/advanced-top...
- hakanderyal 2y agoYeah I sometimes use them but they don’t cover all the cases. I’m waiting for roles/extensions to see if I can achieve a similar result. https://github.com/dotnet/csharplang/discussions/5496 https://github.com/dotnet/csharplang/discussions/5496
- LAC-Tech 2y agohttps://en.wikipedia.org/wiki/Multiple_inheritance#Mitigation https://en.wikipedia.org/wiki/Multiple_inheritance#Mitigatio... CLOS and Ocaml figured it out
- freilanzer 2y agoWhen in doubt look to CLOS.
- consteval 2y agoThe "diamond problem" isn't a C++ problem. C++ solved it with virtual inheritance. Also C++ has exactly what you want. No interfaces, multiple inheritance. People don't utilize it unless it's a GUI lib.