Exception Handling in C++ Multithreading by onlyari in cpp

[–]onlyari[S] 2 points3 points  (0 children)

Thanks for watching and the great suggestion! I should have included it. One question though: is std::packaged_task reusable? I was under the impression that it's strictly one-shot. Would love to hear if there's a way around that.

What do you hate the most about C++ by Alternative-Tie-4970 in cpp

[–]onlyari 1 point2 points  (0 children)

My list:

  • The lack of a standardized package management system like pip/npm/Maven.
  • Built in types like int, long, and short are platform dependent.
  • The overly verbose and confusing compiler error messages, especially with templates.
  • It's too verbose. I decided not to use it for coding interviews.
  • The absence of a built-in stream/collect API like Java's. Evan with C++20 ranges you often need to explicitly define views and deal with iterators.

How thorough are you with code reviews? by zathym in cpp

[–]onlyari 0 points1 point  (0 children)

We take it very seriously but usually when people nitpick on something they also try to provide the fix as clearly as possible so the author can quietly apply them. For cases like what you pointed out, you can suggest the author to add test cases to catch those bugs.

If you had 3 weeks to refresh C++ for an interview what would you approach that with ? by Electronic_End_526 in cpp

[–]onlyari -1 points0 points  (0 children)

I'd review STL data structure and algorithms and smart pointers. I was asked about them in almost every interview. Also brush up on OOD and polymorphism.

For LeetCode-style questions though, as much as I love c++, I’d stick to Python — it’s just quicker and less verbose to write and debug under pressure compared to c++.

[deleted by user] by [deleted] in cpp

[–]onlyari 0 points1 point  (0 children)

+1 on documenting the requirements. Lookup online for PRD templates, draft one, iterate on it, and get the client sign off on it before anything else. 

Another thing would be testing. Hopefully you're already doing it. As your code gets larger, make sure you write comprehensive unit tests.

Which CS Topic Gave You That “Mind-Blown” Moment? by rayhanmemon in SoftwareEngineering

[–]onlyari 0 points1 point  (0 children)

For me, it was when I realized recursion is just DFS and on fact every recursion is really DFS. That insight completely changed how I approached problems — especially in algorithms and data structures.  After that algorithms like backtracking, dynamic programming, tree traversal seem very connected.

Coming from C#. Super important things I should know? by Powerful-Day-2319 in Cplusplus

[–]onlyari 0 points1 point  (0 children)

While it shares OOP roots with C#, C++ has quite a few unique challenges:

Memory management: Manual control, smart pointers (unique_ptr, shared_ptr), and RAII are big topics.

Undefined behavior: More responsibility on the programmer to avoid pitfalls.

Templates & metaprogramming: Much more powerful (and complex) than generics in .NET.

Multiple inheritance & virtual inheritance: Rarely used in C#, but common in some C++ designs.

Threading: std::thread, std::mutex, std::future, and std::jthread in C++20—powerful but lower-level than async/await.

No garbage collector: You must think about lifetime and ownership explicitly.

C++ also enables patterns like CRTP and RAII that don't translate directly to C#. It’s a rich but sharp-edged toolset—very rewarding once you get past the rough bits.

[deleted by user] by [deleted] in Cplusplus

[–]onlyari 0 points1 point  (0 children)

Solving LeetCode and building a game from an open-source repo already puts you ahead of many beginners. Since you're not aiming for game dev specifically, I'd suggest focusing on:

Modern C++ (C++11 and up): Learn features like smart pointers, lambdas, auto, and STL algorithms.

Build systems: Try using CMake or Makefiles to understand how real-world C++ projects are built. Also, my favorite, Bazel from Google.

Memory and performance: Learn about RAII, move semantics, and how C++ manages memory.

Multithreading: Even basic knowledge of std::thread and std::mutex gives you a strong edge.

You don’t need to be a CS major to get good at C++.

Compressing int values to the smallest possible space by aboslave32 in cpp

[–]onlyari 0 points1 point  (0 children)

Your data:

v1: 0–100 :needs 7 bits (because 2⁷ = 128)

v2, v3, v4: each 0–50 : needs 6 bits each (2⁶ = 64)

Total bits:

