Course program for 1st year students - no experience with OOP
Hi guys,
I'll be teaching relative newbies OOP in C++. They know some C++ but no OOP. Each lecture will be 3 hours. What do you think about the curriculum?
* **Introduction to OOP.** Review of pointers, references, and memory types in C++. Passing by value/reference. Procedural style vs. OOP – what OOP improves. Basic principles of OOP. Classes and objects at a high level. Structures in C++. Comparison of the basic principles with Java. Examples.
* **Abstraction and Encapsulation.** Access modifiers. Abstraction. Const classes and member functions. `mutable`. Streams and file input/output.
* **Constructors and Destructor.** The `this` pointer. Invocation of constructors and destructors. Converting constructors. Constructor and destructor calls when creating arrays (static and dynamic). The RAII principle.
* **Copy constructor and assignment operator (**`operator=`**).** Separate compilation. Preprocessor. Composition and aggregation. Examples – the `Student` class.
* **Move semantics** – benefits, lvalue, rvalue, move constructor/assignment operator, `std::move`. Example of a string class with move semantics (C++11). Arrays of pointers to objects.
* **Rule of Five and Rule of Zero.** Dynamic memory in classes. `default` / `delete` for special member functions (C++11). Example of a student class with a name (arbitrary length) and an array of grades (arbitrary length).
* **Operator overloading.** Friend classes and functions. Defaulted comparison operators and `<=>` (C++20). Example implementation of a complex number and an `Nvector`.
* **Error handling.** Static data members. Exceptions. Exception handling. Exception hierarchies and examples. Exceptions in constructors and destructors. Levels of exception safety. Modern approach – `std::expected` (C++23). Example of a class that counts its instances.
* **Relationships between objects.** Association. Dependencies. Ownership. Design guidelines.
* **Inheritance.** Types of inheritance. Function parameters (pointers and references). Constructors and destructors in inheritance. Copying in inheritance. Move semantics in inheritance. Example with a person, student, and teacher.
* **The** `virtual` **keyword.** Static and dynamic binding. Virtual functions. Keywords `override`, `final`. Virtual tables. Polymorphism – runtime and compile-time. Example.
* **Abstract classes and interfaces.** Pure virtual functions. Object slicing, type casts. Type erasure (`std::function`, C++11). Comparison with Java.
* **Multiple inheritance.** Diamond problem. Collections of objects in a polymorphic hierarchy. Copying and deletion. Example with the `Student` class.
* **Templates.** Required functions in a template class/template function. Template specializations. Examples of template classes/functions from the standard library. Smart pointers. Usage and idea of `shared_ptr`, `weak_ptr`, `unique_ptr` (C++11/14). Example of a stack (with template capacity) and a queue (with a `resize` function).
* **Design patterns.** SOLID principles. Pattern examples – Singleton, Factory, Prototype, Composite, Flyweight, Iterator, Command, Visitor, PIMPL – examples.
https://redd.it/1puugre
@r_cpp
Hi guys,
I'll be teaching relative newbies OOP in C++. They know some C++ but no OOP. Each lecture will be 3 hours. What do you think about the curriculum?
* **Introduction to OOP.** Review of pointers, references, and memory types in C++. Passing by value/reference. Procedural style vs. OOP – what OOP improves. Basic principles of OOP. Classes and objects at a high level. Structures in C++. Comparison of the basic principles with Java. Examples.
* **Abstraction and Encapsulation.** Access modifiers. Abstraction. Const classes and member functions. `mutable`. Streams and file input/output.
* **Constructors and Destructor.** The `this` pointer. Invocation of constructors and destructors. Converting constructors. Constructor and destructor calls when creating arrays (static and dynamic). The RAII principle.
* **Copy constructor and assignment operator (**`operator=`**).** Separate compilation. Preprocessor. Composition and aggregation. Examples – the `Student` class.
* **Move semantics** – benefits, lvalue, rvalue, move constructor/assignment operator, `std::move`. Example of a string class with move semantics (C++11). Arrays of pointers to objects.
* **Rule of Five and Rule of Zero.** Dynamic memory in classes. `default` / `delete` for special member functions (C++11). Example of a student class with a name (arbitrary length) and an array of grades (arbitrary length).
* **Operator overloading.** Friend classes and functions. Defaulted comparison operators and `<=>` (C++20). Example implementation of a complex number and an `Nvector`.
* **Error handling.** Static data members. Exceptions. Exception handling. Exception hierarchies and examples. Exceptions in constructors and destructors. Levels of exception safety. Modern approach – `std::expected` (C++23). Example of a class that counts its instances.
* **Relationships between objects.** Association. Dependencies. Ownership. Design guidelines.
* **Inheritance.** Types of inheritance. Function parameters (pointers and references). Constructors and destructors in inheritance. Copying in inheritance. Move semantics in inheritance. Example with a person, student, and teacher.
* **The** `virtual` **keyword.** Static and dynamic binding. Virtual functions. Keywords `override`, `final`. Virtual tables. Polymorphism – runtime and compile-time. Example.
* **Abstract classes and interfaces.** Pure virtual functions. Object slicing, type casts. Type erasure (`std::function`, C++11). Comparison with Java.
* **Multiple inheritance.** Diamond problem. Collections of objects in a polymorphic hierarchy. Copying and deletion. Example with the `Student` class.
* **Templates.** Required functions in a template class/template function. Template specializations. Examples of template classes/functions from the standard library. Smart pointers. Usage and idea of `shared_ptr`, `weak_ptr`, `unique_ptr` (C++11/14). Example of a stack (with template capacity) and a queue (with a `resize` function).
* **Design patterns.** SOLID principles. Pattern examples – Singleton, Factory, Prototype, Composite, Flyweight, Iterator, Command, Visitor, PIMPL – examples.
https://redd.it/1puugre
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Gstreamer: RTSP pipeline is not being freed
Hi everyone!
Sorry for posting it here and not in r/gstreamer, I'm waiting to be accepted but this issue is making me crazy.
I'm working on a C++ program which uses gstreamer to get a video from mediamtx via rtsp and send it to other targets via rtp udp, If mediamtx stops the video stream, my program should be trying to read it until the stream is available again. Also, this programs is used for multiple video streams, so every pipeline is run on a separated thread.
When the mediamtx video source is not available, my program enters on a loop where it resets the pipeline every n seconds, so when the video is available again, my program read it again and send to the other targets.
The issue is that every time the video is avaiable again, the pipeline allocates memory (for x264enc I think) but it doesn't frees the memory used before, so after a while between some video restarts, the memory allocated grows a lot, the only way to free it is restarting my program.
I tried to use valgrind, LSAN, GST_TRACER and `gst_deinit()` at the end of my program to check for any memory leak, but there is nothing related to the pipeline, also when the thread that is running the stream is stopped, I'm sure that the pipeline is removed with this:
```cpp
struct GstDeleter
{
void operator()(GstElement *ptr) const
{
if (ptr) gst_object_unref(ptr);
}
};
```
I checked the refcount before the unref, and is 1, so its supposed that the pipeline and the other elements (source, encoders, etc.) will be deleted.
The restart section is the following:
```cpp
void RtspStream::RestartConnection()
{
...
std::cout << Format("Video stream lost for %ld seconds, waiting 3s to reconnect\n", seconds_elapsed);
std::this_thread::sleep_for(std::chrono::seconds(3));
std::cout << "Reconnecting..." << std::endl;
GstState state, pending;
gst_element_set_state(pipeline.get(), GST_STATE_NULL);
gst_element_get_state(pipeline.get(), &state, &pending, GST_CLOCK_TIME_NONE);
gst_element_set_state(pipeline.get(), GST_STATE_PLAYING);
gst_element_get_state(pipeline.get(), &state, &pending, GST_CLOCK_TIME_NONE);
}
```
The pipeline is the following:
```cpp
pipeline = std::unique_ptr<GstElement, GstDeleter>(gst_pipeline_new(pipelineName.c_str()));
const auto pipelineSource = gst_element_factory_make("rtspsrc", "source");
const auto decodebin = gst_element_factory_make("decodebin", "decoder");
const auto videoconvert = gst_element_factory_make("videoconvert", "videoconvert");
const auto x264enc = gst_element_factory_make("x264enc", "x264enc");
const auto h264parse = gst_element_factory_make("h264parse", "h264parse");
const auto rtph264pay = gst_element_factory_make("rtph264pay", "rtph264pay");
const auto tee = gst_element_factory_make("tee", "tee");
const auto fakeQueue = gst_element_factory_make("queue", "fake_queue");
const auto fakesink = gst_element_factory_make("fakesink", "fakesink");
if (!pipeline || !pipelineSource || !decodebin || !videoconvert || !x264enc || !h264parse || !rtph264pay || !tee || !fakeQueue || !fakesink)
{
std::cerr << "Failed to create elements" << std::endl;
return;
}
g_object_set(source, "onvif-rate-control", 0, "location", src.url.value().c_str(), "latency", 0u, nullptr);
gst_util_set_object_arg(G_OBJECT(source), "protocols", "tcp");
gst_util_set_object_arg(G_OBJECT(x264enc), "tune", "zerolatency");
gst_util_set_object_arg(G_OBJECT(x264enc), "speed-preset", "ultrafast");
g_object_set(x264enc, "key-int-max", 15u, nullptr);
g_object_set(rtph264pay, "config-interval", 1, "pt", 96, nullptr);
gst_bin_add_many(GST_BIN(pipeline.get()), pipelineSource, decodebin, videoconvert, x264enc, h264parse, rtph264pay, tee, fakeQueue, fakesink, nullptr);
// Dynamic pad linking for source -> decodebin
// ReSharper disable once CppParameterMayBeConst
g_signal_connect(pipelineSource, "pad-added", G_CALLBACK(+[]([[maybe_unused]] GstElement *src, GstPad *src_pad, gpointer data)
{
const auto decodebin_ref =
Hi everyone!
Sorry for posting it here and not in r/gstreamer, I'm waiting to be accepted but this issue is making me crazy.
I'm working on a C++ program which uses gstreamer to get a video from mediamtx via rtsp and send it to other targets via rtp udp, If mediamtx stops the video stream, my program should be trying to read it until the stream is available again. Also, this programs is used for multiple video streams, so every pipeline is run on a separated thread.
When the mediamtx video source is not available, my program enters on a loop where it resets the pipeline every n seconds, so when the video is available again, my program read it again and send to the other targets.
The issue is that every time the video is avaiable again, the pipeline allocates memory (for x264enc I think) but it doesn't frees the memory used before, so after a while between some video restarts, the memory allocated grows a lot, the only way to free it is restarting my program.
I tried to use valgrind, LSAN, GST_TRACER and `gst_deinit()` at the end of my program to check for any memory leak, but there is nothing related to the pipeline, also when the thread that is running the stream is stopped, I'm sure that the pipeline is removed with this:
```cpp
struct GstDeleter
{
void operator()(GstElement *ptr) const
{
if (ptr) gst_object_unref(ptr);
}
};
```
I checked the refcount before the unref, and is 1, so its supposed that the pipeline and the other elements (source, encoders, etc.) will be deleted.
The restart section is the following:
```cpp
void RtspStream::RestartConnection()
{
...
std::cout << Format("Video stream lost for %ld seconds, waiting 3s to reconnect\n", seconds_elapsed);
std::this_thread::sleep_for(std::chrono::seconds(3));
std::cout << "Reconnecting..." << std::endl;
GstState state, pending;
gst_element_set_state(pipeline.get(), GST_STATE_NULL);
gst_element_get_state(pipeline.get(), &state, &pending, GST_CLOCK_TIME_NONE);
gst_element_set_state(pipeline.get(), GST_STATE_PLAYING);
gst_element_get_state(pipeline.get(), &state, &pending, GST_CLOCK_TIME_NONE);
}
```
The pipeline is the following:
```cpp
pipeline = std::unique_ptr<GstElement, GstDeleter>(gst_pipeline_new(pipelineName.c_str()));
const auto pipelineSource = gst_element_factory_make("rtspsrc", "source");
const auto decodebin = gst_element_factory_make("decodebin", "decoder");
const auto videoconvert = gst_element_factory_make("videoconvert", "videoconvert");
const auto x264enc = gst_element_factory_make("x264enc", "x264enc");
const auto h264parse = gst_element_factory_make("h264parse", "h264parse");
const auto rtph264pay = gst_element_factory_make("rtph264pay", "rtph264pay");
const auto tee = gst_element_factory_make("tee", "tee");
const auto fakeQueue = gst_element_factory_make("queue", "fake_queue");
const auto fakesink = gst_element_factory_make("fakesink", "fakesink");
if (!pipeline || !pipelineSource || !decodebin || !videoconvert || !x264enc || !h264parse || !rtph264pay || !tee || !fakeQueue || !fakesink)
{
std::cerr << "Failed to create elements" << std::endl;
return;
}
g_object_set(source, "onvif-rate-control", 0, "location", src.url.value().c_str(), "latency", 0u, nullptr);
gst_util_set_object_arg(G_OBJECT(source), "protocols", "tcp");
gst_util_set_object_arg(G_OBJECT(x264enc), "tune", "zerolatency");
gst_util_set_object_arg(G_OBJECT(x264enc), "speed-preset", "ultrafast");
g_object_set(x264enc, "key-int-max", 15u, nullptr);
g_object_set(rtph264pay, "config-interval", 1, "pt", 96, nullptr);
gst_bin_add_many(GST_BIN(pipeline.get()), pipelineSource, decodebin, videoconvert, x264enc, h264parse, rtph264pay, tee, fakeQueue, fakesink, nullptr);
// Dynamic pad linking for source -> decodebin
// ReSharper disable once CppParameterMayBeConst
g_signal_connect(pipelineSource, "pad-added", G_CALLBACK(+[]([[maybe_unused]] GstElement *src, GstPad *src_pad, gpointer data)
{
const auto decodebin_ref =
static_cast<GstElement *>(data);
const auto sink_pad = gst_element_get_static_pad(decodebin_ref, "sink");
if (gst_pad_link(src_pad, sink_pad) != GST_PAD_LINK_OK)
{
std::cerr << "Failed to link source to decodebin" << std::endl;
}
gst_object_unref(sink_pad);
}),
decodebin);
// Dynamic pad linking for decodebin -> videoconvert
// ReSharper disable once CppParameterMayBeConst
g_signal_connect(decodebin, "pad-added", G_CALLBACK(+[]([[maybe_unused]] GstElement *src, GstPad *new_pad, gpointer data)
{
const auto videoconvert_ref = static_cast<GstElement *>(data);
if (g_str_has_prefix(GST_PAD_NAME(new_pad), "src"))
{
const auto sink_pad = gst_element_get_static_pad(videoconvert_ref, "sink");
if (gst_pad_link(new_pad, sink_pad) != GST_PAD_LINK_OK)
{
std::cerr << "Failed to link decodebin to videoconvert" << std::endl;
}
gst_object_unref(sink_pad);
}
}),
videoconvert);
gst_element_link(videoconvert, x264enc);
gst_element_link(x264enc, h264parse);
gst_element_link(h264parse, rtph264pay);
gst_element_link(rtph264pay, tee);
gst_element_link(fakeQueue, fakesink);
gst_element_link(tee, fakeQueue);
```
Please, if someone know what I'm doing wrong or how can I fix it, this issue is consuming a lot of time and I don't know what to do :')
https://redd.it/1puw1xi
@r_cpp
const auto sink_pad = gst_element_get_static_pad(decodebin_ref, "sink");
if (gst_pad_link(src_pad, sink_pad) != GST_PAD_LINK_OK)
{
std::cerr << "Failed to link source to decodebin" << std::endl;
}
gst_object_unref(sink_pad);
}),
decodebin);
// Dynamic pad linking for decodebin -> videoconvert
// ReSharper disable once CppParameterMayBeConst
g_signal_connect(decodebin, "pad-added", G_CALLBACK(+[]([[maybe_unused]] GstElement *src, GstPad *new_pad, gpointer data)
{
const auto videoconvert_ref = static_cast<GstElement *>(data);
if (g_str_has_prefix(GST_PAD_NAME(new_pad), "src"))
{
const auto sink_pad = gst_element_get_static_pad(videoconvert_ref, "sink");
if (gst_pad_link(new_pad, sink_pad) != GST_PAD_LINK_OK)
{
std::cerr << "Failed to link decodebin to videoconvert" << std::endl;
}
gst_object_unref(sink_pad);
}
}),
videoconvert);
gst_element_link(videoconvert, x264enc);
gst_element_link(x264enc, h264parse);
gst_element_link(h264parse, rtph264pay);
gst_element_link(rtph264pay, tee);
gst_element_link(fakeQueue, fakesink);
gst_element_link(tee, fakeQueue);
```
Please, if someone know what I'm doing wrong or how can I fix it, this issue is consuming a lot of time and I don't know what to do :')
https://redd.it/1puw1xi
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Micro-benchmarking Type Erasure: std::function vs. Abseil vs. Boost vs. Function2 (Clang 20, Ryzen 9 9950X)
I'm currently developing SereneDB and some time ago we performed some micro-benchmarks to evaluate the call overhead of `std::function` against popular alternatives.
We compared
* `std::function`
* `absl::AnyInvocable`, `absl::FunctionRef`
* `boost::function`
* `fu2::function` / `fu2::unique_function`
Setup
* **CPU:** AMD Ryzen 9 9950X 16-Core (Zen 5)
* **Compiler:** Clang 20.1.8 (-O3)
* **Std Lib:** libc++ 20 (ABI v2)
* **Methodology:** Follows Abseil's micro-benchmarking practices (using DoNotOptimize to prevent dead-code elimination).
* Benchmark source code is available [**here**](https://github.com/serenedb/serenedb/blob/main/tests/bench/micro/function.cpp)**.**
Results and notes ([click here to see the visualized results](https://imgur.com/JUX738l))
|**Trivial Lambda**|||
|:-|:-|:-|
|`std::function`|**0.91 ns**|Surprisingly fast, likely because libc++ is devirtualizing this|
|`absl::FunctionRef`|0.90 ns|Non-owning, consistently fast|
|`boost::function`|0.95 ns||
|`absl::AnyInvocable`|1.81 ns||
|`fu2::function`|4.77 ns|Significant overhead (likely missed devirtualization)|
|**Large Lambda (SBO Check)**|||
|`std::function`|5.51 ns|Hit the allocation|
|`absl::FunctionRef`|**1.09 ns**|Immune to capture size (reference semantics)|
|`boost::function`|10.20 ns|Heaviest penalty for large captures|
|`fu2::function`|6.06 ns||
|**Function Pointers**|||
|`absl::FunctionRef`|1.08 ns||
|`absl::FunctionValue`|**0.89 ns**||
|`std::function`|1.10 ns||
|`fu2::function_view`|1.09 ns|The view variant performs well|
|**With Non-Trivial Args**|||
|absl::FunctionRef|2.53 ns|Slightly slower than std::function here|
|`std::function`|**2.39 ns**||
|`absl::AnyInvocable`|2.39 ns||
|`boost::function`|3.84 ns||
# Key Observations
1. **Clang & libc++:** The most surprising result is `std::function` (0.91ns) beating `absl::AnyInvocable` and `fu2` in the trivial case. Since we're using Clang 20 with libc++, the compiler is likely seeing through the type erasure and devirtualizing the call completely.
2. **Views are great:** If you don't need ownership, `absl::FunctionRef` (or `fu2::function_view`) beats owning wrappers in performance. `absl::FunctionRef` remained \~1ns even when the underlying lambda was large, whereas `std::function` jumped to \~5.5ns due to allocation/SBO limits.
3. **The function2 (fu2) poor results:** We observed `fu2::function` hovering around \~4.8ns for trivial cases. Since `std::function` is <1ns, this suggests that while Clang could inline the standard library implementation, it failed to devirtualize the `fu2` vtable, resulting in a true indirect call.
4. **Features vs Raw Speed:** While `fu2` lagged in this specific micro-benchmark, it provides powerful features that `std::function` lacks, such as function overloading.
5. **Boost:** Shows its age slightly with the highest penalty for large captures (10.2ns).
# Conclusion
Based on the results, at **SereneDB** we decided to stick to `std::function` or `absl::FunctionRef` depending on the use case (ownership vs. non-ownership), as they currently offer the best performance-to-complexity ratio for our specific compiler setup.
repo: [https://github.com/serenedb/serenedb](https://github.com/serenedb/serenedb)
https://redd.it/1puz450
@r_cpp
I'm currently developing SereneDB and some time ago we performed some micro-benchmarks to evaluate the call overhead of `std::function` against popular alternatives.
We compared
* `std::function`
* `absl::AnyInvocable`, `absl::FunctionRef`
* `boost::function`
* `fu2::function` / `fu2::unique_function`
Setup
* **CPU:** AMD Ryzen 9 9950X 16-Core (Zen 5)
* **Compiler:** Clang 20.1.8 (-O3)
* **Std Lib:** libc++ 20 (ABI v2)
* **Methodology:** Follows Abseil's micro-benchmarking practices (using DoNotOptimize to prevent dead-code elimination).
* Benchmark source code is available [**here**](https://github.com/serenedb/serenedb/blob/main/tests/bench/micro/function.cpp)**.**
Results and notes ([click here to see the visualized results](https://imgur.com/JUX738l))
|**Trivial Lambda**|||
|:-|:-|:-|
|`std::function`|**0.91 ns**|Surprisingly fast, likely because libc++ is devirtualizing this|
|`absl::FunctionRef`|0.90 ns|Non-owning, consistently fast|
|`boost::function`|0.95 ns||
|`absl::AnyInvocable`|1.81 ns||
|`fu2::function`|4.77 ns|Significant overhead (likely missed devirtualization)|
|**Large Lambda (SBO Check)**|||
|`std::function`|5.51 ns|Hit the allocation|
|`absl::FunctionRef`|**1.09 ns**|Immune to capture size (reference semantics)|
|`boost::function`|10.20 ns|Heaviest penalty for large captures|
|`fu2::function`|6.06 ns||
|**Function Pointers**|||
|`absl::FunctionRef`|1.08 ns||
|`absl::FunctionValue`|**0.89 ns**||
|`std::function`|1.10 ns||
|`fu2::function_view`|1.09 ns|The view variant performs well|
|**With Non-Trivial Args**|||
|absl::FunctionRef|2.53 ns|Slightly slower than std::function here|
|`std::function`|**2.39 ns**||
|`absl::AnyInvocable`|2.39 ns||
|`boost::function`|3.84 ns||
# Key Observations
1. **Clang & libc++:** The most surprising result is `std::function` (0.91ns) beating `absl::AnyInvocable` and `fu2` in the trivial case. Since we're using Clang 20 with libc++, the compiler is likely seeing through the type erasure and devirtualizing the call completely.
2. **Views are great:** If you don't need ownership, `absl::FunctionRef` (or `fu2::function_view`) beats owning wrappers in performance. `absl::FunctionRef` remained \~1ns even when the underlying lambda was large, whereas `std::function` jumped to \~5.5ns due to allocation/SBO limits.
3. **The function2 (fu2) poor results:** We observed `fu2::function` hovering around \~4.8ns for trivial cases. Since `std::function` is <1ns, this suggests that while Clang could inline the standard library implementation, it failed to devirtualize the `fu2` vtable, resulting in a true indirect call.
4. **Features vs Raw Speed:** While `fu2` lagged in this specific micro-benchmark, it provides powerful features that `std::function` lacks, such as function overloading.
5. **Boost:** Shows its age slightly with the highest penalty for large captures (10.2ns).
# Conclusion
Based on the results, at **SereneDB** we decided to stick to `std::function` or `absl::FunctionRef` depending on the use case (ownership vs. non-ownership), as they currently offer the best performance-to-complexity ratio for our specific compiler setup.
repo: [https://github.com/serenedb/serenedb](https://github.com/serenedb/serenedb)
https://redd.it/1puz450
@r_cpp
GitHub
serenedb/tests/bench/micro/function.cpp at main · serenedb/serenedb
The First Distributed Real-Time Search Analytics Database - serenedb/serenedb
Microsoft to Replace All C/C++ Code With Rust by 2030
https://www.thurrott.com/dev/330980/microsoft-to-replace-all-c-c-code-with-rust-by-2030
https://redd.it/1pv5nsd
@r_cpp
https://www.thurrott.com/dev/330980/microsoft-to-replace-all-c-c-code-with-rust-by-2030
https://redd.it/1pv5nsd
@r_cpp
Thurrott.com
Microsoft to Replace All C/C++ Code With Rust by 2030
Microsoft is taking an impressive step in modernizing its biggest codebases and will eliminate all C/C++ code by the end of the decade.
Software Architecture with C++, Second Edition: reviews, thoughts
The second edition of the book was recently published. The first edition was met with mixed reviews, with some people liking it and others disliking it. Overall, it appears the book has been significantly revised and expanded with practical examples for writing and deploying C++ microservices. Does anyone have any opinions on this book?
Software Architecture With C++ by Adrian Ostrowski, Piotr Gaczkowski
Google Books Software Architecture with C++: Designing robust C++ systems with modern architectural practices, Edition 2
https://redd.it/1pva16y
@r_cpp
The second edition of the book was recently published. The first edition was met with mixed reviews, with some people liking it and others disliking it. Overall, it appears the book has been significantly revised and expanded with practical examples for writing and deploying C++ microservices. Does anyone have any opinions on this book?
Software Architecture With C++ by Adrian Ostrowski, Piotr Gaczkowski
Google Books Software Architecture with C++: Designing robust C++ systems with modern architectural practices, Edition 2
https://redd.it/1pva16y
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
C++ logging library - something I've been working on, Pt. 5
Hello everyone,
You may not know, but it has become tradition for me to post an update about my logging library at the end of every year. Your critique and feedback have been invaluable, so thank you sincerely.
The logger is very fast and makes no heap allocations per log call. To achieve that, the logger uses several purpose-specific pre-allocated static buffers where everything is formatted in-place and memory is efficiently reused. It supports both synchronous and asynchronous logging. It's very configurable, so you can tailor it to your specific use case, including the sizes of the pre-allocated buffers I mentioned.
The codebase is clean, and I believe it's well documented, so you'll find it relatively easy to follow and read.
Whats new since last year:
A lot of stability/edge-case issues have been fixed
The logger is now available in vcpkg for easier integration
What's left to do:
Add Conan packaging
Add FMT support(?)
Update benchmarks for spdlog and add comparisons with more loggers(performance has improved a lot since the benchmarks shown in the readme)
Rewrite pattern formatting(planned for 1.6.0, mostly done, see
I would be very honoured if you could take a look and share your critique, feedback, or any kind of idea. I believe the library could be of good use to you: https://github.com/ChristianPanov/lwlog
Thank you for your time and happy holidays,
Chris
https://redd.it/1pvixcz
@r_cpp
Hello everyone,
You may not know, but it has become tradition for me to post an update about my logging library at the end of every year. Your critique and feedback have been invaluable, so thank you sincerely.
The logger is very fast and makes no heap allocations per log call. To achieve that, the logger uses several purpose-specific pre-allocated static buffers where everything is formatted in-place and memory is efficiently reused. It supports both synchronous and asynchronous logging. It's very configurable, so you can tailor it to your specific use case, including the sizes of the pre-allocated buffers I mentioned.
The codebase is clean, and I believe it's well documented, so you'll find it relatively easy to follow and read.
Whats new since last year:
A lot of stability/edge-case issues have been fixed
The logger is now available in vcpkg for easier integration
What's left to do:
Add Conan packaging
Add FMT support(?)
Update benchmarks for spdlog and add comparisons with more loggers(performance has improved a lot since the benchmarks shown in the readme)
Rewrite pattern formatting(planned for 1.6.0, mostly done, see
pattern_compiler branch, I plan to release it next month) - The pattern is parsed once by a tiny compiler, which then generates a set of bytecode instructions(literals, fields, color codes). On each log call, the logger executes these instructions, which produce the final message by appending the generated results from the instructions. This completely eliminates per-log call pattern scans, strlen calls, and memory shifts for replacing and inserting. This has a huge performance impact, making both sync and async logging even faster than they were.I would be very honoured if you could take a look and share your critique, feedback, or any kind of idea. I believe the library could be of good use to you: https://github.com/ChristianPanov/lwlog
Thank you for your time and happy holidays,
Chris
https://redd.it/1pvixcz
@r_cpp
GitHub
GitHub - ChristianPanov/lwlog: Very fast synchronous and asynchronous C++17 logging library
Very fast synchronous and asynchronous C++17 logging library - ChristianPanov/lwlog
I need C++ code about 240 line if you think you can handle it in a one day
Please dm to me if you can do
https://redd.it/1pvsjb6
@r_cpp
Please dm to me if you can do
https://redd.it/1pvsjb6
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Microsoft wants to replace its entire C and C++ codebase
https://www.theregister.com/2025/12/24/microsoft_rust_codebase_migration
https://redd.it/1pw9mqb
@r_cpp
https://www.theregister.com/2025/12/24/microsoft_rust_codebase_migration
https://redd.it/1pw9mqb
@r_cpp
The Register
Microsoft wants to replace its entire C and C++ codebase, perhaps by 2030
: Plans move to Rust, with help from AI
Who is the best C++ Programmer You Know.
I'm current an engineering student and was wondering who the best C++ programmers yall know are. Are they students, FAANG employees, researchers, mathematicians, etc? How can i become a better C++ dev and what makes a good C++ dev? Curios on yall's thoughts.
https://redd.it/1pwbb50
@r_cpp
I'm current an engineering student and was wondering who the best C++ programmers yall know are. Are they students, FAANG employees, researchers, mathematicians, etc? How can i become a better C++ dev and what makes a good C++ dev? Curios on yall's thoughts.
https://redd.it/1pwbb50
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Behl: Lua-inspired noscripting language with C-like syntax, implemented in C++20.
https://github.com/behl-lang/behl
https://redd.it/1pwd4dg
@r_cpp
https://github.com/behl-lang/behl
https://redd.it/1pwd4dg
@r_cpp
GitHub
GitHub - behl-lang/behl: Lua-inspired noscripting language with C-like syntax, implemented in C++20.
Lua-inspired noscripting language with C-like syntax, implemented in C++20. - behl-lang/behl
Header-only library for creating simple text-based command interpreters
Hi all,
I made a small header-only library called
The core idea is to take a raw string like
You can bind regular functions, capturing lambdas or member functions as your commands. There is no global state and no dynamic memory allocations. The library is well suited for embedded development, where creating text-based debug interfaces over UART/serial port might come handy.
Basic example:
void logenable() { ... }
int sum(int a, int b) { return a + b; }
int main()
{
// List of available commands
const conco::command commands[] = {
{ logenable, "log.enable;Enable logging" },
{ sum, "sum;Sum of two integers" }
};
// Calls
conco::execute(commands, "log.enable");
char buffer256 = { 0 };
// Calls
conco::execute(commands, "sum 123 456", buffer);
std::println("{}", buffer); // Outputs: 579
}
I would love to hear your feedback or roast of the implementation! Check out the GitHub repository link here:
https://github.com/P-i-N/conco
Cheers!
https://redd.it/1pwvui8
@r_cpp
Hi all,
I made a small header-only library called
conco ("console commands") designed to make building simple command interpreters, REPLs, or Quake-like game consoles trivial.The core idea is to take a raw string like
add 10 20 and automatically dispatch it to a C++ function like int add(int x, int y);. The library handles tokenization, type conversion, argument passing and result stringification for you.You can bind regular functions, capturing lambdas or member functions as your commands. There is no global state and no dynamic memory allocations. The library is well suited for embedded development, where creating text-based debug interfaces over UART/serial port might come handy.
Basic example:
void logenable() { ... }
int sum(int a, int b) { return a + b; }
int main()
{
// List of available commands
const conco::command commands[] = {
{ logenable, "log.enable;Enable logging" },
{ sum, "sum;Sum of two integers" }
};
// Calls
log_enableconco::execute(commands, "log.enable");
char buffer256 = { 0 };
// Calls
sum(123, 456), writes stringified result to bufferconco::execute(commands, "sum 123 456", buffer);
std::println("{}", buffer); // Outputs: 579
}
I would love to hear your feedback or roast of the implementation! Check out the GitHub repository link here:
https://github.com/P-i-N/conco
Cheers!
https://redd.it/1pwvui8
@r_cpp
GitHub
GitHub - P-i-N/conco: C++ header only library for building REPL-like interfaces
C++ header only library for building REPL-like interfaces - P-i-N/conco
uniOS - A scratch-built x86-64 operating system kernel written in C++20.
https://github.com/unionyxx/uniOS
https://redd.it/1pwy0p7
@r_cpp
https://github.com/unionyxx/uniOS
https://redd.it/1pwy0p7
@r_cpp
GitHub
GitHub - unionyxx/uniOS: A scratch-built x86-64 operating system kernel written in C++20.
A scratch-built x86-64 operating system kernel written in C++20. - unionyxx/uniOS
I’m building a small C++ rendering library (VGLX). Feedback welcome.
I’ve been working on a small C++ rendering library called VGLX.
The goal is clarity over features. Explicit ownership. Minimal magic.
Some constraints I set for myself:
* Modern C++ (C++20).
* OpenGL backend for now. Vulkan later.
* Asset importing is offline. Runtime loaders only deal with engine-native formats.
* No global asset managers or hidden caches.
* Scene graph and lifetimes are explicit and boring by design.
It’s not a game engine. It’s closer to a rendering library you can read, reason about, and extend.
Docs + examples:
[https://vglx.org]()
Repo:
[https://github.com/shlomnissan/vglx]()
If you have opinions on API shape, ownership, or things that look wrong, I’d like to hear them.
https://redd.it/1px91ls
@r_cpp
I’ve been working on a small C++ rendering library called VGLX.
The goal is clarity over features. Explicit ownership. Minimal magic.
Some constraints I set for myself:
* Modern C++ (C++20).
* OpenGL backend for now. Vulkan later.
* Asset importing is offline. Runtime loaders only deal with engine-native formats.
* No global asset managers or hidden caches.
* Scene graph and lifetimes are explicit and boring by design.
It’s not a game engine. It’s closer to a rendering library you can read, reason about, and extend.
Docs + examples:
[https://vglx.org]()
Repo:
[https://github.com/shlomnissan/vglx]()
If you have opinions on API shape, ownership, or things that look wrong, I’d like to hear them.
https://redd.it/1px91ls
@r_cpp
Unlocking the value of C++20 - Alex Dathskovsky - Meeting C++ 2025
https://www.youtube.com/watch?v=5h4djuyx4Nk
https://redd.it/1pxdmaw
@r_cpp
https://www.youtube.com/watch?v=5h4djuyx4Nk
https://redd.it/1pxdmaw
@r_cpp
YouTube
Unlocking the value of C++20 - Alex Dathskovsky - Meeting C++ 2025
Unlocking the value of C++20 - Alex Dathskovsky - Meeting C++ 2025
Slides: https://slides.meetingcpp.com
With C++23 already making headlines and C++26 on the horizon, it’s tempting to focus on the bleeding edge. But in practice, many companies are still…
Slides: https://slides.meetingcpp.com
With C++23 already making headlines and C++26 on the horizon, it’s tempting to focus on the bleeding edge. But in practice, many companies are still…
Seeking advice on building a strong C++ gameplay portfolio
Hi all,
I’m looking for technical, portfolio-focused advice from experienced game developers, especially those with backgrounds in C++ gameplay programming, simulation-heavy systems, or grand strategy–style games.
I’ve been working with C++ for a while and have built several projects in the past, including:
* A small custom engine (core loop, input, minimal rendering),
* Some physics and systems experiments,
* And a few gameplay-focused prototypes.
Recently, I made a decision I now question: I deleted all of those projects because I felt they were “not good enough” or didn’t reflect the level I want to reach. In hindsight, this feels less like quality control and more like a destructive reset loop.
My long-term goal is to become a gameplay programmer on complex, systems-driven games (grand strategy like EU/CK/Victoria, but also action games like Soulsborne / Monster Hunter). My primary interest is gameplay logic and simulation.
I’m also open to learning game engine development at a foundational level (architecture, update loops, data flow, tooling), but I see that as a secondary path that supports gameplay work, not as a goal in itself. I’m deliberately trying to avoid spending years on graphics or low-level tech that doesn’t translate into better gameplay systems.
What I’m trying to understand, from a technical and strategic standpoint:
* What kinds of C++ projects actually make a strong gameplay-focused portfolio today?
* How do you decide a project is “good enough” to keep and present, rather than delete and restart? (I tend to restart when I notice architectural flaws or design weaknesses. At what point is refactoring and iteration more valuable than starting from scratch?)
* How do you structure learning so projects accumulate value over time instead of being thrown away?
* If you were starting again today, aiming for a C++ gameplay programmer role, what would you build first, and what would you deliberately not build?
I’m not looking for motivation or generic encouragement.
Thanks in advance to anyone willing to share experience or critique this approach.
https://redd.it/1pxd8w7
@r_cpp
Hi all,
I’m looking for technical, portfolio-focused advice from experienced game developers, especially those with backgrounds in C++ gameplay programming, simulation-heavy systems, or grand strategy–style games.
I’ve been working with C++ for a while and have built several projects in the past, including:
* A small custom engine (core loop, input, minimal rendering),
* Some physics and systems experiments,
* And a few gameplay-focused prototypes.
Recently, I made a decision I now question: I deleted all of those projects because I felt they were “not good enough” or didn’t reflect the level I want to reach. In hindsight, this feels less like quality control and more like a destructive reset loop.
My long-term goal is to become a gameplay programmer on complex, systems-driven games (grand strategy like EU/CK/Victoria, but also action games like Soulsborne / Monster Hunter). My primary interest is gameplay logic and simulation.
I’m also open to learning game engine development at a foundational level (architecture, update loops, data flow, tooling), but I see that as a secondary path that supports gameplay work, not as a goal in itself. I’m deliberately trying to avoid spending years on graphics or low-level tech that doesn’t translate into better gameplay systems.
What I’m trying to understand, from a technical and strategic standpoint:
* What kinds of C++ projects actually make a strong gameplay-focused portfolio today?
* How do you decide a project is “good enough” to keep and present, rather than delete and restart? (I tend to restart when I notice architectural flaws or design weaknesses. At what point is refactoring and iteration more valuable than starting from scratch?)
* How do you structure learning so projects accumulate value over time instead of being thrown away?
* If you were starting again today, aiming for a C++ gameplay programmer role, what would you build first, and what would you deliberately not build?
I’m not looking for motivation or generic encouragement.
Thanks in advance to anyone willing to share experience or critique this approach.
https://redd.it/1pxd8w7
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Saucer v8 released - A modern, cross-platform webview library
A new version of saucer has been released!
The update includes a refactor of the C-Bindings as well as (optional) C++ Exception support for exposed functions as well as some other QoL features such as a build-hook for refreshing embedded files!
I have also refactored the README a little, as suggested in reply to an earlier update post :)
Feel free to check it out! I'm grateful for all kinds of feedback :)
GitHub: https://github.com/saucer/saucer
Documentation: https://saucer.app/
https://redd.it/1pxr169
@r_cpp
A new version of saucer has been released!
The update includes a refactor of the C-Bindings as well as (optional) C++ Exception support for exposed functions as well as some other QoL features such as a build-hook for refreshing embedded files!
I have also refactored the README a little, as suggested in reply to an earlier update post :)
Feel free to check it out! I'm grateful for all kinds of feedback :)
GitHub: https://github.com/saucer/saucer
Documentation: https://saucer.app/
https://redd.it/1pxr169
@r_cpp
GitHub
Release saucer v8.0.0 · saucer/saucer
saucer v8.0.0
👽 Author Note
Greetings! After a small chat with our terrestrial professionals a few days ago, I was made aware that earthlings celebrate some sort of hallucinogenic adventure at th...
👽 Author Note
Greetings! After a small chat with our terrestrial professionals a few days ago, I was made aware that earthlings celebrate some sort of hallucinogenic adventure at th...
Mike shah if you are reading this your playlist is goated.
got a job because of that guy
https://redd.it/1pye51z
@r_cpp
got a job because of that guy
https://redd.it/1pye51z
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community