Simple Rules for Safer Programs
I’m sure everybody hates it when some obscure bug happens which then consumes precious development time in the attempt to fix. It happens to the best of us.
To keep these at a minimum I employ some simple rules or guidelines and you should do it too if you value your time.
Prefer references instead of raw pointers A reference can’t be null like a pointer and you don’t have to check it if it’s non-null before using it.
std::jthread
C++20 brought in some nice features, unfortunately some of them are quite unstable and incomplete (looking at you “modules”), nevertheless some of them are quite complete and helpful.
Today we will take a look at std::jthread, also know as “joining thread”. This new threading abstraction is almost similar with its older brother std::thread, but unlike it it provides some neat features such as: automatic join on destruction and a mechanism that allows one to request a stop.
How I Learn Rust
In the recent months I’ve developed an interest for the Rust programming language. Some of its feature sound very attractive to me and while other people claim it to be just an improved C++ (like they say about C++ in regard to C) I try as much as possible to view it as its own thing. Of course from time to time I do comparisons between these two languages but I think that both are great tools for what they want to solve.