I am a haskelly guy who turned game developer and find myself inside the depths of C++.
So I found this quite funny and maybe someone here finds it funny/interesting, too.
Polymorphism in C++ is usually embodied by inheritance with virtual functions, i.e. I create a new type, called class in C++ of course, that implements the “virtual functions” of some other type (the “parent class”). This, arguably, is the defining chracteristic of object-oriented programming (I know that defining object-orientation is contentious and for good reasons).
In this talk, which is quite pleasant to watch and really interesting, the speaker puts a bold statement on his last slide. You don’t actually need to watch it, to participate in my amazement: with modern C++ you don’t need virtual.
Less cryptic, he is saying
The feature called concepts of the new C++ standard, which really is the same as type-classes in Haskell, makes inheritance (object-oriented polymorphism) redundant.
I am not spiteful. Usually C++ developers are well aware that their toolbox isn’t sexy. There are usually practical reasons, most often just a huge legacy codebase that is still worth maintaining somehow.
But yes, I find it funny what kind of detour C++ takes to (somehow, a little bit) abondon object-orientation. Given that modern C++ also allows modules (finally!), encapsulation, which would be the second-most important characteristic of object-oriented programming (my opinion) doesn’t imply the use of C++ classes anymore, either.
In other news: Modern C++ has support for “lazy lists” in the form of ranges and function composition (not for functions in general, though).
So does that mean, Haskell guys can just switch to C++ and excel there, too? Well of course some of them can … but don’t expect to use any of those modern C++ features. As I said, the reason why C++ is employed are quite often legacy code-bases. Modern C++ is backwards compatible (there really wouldn’t be a point, otherwise) but you can’t count on the specific C++ compiler to actually support the modern world. Less can you count on support of your coworkers and bosses, who can’t read your code anymore, once you get serious with concepts.
Also, the legacy of old-world C++ still weighs heavily. Backwards compatiblity implies awfully strange syntax and a good deal of keyword recycling in the new features. It’s like doing type artihmetic in Haskell until you discover Idris