Blog Post: Beating std::visit Without Really Trying
Meta
jared771 at gmail.com
Sat Oct 5 04:07:45 UTC 2019
On Saturday, 5 October 2019 at 02:59:58 UTC, Paul Backus wrote:
> I was curious how C++17's std::variant compared to the options
> we have in D, like Algebraic and SumType, so I did a simple
> comparison of the generated assembly for each of them. You can
> read about it at the link below. And as you can probably guess
> from the title, D comes out ahead, in the end.
>
> https://pbackus.github.io/blog/beating-stdvisit-without-really-trying.html
>
> This is my first attempt at sharing something like this, so any
> comment or feedback is very much appreciated!
I'm not sure if you're aware, but funnily enough, I also wrote an
article[1] on std::variant vs. the D alternative that references
Matt Kline's article on std::visit. It seems we're really making
getting our money's worth from his article.
I really enjoyed this - I think you're right in that it comes
down to the complexity of implementation, and I suspect that C++
forced the developers of std::variant to choose between a usable
API (usable, not good) and performance.
I've been trying to communicate this major selling point of D to
my coworkers, but it's a real uphill battle. I haven't even been
able to convince them that built-in unit tests are a killer
feature.
As an aside, I actively use your sumtype library and for the most
part find it very nice to use. Thanks for the great work.
1.https://dlang.org/blog/2018/03/29/std-variant-is-everything-cool-about-d/
More information about the Digitalmars-d-announce
mailing list