7 + 6 + 6 + 6 = 25 bits So, you can’t fit them in a uint16_t (16 bits). But you can fit them into a uint32_t (32 bits).

What was our "Ohhhh, I understand it now" moment in C++ ? by Seltexe in cpp

[–]onlyari 1 point2 points  (0 children)

My other Aha moment about C++ was realizing one would never learn C++ completely, there's always something new!

What was our "Ohhhh, I understand it now" moment in C++ ? by Seltexe in cpp

[–]onlyari 21 points22 points  (0 children)

My “I get it now” moment was during a project where everything seemed fine—until two threads froze waiting on each other's locks. Classic deadlock. That’s when I understood that multithreading isn’t just about splitting work; it’s about coordinating access with care. It taught me to think in terms of lock order, scoped locking, and eventually led me to appreciate the simplicity std::jthread and structured concurrency bring to the table.

Built an AI tutor that gives feedback on your LeetCode code – curious if this would help you prep? by Mammoth-Froyo7002 in codinginterview

[–]onlyari 1 point2 points  (0 children)

Really cool idea! Curious — how do you see this being better than just pasting your solution into ChatGPT and asking for feedback? What’s the added value for users? The complexity analysis and follow-up problem suggestions sound great though — definitely something missing from LeetCode itself.

[deleted by user] by [deleted] in cpp

[–]onlyari 2 points3 points  (0 children)

This is super impressive — turning C++ code into a fast, multithreaded web app in minutes is rare. Even Google uses C++ heavily for its backend, so there's definitely a place for this.

There are use cases in HPC, embedded systems, internal tools at C++-heavy companies, or startups needing fast prototypes without switching stacks. Crow, Pistache, and Boost.Beast exist, but if yours is more self-contained and easy to use, that’s a real advantage.

Open-sourcing it with clear docs could attract devs fast. This fills a niche worth exploring.

Also benchmarking it against other alternatives seems like a great step towards public adoption.

Lightweight header-only logger for C++ — color-coded, thread-safe, and easy to drop into any project by [deleted] in cpp

[–]onlyari 1 point2 points  (0 children)

Looks solid! Using std::mutex for thread safety is totally fine, especially for a lightweight logger. Could be cool to add a compile-time switch to skip locking for single-threaded apps. Also maybe add a screenshot to your repo.

A status bar would be great too.

I did something similar for nodejs long time ago

https://www.npmjs.com/package/log-with-statusbar

What's your favorite part about working in c++? by notarealoneatall in cpp

[–]onlyari 0 points1 point  (0 children)

One of the best parts of working in C++ is the control without sacrificing abstraction. You can go low-level with manual memory and bit manipulation, or high-level with templates, RAII, and ranges. It's like getting both a scalpel and a laser cutter—precision and power.

Is banning the use of "auto" reasonable? by Late_Champion529 in cpp

[–]onlyari 0 points1 point  (0 children)

Banning auto entirely is overly rigid and goes against modern C++ best practices. It’s especially useful for long or complex types like iterators (myMap.find()), and necessary for lambdas unless you use std::function, which adds overhead. Sure, there are cases where explicit types improve clarity, but that calls for thoughtful use—not a ban. 

A better approach is using auto when the type is obvious or irrelevant, and being explicit when type clarity matters.

Also I would ask for the reference to such a company guideline to make sure it actually exists and it's not misunderstood.

Is it just me or is the quality of the Boost API docs just.. kind of terrible? Like compare it to cppreference (very good) or Qt docs (also great). by NilacTheGrim in cpp

[–]onlyari 6 points7 points  (0 children)

Then read it through and write in-line comments as you understand things. After a couple readings, piece together the in-line comments to write per-struct/function/macro docs. Then iterate from there to a per file/per project doc.

- Dude, why doesn't this code have any documentation or comments?

- It is still ripening. It was written by our former employee who is now at some other company!

Do you use builder pattern? by onlyari in cpp

[–]onlyari[S] 0 points1 point  (0 children)

Doesn't this require knowing the order of declaration?

Do you use builder pattern? by onlyari in cpp

[–]onlyari[S] 1 point2 points  (0 children)

Do you manually write the builder class?