News for hackers. Stuff that matters.
Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by sizzzzlerz on Sunday October 30, 2022 @09:21AM (#33394278)
Having left the C/C++ professional programming world several years back to wallow in other pastures, I've lost close touch with the languages except at a low-key hobbyist level. That said, I am curious over what is the motivation to pursue updates in 20 and 23? Are there really new features promised that today's programmer simply can't live without or are they all various levels of syntactic sugar or something in between? Is there a concern over whether these changes are making the language ever more complex and obese thus making mastery even harder to achieve?
Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by Deukhoofd on Sunday October 30, 2022 @09:28AM (#33394337)
One of the things I've mostly been looking at is the additions to the standard library. Especially the new <stacktrace> header looks like something that should have been in the language already.
Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by helen___keller on Sunday October 30, 2022 @09:43AM (#33394454)
I can’t speak for all of C++20/23 but I was impressed by Concepts which finally make template compile errors legible
Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by DoingIsLearning on Sunday October 30, 2022 @10:09AM (#33394632)
> Having left the C/C++ professional programming world several years back to wallow in other pastures.

As someone who wants to follow the same trajectory, how did you do it? And how did you dissociate professionally from being seen as the C++/systems guy?

Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by _dhruva on Sunday October 30, 2022 @12:14PM (#33395711)
Having gone through a very similar journey, it took around 2 years for me to completely disassociate myself from a specific programming language. It was more a 'me' problem since I leaned on to a programming language rather than a problem domain.

I still consider myself a systems programmer mostly writing glue code in Go/Python and jumping into C/C++ as required to improve performance when required.

Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by sizzzzlerz on Sunday October 30, 2022 @12:19PM (#33395753)
I have a bachelor and master of EE. My first job out of college starting my programming career (in Fortran), eventually moving to C and then C++. As my career progressed, I made myself into a software systems engineer. After several years of that, I started taking on full blown systems engineering things which I greatly enjoyed. That started my distancing from software development, mainly from interests but also because I became to expensive to write code. Fortunately, the companies I worked for were willing to support my career goals. YMMV.
Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by einpoklum on Sunday October 30, 2022 @10:11AM (#33394650)
> what is the motivation to pursue updates in 20 and 23?

For C++20:

* Ranges! With may range operations and views

* Expansion of ability of compile-time computation, including a lot of standard library code.

* Concepts - constrained templates

* 3-way comparisons with spaceship operator + automatic comparisons generation.

* You can write your own modules (Java-esque import rather than textual inclusion)

* Support (albeit ugly) for co-routines

* Spans: https://stackoverflow.com/q/45723819/1593077

* Parallelism primitives

* Asynchronous network operations in the standard library (Boost-ASIO-based IIANM)

* Can safely implement scope guards

For C++23:

* Standard library via modules

* Stack traces (e.g. in exceptions)

* Many range views/algroithms/adapters

* Expected: https://stackoverflow.com/q/68368581/1593077

* Monadic semantics for std::optional

* etc.

> Are there really new features promised that today's programmer simply can't live without

Well, people can live with a lot. Many people write C, after all... so you could ask that about any language undergoing long term development.

Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by alexeiz on Sunday October 30, 2022 @12:32PM (#33395877)
> Can safely implement scope guards

Can you elaborate on this?

Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by einpoklum on Sunday October 30, 2022 @02:22PM (#33397132)
A count of the number of exceptions in-flight was added, replacing the boolean indication of whether an exception is in-flight. This allows the scope guard construct proposed by Andrei Alexandrescu to distinguish between a scope being left on success and on an exception being thrown.

YouTube video about scope guard: https://www.youtube.com/watch?v=WjTrfoiB0MQ

Description of the change to the standard: https://isocpp.org/files/papers/N4152.pdf

Re:A Tour of C++, 3rd edition (covering C++20 plus a few lik... by Const-me on Sunday October 30, 2022 @06:37PM (#33399709)
I like the new <bit> header. In C++/20 they added support for BSR and BSF instructions from 1985, introduced in Intel i386. In C++/23 they even added BSWAP instruction, much newer one, introduced in 1989, in Intel i486. Most other instruction sets (ARM, Power, etc) have equivalents of these instructions.

Currently I use C++/17, have to rely on compiler-specific intrinsics. They work fine in practice, but standard library functions are IMO better.