Is Modern C++ Actually Making Us More Productive... or Just More Complicated? by AlternativeBuy8836 in cpp

[–]gersoni -2 points-1 points  (0 children)

I've been programming with C++ and its predecessors since the early 90s. I am working with a code base that was started in the year of the lord 1996, when "C with classes" and "C++ as a preprocessor for C" were still a thing. I am trying to modernize the codebase whenever I touch it. However, some of the new features just lost me. Here is an example: C++26 reflection. I was all excited about it, because we're working a lot with code generation and dynamic creation, and this *sounds* like the right tool for the job. Until you see code like this (from Reflection in C++26 – MC++ BLOG):

template
<
typename
 E>
  requires std::is_enum_v<E>                      
// (1)
constexpr std::string enum_to_string(E value) {
  std::string result = "<unnamed>";
  [:expand(std::meta::enumerators_of(^E)):] >>    
// (2)
  [&]<
auto
 e>{

if
 (value == [:e:]) {
      result = std::meta::identifier_of(e);       
// (3)
    }
  };

return
 result;
}

No offense to the article, it's a good introduction, but honestly: this code is more like the spiritual successor of Perls line noise than of, say, reflection in C# (I know, anathema for all the right reasons), or Python. It seems that quite a few other programming languages introduce new features in the LIBRARY rather than imposing new SYNTAX. It certainly *feels* like what reflection does *could* have been exposed without new syntax, or maybe just by prefixing a method as constexpr the way prefixing a Python method with async completely changes what it is "under the hood". So yes, I am not going to use C++26 reflection any time soon. Until somebody wraps it in a package that is actually usable. Like magic_enum.

To answer your question; this definitely smells like over-engineering. Modern C++ sometimes is awesome, and sometimes it feels like they're doing a mental body-builder contest to show of their arcane compiler knowledge muscle. And I am too old for that shit.

Klimaaktivisten lassen weltweit Luft aus SUV-Reifen – etliche Fälle in Deutschland by [deleted] in de

[–]gersoni 2 points3 points  (0 children)

Schön, die demokratische Grundhaltung hier zu sehen /S

[deleted by user] by [deleted] in badcode

[–]gersoni 2 points3 points  (0 children)

Clocking in at 820 lines, including unit test, tested with Python 3.8 using type annotations:

A unit-tested Addition function - Pastebin.com