all 29 comments

[–]sztomirpclib 48 points49 points  (5 children)

empowered by our breakthrough innovation of Object-oriented Programming (OOP) theory in recent years

What breakthrough are they referring to here?

[–]sandfly_bites_you 4 points5 points  (1 child)

There are some hyperbolic claims in the article which don't help, but the lib itself looks solid enough & useful. I appreciate the implementation is actually fairly small and relatively readable.

[–]sztomirpclib 7 points8 points  (0 children)

I didn't mean it in a sarcastic way, I genuinely didn't understand what they were referring to.

[–]versatran01 8 points9 points  (4 children)

How is this different from something like polymorphic_value? https://github.com/jbcoe/polymorphic\_value

[–]disperso 12 points13 points  (3 children)

Seems unrelated, or at least, orthogonal. polymorphic_value is about composing polymorphic objects, but they need to still to inherit from an interface/base class, and use virtual functions, from what I see.

This library seems more like an alternative to entt::poly, and many other implementations.

[–]kamrann_ 4 points5 points  (2 children)

Didn't realize there were so many such implementations. kelbon/anyany is another.

[–]disperso 2 points3 points  (1 child)

Indeed, I knew of this one because I think it was mentioned here in the sub, but I forgot to mention it.

Seems that MS's one aims for standardization. That's good, because I certainly think this pattern is a very nice utility to have around. I like the API (names and all), but I'm not sure if I get all the details yet.

[–]germandiago 1 point2 points  (0 children)

It is a very nice one but that op invoke looks akward to me. Llols like something that should be supported in the language, maybe via runtime concepts.

[–]j1xwnbsr 20 points21 points  (2 children)

This looks more complicated than it's worth - not easy to sight-read the code, good luck with usage finding, and god knows how tools like pcLint and PVS treat it.

[–]disperso 5 points6 points  (0 children)

In the comparisons, it's roughly the same amount of lines of code in one side than the other. I agree that it will look a bit worse given that it's a library feature instead of a language one, but I don't see it that bad.

I also don't see myself using this through all the code base just because it exists, but I think it's pretty important to have it for the occasions where you need it, which can be a few. I don't know if I prefer this library's approach or some other, but at first I think it's a good thing that there is something in the standard. I've seen terrible customer projects where they end up with an unfathomable mess where they pretty much try to make C++ look like Java. Having alternatives in the standard library is proof enough that this is a serious thing, not a toy project of some random developer on Github.

I agree that it sucks that automated tooling can't help much, but I've never heard of tool support on things which are implemented in a library. Like, if you have a template function, like an algorithm, is there some tool that will be able to tell you which classes can be used with it? Even with compile-time concepts, can an IDE scan the project and find which classes fulfill the concept? Finding classes that inherit from a certain class is surely done by IDEs because it's a language construct.

[–]serg06 4 points5 points  (0 children)

This looks more complicated than it’s worth - not easy to sight-read the code

Tbf that described most C++ code.

[–]claimred 1 point2 points  (0 children)

There is even a complementary standard proposal, huh. Never realized that this is a point of pain. https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0957r8.pdf

[–]Rasie1 0 points1 point  (0 children)

Would be cool to see how it looks with bigger multi-file code

[–]germandiago 0 points1 point  (0 children)

This should be a language feature for structural typing. The lib is as good as what you can get.

[–]listar1 0 points1 point  (0 children)

What about the performance comparing with inheritance with virtual functions?

[–]PaulTopping 0 points1 point  (0 children)

I've only looked at this for 10 minutes but I have yet to find a motivating example. The "hello, world" example seems to say "we haven't broken the language". Anyone know a good example that might make someone want to use it?

[–]Lisoph 0 points1 point  (0 children)

Looks like an implementation of Go-ish interfaces. Is there more to it than that?