Live data from Hacker News

C++26 Reflections adventures and compile-time UML

reachablecode.com

71–80 of 118 posts

Re: C++26 Reflections adventures and compile-time UML

#71
post #55

Oh man, some of the code in the linked proposal: Old: template struct list {}; using types = list ; constexpr auto sizes = [] class L, class... T>(L ) { return std::array {{ sizeof(T)... }}; }(types{}); New: constexpr std::array types = {^^int, ^^float, ^^double}; constexpr std::array sizes = []{ std::array r; std::ranges::transform(types, r.begin(), std::meta::size_of); return r; }(); I'm so tired of parameter packs…

This is when I switch to a programming language that doesn't block me from compiling and running just because I forgot some intricate detail. Ironically, I often find assembly programming much friendly.

BTW, I continue to maintain some C++ software, and I like cryptopp [1]. I know people now use libsodium.

[1] https://github.com/weidai11/cryptopp

Re: C++26 Reflections adventures and compile-time UML

#72
post #2

I had to do a UML thing for the first time in years for a class a few weeks ago[2]. I'm not 100% convinced that UML is actually useful at all. Obviously if you find value from it, don't let me take that from you, by all means keep doing it, but all it seemed to provide was boxes pointing to other boxes for stuff that really wasn't unclear from looking directly at the code anyway. It's really not that hard to look dir…

UML diagrams are the only pictures that DON’T paint a thousand words

Re: C++26 Reflections adventures and compile-time UML

#73
post #6

Whenever I start to feel like a real programmer making games and webapps and AI-enhanced ETL pipelines, I inevitably come across the blog post of a C++ expert and reminded that I am basically playing with legos and play-doh.

It's the other way around. You are the real programmer and the committee and the "modern C++" crowd are more interested playing with legos instead of shipping actual software. No way anything std::meta gets into serious production; too flexible in some ways, too inflexible in others, too much unpredictability, too high impact on compilation times - just like always with newer additions to the C++ standard. It takes o…

> And like always, the problem std::meta is purported to solve has been solved for years.

It is rare to read something more moronic than that

The Rust equivalent of std::meta (procedural macros) are heavily used everywhere including in serialization framework, debugging and tracers.

And that's not surprising at all: Compile time introspection is much more powerful and lightweight than codegen for exactly the same usage.

Re: C++26 Reflections adventures and compile-time UML

#74
post #2

I had to do a UML thing for the first time in years for a class a few weeks ago[2]. I'm not 100% convinced that UML is actually useful at all. Obviously if you find value from it, don't let me take that from you, by all means keep doing it, but all it seemed to provide was boxes pointing to other boxes for stuff that really wasn't unclear from looking directly at the code anyway. It's really not that hard to look dir…

You have to rethink your view and understanding of UML - https://en.wikipedia.org/wiki/Unified_Modeling_Language

It is not just drawing boxes but a visual modeling language providing both static/structural and dynamic/behavioural views of a complete system. You will only understand its value when you actually deal with large systems consisting of many interconnected modules with dependencies. In such large codebases it is almost impossible to understand all structural/behavioural aspects by browsing code whereas a tool like Doxygen generating UML diagrams from code becomes a godsend. You can map from UML to Code or Code to UML. As with any language you don't have to know all of it but can focus only on what you need eg. Class diagram/Activity diagram/Statemachine diagram are the ones i have found most useful.

Finally, UML is now being used as a modeling/specification language frontend to Formal Methods which is the ultimate proof of its usefulness.

Re: C++26 Reflections adventures and compile-time UML

#75
post #73
post #6

Earlier quoted context omitted.

It's the other way around. You are the real programmer and the committee and the "modern C++" crowd are more interested playing with legos instead of shipping actual software. No way anything std::meta gets into serious production; too flexible in some ways, too inflexible in others, too much unpredictability, too high impact on compilation times - just like always with newer additions to the C++ standard. It takes o…

> And like always, the problem std::meta is purported to solve has been solved for years. It is rare to read something more moronic than that The Rust equivalent of std::meta (procedural macros) are heavily used everywhere including in serialization framework, debugging and tracers. And that's not surprising at all: Compile time introspection is much more powerful and lightweight than codegen for exactly the same usa…

