Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I always think it's a shame that instead of C# becoming a better OO language, they keep trying to become an uglier F#. IE, why is the syntax for multiple dispatch still so clunky?

I know I know, pseudo OO took over the world, and then people revolted against it, so the easiest thing to do to stay relevant is to become "slightly functional with curly braces", rather than to actually try and do OO well.



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"?


To 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-dispat...


> What would it take for C# and/or others to "do OO well"?

Multiple inheritance. (j/k)


Unironically 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.


The "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.


I 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.



When in doubt look to CLOS.


Mixins via inheritance is a sweet pattern that I miss in C# sometimes.


C# has default interface implementations now, that can be used to create mixins...

https://learn.microsoft.com/en-us/dotnet/csharp/advanced-top...


Yeah 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


What does "better OO" mean here?

Which concepts or feature you have on mind?


multiple dispatch or whatever helps people stop thinking about a hierarchy of inheritance and more in terms of objects and messages.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: