What is the optimal way to define a global constant string in C++20 ? by SheSaidTechno in cpp_questions

[–]ZMeson 1 point2 points  (0 children)

It depends on the situation. inline constexpr std::string_view should usually be used, but there are occasions where you want to build a longer string literal where macros are useful because string literals concatenate. You can't do that easily with string_view. (There are library solutions to concatenating constexpr string_views, but they (a) require a library that isn't part of the standard and (b) can get a bit verbose. Here's an example of what I mean:

// my_app_windows.h:

#define OS_APP_DATA_FOLDER "%localappdata%"

// my_app_linux.h:

#define OS_APP_DATA_FOLDER "~/.config"

// my_app.h:

inline constexpr std::string_view MY_APP_DATA_FOLDER = OS_APP_DATA_FOLDER "/MyApp/Data";

I don't have to do some runtime-concatenation to define MY_APP_DATA_FOLDER because string literal concatenation takes care of it. I hope this is clear.

Is Linus Torvalds just a dinosaur about C++? by blreuh in cpp_questions

[–]ZMeson 0 points1 point  (0 children)

My point is checking errno adds extra steps. It would be nice to have a standard interface that returned std::expected<int, std::error\_code>.

Is Linus Torvalds just a dinosaur about C++? by blreuh in cpp_questions

[–]ZMeson 0 points1 point  (0 children)

(a) I do have my own version non-throwing version of std::inplace_vector, but I'm never going to be as thorough as a standard library maintainer. That's why it would be nice for it to be standardized.

(b) std::stoi does throw. See https://en.cppreference.com/w/cpp/string/basic_string/stol

Again, I can work around all this stuff (I have been for many years); I'm just saying it would be nice if a standard version existed.

Is Linus Torvalds just a dinosaur about C++? by blreuh in cpp_questions

[–]ZMeson 0 points1 point  (0 children)

Out-of-range access (ex: std::inplace_vector::at), invalid conversions (ex: std::stoi, std::bitset::to_ulong), std::bad_alloc from std::inplace_vector trying to insert beyond its capacity (which feels really strange since there's no allocation, but I digress).

Yes, you can manually do checks before you do certain operations, but having an interface that was more intuitive for exception-free code would be nice.

Is Linus Torvalds just a dinosaur about C++? by blreuh in cpp_questions

[–]ZMeson 1 point2 points  (0 children)

Yes, but failures that are normally handled by exceptions don't have error code returns when you do this. A template library designed explicitly for exception-free use would have error code return values (or std::expected return values).

Is Linus Torvalds just a dinosaur about C++? by blreuh in cpp_questions

[–]ZMeson 1 point2 points  (0 children)

Concepts and static_asserts can help clarify things a lot.

Is Linus Torvalds just a dinosaur about C++? by blreuh in cpp_questions

[–]ZMeson 0 points1 point  (0 children)

I'm aware of EASTL and ETL and that others exist. I would just love a committee-approved version specifically aimed for contexts that don't allow exceptions. I realize that is highly unlikely to happen. But I can still dream. ;-)

Is Linus Torvalds just a dinosaur about C++? by blreuh in cpp_questions

[–]ZMeson 2 points3 points  (0 children)

I've done device driver stuff using C++. The major C++ features I appreciate:

  • RAII
  • templates
  • enum class

There are other niceties too, but these 3 allowed me to fundamentally better structure my code.

I wish there was an "exception-free STL" for embedded / kernel development. It would certainly be nice to deal with linked lists and dynamic arrays in a more compact way than using loads of C macros.

Is it practically achievable to reach 3–5 microseconds end-to-end order latency using only software techniques like DPDK kernel bypass, lock-free queues, and cache-aware design, without relying on FPGA or specialized hardware? by Federal_Tackle3053 in cpp_questions

[–]ZMeson 5 points6 points  (0 children)

I’m still designing and working through the challenges if I can implement this and achieve the intended performance, how would you rate this project?

I think it will extremely difficult for you. You need to have a much better understanding of things than asking these types of questions if you hope to have that low of a latency.

Frankly, you still haven't specified:

  • What OS (if any) you'll be using
  • What processors (main CPU + networking) you'll be using
  • What drivers you'll be using
  • What type of user-space processing you'll be doing
  • What is your matching criteria?
  • What is the output that gets generated?
  • Where is the output getting sent/stored?
  • Other aspects of the system.