> It is rare to read something more moronic than that

It's not actually wrong though is it - real codebases have been implementing reflection and introspection through macro magic etc. for decades at this point.

I guess it's cool they want to fix it in the language, but as always, the approach is to make the language even more complex than it already is - e.g. two new operators (!) in the linked article

Re: C++26 Reflections adventures and compile-time UML

#76
post #6

Whenever I start to feel like a real programmer making games and webapps and AI-enhanced ETL pipelines, I inevitably come across the blog post of a C++ expert and reminded that I am basically playing with legos and play-doh.

It's the other way around. You are the real programmer and the committee and the "modern C++" crowd are more interested playing with legos instead of shipping actual software. No way anything std::meta gets into serious production; too flexible in some ways, too inflexible in others, too much unpredictability, too high impact on compilation times - just like always with newer additions to the C++ standard. It takes o…

> It's the other way around. You are the real programmer and the committee and the "modern C++" crowd are more interested playing with legos instead of shipping actual software.

I think this is the most clueless comment I ever read in HN. I hope the site is not being hit with it's blend of September.

I was going to explain to you how fundamentally wrong your comment was, but it's better to just kindly ask you to post in Reddit instead.

Re: C++26 Reflections adventures and compile-time UML

#77

Earlier quoted context omitted.

The stream of modern C++ features have been a god-send for anyone that cares about high-performance, high-reliability software. Maybe that doesn’t apply to your use case but C++ is widely used in critical data infrastructure. For anyone that does care about things like performance and reliability, the changes to modern C++ have largely been obvious and immediately useful improvements. Almost all C++ projects I know i…

You are sounding like rose tinted glasses are on. I think your glass is half full if you recheck actual versions and features. And mine is half empty in gamedev. Anecdata: A year or so ago I have been in discussion if beta features of C++20 on platforms are good to be used on large scale. It makes it not a sum but an intersection of partial implementations. Anyway it looked positive until we needed a pilot project to…

> One of the projects came back with 'just flipping C++20 switch with no changes causes significant regression on build times'.

I think this just proves that your team is highly inexperienced in C++ projects, which you implicitly attest by admitting this was your first C++ upgrade you had to go through.

Let me be very clear: there is never an upgrade of the C++ version targeted by a project that does not require full regression tests and a few bugs to squash. Why? Because even if the C++ side of things is perfectly fine, libraries often introduce all sorts of unexpected issues.

For example, once I had to migrate a legacy project to C++14 and flipping the compiler flag to c++14 caused a wall of compiler errors. It turned out the C++ was perfectly fine, but a single library behaved very poorly with a constexpr constructor they enabled conditionally with C++14.

You should understand that upgrades to the core language and standard libraries are exceptionally stable, and a clear focus of the standardization committee. But they only have a say in how the core language and standard libs should be. The bulk of the code any relatively complex project consumes is not core lang+ stdlib, but third-party libraries and frameworks. These often are riddled with flags to toggle whole components only in specific versions of the C++ language, mainly for backwards compatibility. Once you target a new version of C++, often that means you replace whole components of upstream dependencies. This often requires fixing your code. This happens very frequently, even with the likes of Boost.

So, what you're complaining about is not C++ but your inexperience in software engineering in general. I mean, what is the rule of thumb about major version upgrades?

Re: C++26 Reflections adventures and compile-time UML

#78
post #17

Earlier quoted context omitted.

sure, but instagram was created by a handful of people with python and got a billion dollar exit in 2012.

What is this culture of judging everything by amount of money. No one needs a billion dollars, it is practically irrelevant unless you are running on greed

money is a proxy for value. the post i was responding to seemed to be pointing out how little value there is in something else.

Re: C++26 Reflections adventures and compile-time UML

#79
post #17

Earlier quoted context omitted.

I know the trading firm I work at will be making heavy use of reflection the second it lands… we had a literal party when it made it into the standard.

sure, but instagram was created by a handful of people with python and got a billion dollar exit in 2012.

> sure, but instagram was created by a handful of people with python and got a billion dollar exit in 2012.

Facebook famously felt compelled to hire eminent C++ experts to help them migrate away from their PHP backend. I still recall reading posts on the Instagram Engineering blog on how and where they used C++.

Post reply on HN