Live data from Hacker News

Show HN: Beautiful Type Erasure with C++26 Reflection

ryanjk5.github.io

31–40 of 64 posts

Re: Show HN: Beautiful Type Erasure with C++26 Reflection

#31
post #29

in the first example: ``` 10: rjk::duck c{std::vector {1, 2, 3}}; 11: c.size(); // 3 12: 13: c = std::string{"hello"}; ``` Does the assignment on line 13 call the destrucor for the vector of ints created on line 10?

Is there another option? Or were you asking if it leaks memory? Maybe you were asking if it implements custom destructors? GC?

> Or were you asking if it leaks memory?

yeah,

If variable c where of type void* instead of duck, the assignment on line 13 would leak the memory used by the vector.

Re: Show HN: Beautiful Type Erasure with C++26 Reflection

#33
post #32

An include with a HTTP URL is a scary abomination straight put of hell. Please tell me that this is a compiler explorer specialty (which would still be cursed, but in a cool way) and not a GCC feature (which would be an absolute nightmare).

Yes, it's a Compiler Explorer feature. URL includes get rewritten client-side to work as if they were additional files supplied by the user. PR adding the current behavior is at [0], while I think the downloading code itself is at [1].

[0]: https://github.com/compiler-explorer/compiler-explorer/pull/...

[1]: https://github.com/compiler-explorer/compiler-explorer/blob/...

Re: Show HN: Beautiful Type Erasure with C++26 Reflection

#34
post #28

Earlier quoted context omitted.

That is exactly what I was thinking. I was a seasoned C++ programmer and always loved reading articles like this. I can't imagine I will every write my own C++ code again -- or in any language. I now program with English specifications now and I am 10000% times more productive.

Good for you! Some of us are professionals and like to understand our systems and how they work. I don't write assembly instructions by hand either, nor do I design CPUs much, but I want to - and likely need to - know how they work to make the best judgements.

I think you misunderstand -- I am still reading the article.

Re: Show HN: Beautiful Type Erasure with C++26 Reflection

#36
post #4

The things people describe as "beautiful" never cease to amaze me... ...but, as they say, beauty is in the eye of the beholder!

I find it hard to see a language as beautiful that’s grown too complex for a single person to hold a complete mental model of. I used to think that was a personal limitation, until I saw an interview with Bjarne explaining that he used to understand all of it but at this point it’s too big, no one can anymore.

C++ is certainly a leader among the least feasible, but it's far from alone.

Re: Show HN: Beautiful Type Erasure with C++26 Reflection

#37
post #20

Earlier quoted context omitted.

The problem with that is best described by Antoine de Sain-Exupery's saying "perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." I guess the same goes for elegance and grace...

C++ is in the transitional phase where major bad things are being taken away very satisfactorily, usually by providing a simpler and more general replacement (for example, auto instead of long and pointless type declarations or modern initialization protecting against implicit conversions and surprise constructor overloads), but most progress of elegance and grace come from new features that enable something traditio…

Oh, have they finally started to remove features?

Re: Show HN: Beautiful Type Erasure with C++26 Reflection

#39

are we still hand writing code?

That is exactly what I was thinking. I was a seasoned C++ programmer and always loved reading articles like this. I can't imagine I will every write my own C++ code again -- or in any language. I now program with English specifications now and I am 10000% times more productive.

I could imagine that in near future when token prices are as high as they really are, programmers that can't imagine or remember how to write code anymore will clean our streets, drive our taxis and water our plants.
Post reply on HN