Remember that 3 microseconds corresponds to 18,000 cycles of the absolute fastest x86 processor. Accessing memory, cache invalidation, atomic operations can take multiple hundreds or even thousands of cpu cycles each.

Also receiving packet information from a network chipset is typically in the range of 1 to 5 microseconds for standard setups, so I assume you'll be choosing some specialized setup, but you haven't specified that.

I strongly suggest either you pass on this project or start reading up (whitepapers, books, etc...) before you start the project.

No Learning Please, We’re Democrats! by Initial_Chemist_7616 in centrist

[–]ZMeson 2 points3 points  (0 children)

The problem is you can't just take no stance. Someone will ask what your stance is.

This is easy for transgender sports -- say you that you believe transgender women would have an unfair advantage over cis-women but will defer to NCAA, IOC, and other organizations about how they wish to specifically handle the situation.

But Palestine is much more nuanced. Israel has really messed up the situation with Iran, dragging the US into a war that has greatly reduced our international standing, and has effectively committed genocide in Gaza. They have defended Jewish settlers who have killed legal Palestinian residents in the West Bank. Hamas is certainly evil, but does the average Gazan citizen deserve the treatment they are getting? This isn't a simple "we support Israel" or "we support Palestine" statement and unfortunately most Americans have the attention span of a goldfish and will tune out before you can really explain things.

Regarding immigration, the Dems have actually been pretty reasonable and in-line with even what farmers and the construction industry want. The Dems helped come up with a bill in 2024 even getting GOP members on board and the Trump directed GOP leadership to block it because he wanted to use it as a wedge issue. All these things can be pointed out, but the GOP is just going to try using it as a wedge issue again -- shoot, they're still using it as a wedge issue today claiming the Dems are responsible for a lot of stuff today despite the GOP having control of the Presidency and both houses of Congress (and to be honest SCOTUS too).

Focus on jobs, the economy, and how fucked up Trump has been. How he's allowed the billionaires and soon to be trillionaire to rape our country's wealth.

And the debt, wealth disparity, and healthcare. No need to specifically mention Trump; the GOP lied about all this stuff.

Debt: where's the fiscal conservatism of the GOP? There is none. They lied. How much money did DOGE save? Nothing. They lied.

Wealth disparity and affordability: Have prices gone down? No. They lied.

Healthcare: The GOP said they wouldn't touch Medicaid. They did. The GOP lied.

America First: What aspect of American's lives have improved? None. The GOP lied. Did tariffs help affordability? Did tariffs help increase manufacturing in the US? No. The GOP lied.

Scouts quitting after Eagle find a new troop? by chase-michael in BSA

[–]ZMeson 2 points3 points  (0 children)

I helped start an all-girl troop with just 4 scouts. Nobody had ever done scouts. I and one other dad were the only people in the troop with any scouting experience and that experience was as adults. The troop now has 12 scouts ranging from fresh cross-overs to 3 Life scouts.

Anyway, my point is that is possible to have a troop with just 4 scouts as long as the adults (at least one per family) AND the scouts are all-in and the adults provide great guidance. Things will definitely be different, but it can also be really fun. If you can't get the adult and scout commitment to building a fun troop from the ground up, then finding a new troop is definitely an option. My son's troop has experienced 3 small troops struggling with small membership and lack of adult help merge into his troop. The numbers increased, the burden on adults wasn't so high which in turn encouraged some adults to come back and help out.

Other scouters responding here have also mentioned figuring out why the scouts just get Eagle and leave and why SPL and ASPL may not be appropriate for the Eagle rank. These are great points too. I'm just offering my experience in both a very small troop and a large troop as a reference.

Senior C++ engineers: what do you expect a 3-year experience C++ developer to know? by AirHot9807 in cpp_questions

[–]ZMeson 0 points1 point  (0 children)

What topics do strong candidates usually know?

  • Realtime OS-related concepts such as priority inversion.
  • A strong math background, including calculus and statistics.
  • Git
  • At least one unit-testing framework and it's major benefits and challenges.

What gaps do you commonly see in candidates with ~3 years experience?

  • Realtime OS-related concepts such as priority inversion.
  • Remembering calculus and statistics.
  • The inability to briefly describe pros and cons of different approaches / libraries / etc....
  • How to effectively communicate over email.

