1. 2

    Trying to create new content for a C++ course I teach. Reading about new C++20 features now. Modules, contracts, concepts… So much cool stuff. I’ll have a few slides about future C++ but mostly I don’t bother people with advanced C++. Normal C++ is hard enough.

    1. 2

      In the future they will allow new/delete in constexpr and then we’ll have compile time leak detection!

      1. 1

        I recently discovered this. Seems so much easier than writing your own bash scripts as git hooks. I use it to auto format code with clang-format (C/C++) and black (python).

        Anyone else using this? Share your thoughts, experiences…

        1. 2

          i, personally have found this to be a slightly accessible introduction to all this craziness. at some point in around 2007-8 i decided to not go down the rabbit-hole of keeping up with the language.

          frankly, it seems to be the case of putting the proverbial cart-before-the-horse, where the ‘cart’ ofcourse is the programmer, and the ‘horse’ is the compiler. sadly, instead of latter helping the former, it is other way around…

          1. 2

            Haha that link is fantastic. I understand it but GOD what the hell.

            So rvalue now means something else? But prvalue means what rvalue used to mean.

            Also lvalue still means the same. Although glvalue means what you expect lvalue to mean.

            They could have gone for ‘pure rvalue’ and ‘pure lvalue’ and made the system symmetrical. But NOOO

            EDIT: It gets better! Cppreference [1] tells me the following: “C++17 … in contrast with the C++11 scheme, prvalues are no longer moved from.” Ok, eeu, WAT?

            [1] https://en.cppreference.com/w/cpp/language/value_category

          1. 8

            “… and, sadly, the rules are fairly complicated”

            Yeah, no shit. I teach C++ courses sometimes and explaining this to people is not fun. None of it is intuitive and most programmers will just ignore it.

            1. 15

              None of it is intuitive and most programmers will just ignore it.

              C++ in a nutshell.

              1. 2

                I programmed C++ intensively from 2007-2013 or so. Then I left C++ for some time, due to jobs that required Java. At some point I wanted to get up to speed on the changes in C++ and bought Scott Meyer’s Effective Modern C++. When reading the book I remembered what a kludge C++ actually is and that despite ergonomic improvements, recent iterations of C++ added even more accidental complexity. I decided that from then onwards, I will only do C++ when I get paid for it.

                (I occasionally do some C++ now for tinkering with Arduino. But it’s quite old-fashioned, because you can’t really afford to use templates extensively.)

              1. 3

                Learn logic programming by reading “The Reasoned Schemer” and then implement a version of it in Rust!