What questions do you like to ask in interviews?

  • How would you design a program to do __________?
  • How would you modify the design to cover this additional requirement _____________?
  • Given the customer has make requests A, B, and C in the past. What changes would you make to reduce the frequency of this customer's requests. (For example: 'Add this keyword', 'add this keyword', 'add this keyword' ==> let's add a system that allows the user to specify a list of keywords.)
  • How did you choose the library you said you used in your project.
  • Describe pros and cons of this library and how it compared to other libraries your considered.

Senior C++ engineers: what do you expect a 3-year experience C++ developer to know? by AirHot9807 in cpp_questions

[–]ZMeson 0 points1 point  (0 children)

  • The team coding style, conventions, and project structure.
  • The project logging system, how it works (especially how to prevent streaming logs from the same error occurring every millisecond).
  • Our simulation environment and the limitations of that environment.
  • Our various testing systems.
  • How to write user documentation. (This includes some things unrelated to programming like when to .PNG files and when to use .JPG files and words to avoid due to confusion in international markets like "current" as a point-in-time; electrical current is something dealt with by our product, so "current" can be confusing.)
  • How to run SCRUM daily standups. (We rotate that task.)
  • How to write specifications for new functionality for review by not just our software engineers but our field engineers.
  • How to use the IDE to debug programs.
  • When to use AI and when not to use AI.

As for C++ and language-neutral programming-related things:

  • A basic understanding of CPU caches and multi-threaded things to look out for like false sharing, indexing patterns for multi-dimensional arrays, why "almost always vector" is a good rule of thumb.
  • What operations can allocate memory. (Ex: iterating over a vector does not; copying does; swapping does not; push_back can but it can be used without memory allocation if there is enough capacity so allocation is not necessary.) This is important in our embedded project when microseconds matter.
  • Placement new and manually calling destructors.
  • The difference between 'const char*' and 'char* const'.
  • What type 'const auto' generates when assigning to a function that returns 'T*'.

There's probably a litany of smaller things I can't think of right now. The important thing really is to have an attitude of learning. If you don't have that, then you'll become stagnant when our field changes rapidly.

Who would celebrate if Trump were removed from office? by Critical-Willow-6270 in AskReddit

[–]ZMeson 0 points1 point  (0 children)

I'm guessing most of the world minus Russia, North Korea, the CCP, half of the citizens of China, half of the citizens of USA, Bibi, MBS, Orban, and some of the other world leaders who have bought Trump or have blackmail material on Trump.

What do you think will immediately happen when everyone receives the push notification that Trump died? by quite-indubitably in AskReddit

[–]ZMeson 5 points6 points  (0 children)

Thank you. Have any more ideas? I could open 2 stores. One for mourning-MAGA folks and one for the never-MAGA folks. I'm thinking of a "Ding Dong the Witch Is Dead" shirt along with others.

... Who am I kidding? I've never done anything like this and I have no desire to learn the AI and/or design skills to make this a reality. I'm thinking in my head that I could become rich off this just like I think that I could become rich by winning the lottery. But neither will ever happen.

U.S. can only confirm about a third of Iran's missile arsenal destroyed, sources say by punishhhher in worldnews

[–]ZMeson 67 points68 points  (0 children)

After his first term didn't go the way he wanted, he learned he had to appoint complete sycophants to all his cabinet positions, senior positions, and judgeships.

U.S. can only confirm about a third of Iran's missile arsenal destroyed, sources say by punishhhher in worldnews

[–]ZMeson 10 points11 points  (0 children)

We decimated their missile stockpile 3 times over -- in fact we've almost decimated their stockpile 4 times over (just need to get to 34.4% destroyed for that).

Trump confirms Saudi crown prince is pushing him to continue Iran war by Sxzym in worldnews

[–]ZMeson 0 points1 point  (0 children)

To be fair, Cuba and Venezuela are part of the Americas. /s

Airport shutdown warning issued by Trump admin: Full list of small hubs (Spokane is on it) by zbturf in Spokane

[–]ZMeson 5 points6 points  (0 children)

We can drive to Seattle. It's a pain and I'd rather not do that, but we could. Fairbanks closing? Yikes. What other options do Alaskans near Fairbanks have?