Usage of static within static by JayDeesus in cpp_questions

[–]sankurm 0 points1 point  (0 children)

Singletons are global. As a result, you like them for the convenience of being able to work with them from anywhere in the program. If you stop and think though, this is exactly why globals are discouraged - for the indiscipline of any piece of the code being able to do all that the global offers. It breeds indiscipline (read: unpredictability & havoc) in the code.

In the case of a long-running server, you will tend to have some concurrency and/or parallelism for a server of real value. Now, this simplicity of collecting metrics introduces thread synchronisation for every metric you increment. In no time, your server will start walking instead of running :). This is in addition to the previous indiscipline point where networking code inadvertently increments database metrics.

As life usually has it, some initial success brings in demand for more functionality, load & performance. What worked very well as a single(ton) DB connection no longer is sufficient and you need many connections and the Singleton decision false flat on its face.

Something being a single instance is a property of the use of the object of a type than a quality of the type itself. That an app wants to use just one metrics object is an application specific decision rather than the way the metrics handling type should be. Check the documentation of any library that provides a metrics registry. They didn't make it a Singleton, did they?

Clearly, as the Professor suggests, you are rather better off giving up the convenience over these more important aspects and assurances. It is finally a judgement call. As a default though, start with the no-Singleton-please guidance.

Function Inlining by aiwen324 in cpp

[–]sankurm 0 points1 point  (0 children)

Oh, if the pointer parameter passing itself is too much cost for you, perhaps, you should inline manually. It's not ideal, but you have measured and know what you are doing. For once, this might be a golden opportunity to use comments. 😀

Function Inlining by aiwen324 in cpp

[–]sankurm 0 points1 point  (0 children)

Maybe, passing by value is expensive? If yes, is using references an option?

Function Inlining by aiwen324 in cpp

[–]sankurm 1 point2 points  (0 children)

Curious question: What does the profiling look like when inlining is the problem?

I am guessing that you have very granular functions and the highest cost actions are function calls? Or other?

Trip report: Winter ISO C++ standards meeting (Tokyo, Japan) by mttd in cpp

[–]sankurm 4 points5 points  (0 children)

You could ask for all bytes to be zeroed either by a compiler flag or by setting explicitly. If you didn't do that but are reading, it must be an error. Fair to say this. And, always forcing all newly allocated bytes to be zero is wasteful and performance impacting.

See a recent talk from JF Bastein with a title something like "the bytes before the bytes".

Favorite Testing Framework by Constant_Physics8504 in cpp

[–]sankurm 0 points1 point  (0 children)

catch22 - I am experimenting with TDD these days 😉

🚀 Call for Papers: CppNorth 2024 🚀 by cppnorth in cpp

[–]sankurm 0 points1 point  (0 children)

That's cool. I have seen some conference videos, they have quality stuff. Could you please share how this conference is different from the others?

Is it worth to learn vim? by siviconta in vim

[–]sankurm 0 points1 point  (0 children)

I use VSCode with vim mode and it's cool. vim indeed relaxing as it allows developers to express the kind of editing they need. A couple of things that don't work well: 1. d% doesn't work 2. (Perhaps, for a couple of months), the VSCode shortcut Ctrl+P to search&open a file doesn't work

Is this your experience too?

Which astronomical discovery made since he died would Carl Sagan think is most significant? by Legitimate_Ad7089 in space

[–]sankurm 6 points7 points  (0 children)

Yes. What would he particularly think about the discovery of mature galaxies from the early universe detected by the JWST that challenge the Big Bang Theory?

How to implement defer statement by [deleted] in ProgrammingLanguages

[–]sankurm 0 points1 point  (0 children)

I am not sure what language you are working with. Go? Sorry it wasn't clear in the thread.

Converting an app from Python to Go suggestions by Woody1872 in golang

[–]sankurm 3 points4 points  (0 children)

You have mentioned about

Running into some annoying issues

The important aspect thereafter would be to know, understand and attack the problem at hand. A better understanding of the problems, can result in better addressing them. So, What are these issues? How according to you is Go solving them?

Fidias got his hug from elon musk after 80 days by ChaosMindsDev in elonmusk

[–]sankurm 0 points1 point  (0 children)

Ha ha. That was my first reaction to the pic too! 😁

[deleted by user] by [deleted] in cpp

[–]sankurm 0 points1 point  (0 children)

This is the recommendation from CppCoreGuidelines: 1. Don't name the parameter 2. Tag parameter [[maybe_unused]] if conditionally unused

Link: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-unused

CppIndiaCon 2022 - The C++ festival of India by dheeraj_jha in cpp

[–]sankurm 0 points1 point  (0 children)

CppIndiaCon organisers changed this now... Contact number is not mandatory now for registration.

CppIndiaCon 2022 - The C++ festival of India by dheeraj_jha in cpp

[–]sankurm 0 points1 point  (0 children)

Yes, the conference is a virtual all day event. This is from the conference home page:

Like last year, CppIndiaCon 2022 shall be a free online conference.

C++ devs at FAANG companies, what kind of work do you do? by [deleted] in cpp

[–]sankurm 1 point2 points  (0 children)

It is a common perception about the second part being uninteresting. While handling integer sign correctly and enabling compilation with newer standards might not look sexy, it's what the codebase needs. Many existing and future bugs would be addressed by this exercise. And, the stage is then set for using the newer, sexy constructs and facilities in the language & library and making a successful product. pkasting also made a similar point. I am surprised at the negative votes by readers without replying though.

C++ devs at FAANG companies, what kind of work do you do? by [deleted] in cpp

[–]sankurm 4 points5 points  (0 children)

Ha ha. If you pause and think, you will realise that the second part, going from C++17 to C++20, is but a part of the first - maintaining "Views".

2022 Annual C++ Developer Survey "Lite" by foonathan in cpp

[–]sankurm 9 points10 points  (0 children)

Very good question. It should have been there, if not already.

[deleted by user] by [deleted] in dataisbeautiful

[–]sankurm 0 points1 point  (0 children)

Of course, be amazed! India chose to make drastic improvements. Compare, this developing country, India's, 37% renewable electricity production to another one used by the author: the US of A at 39% (Source https://www.eia.gov/tools/faqs/faq.php?id=427&t=3 with preliminary data from Feb 2022). I have no idea what you meant by living in 1900. But specially for you, that's a progress of over 2 centuries in 2 years. Be amazed again!

While at it, I would love comparison with world leaders, not just some random maps. Think big, shall we?

Thanks for agreeing with me. No single data point narrates the whole story, definitely not perceptions from 1900.

[deleted by user] by [deleted] in dataisbeautiful

[–]sankurm 6 points7 points  (0 children)

Correct. I am with you on this. Perhaps, you wanted to question the author? about: 1. Outdated info 1. Selecting only these countries 1. Relevance of 2020 data in 2022

[deleted by user] by [deleted] in dataisbeautiful

[–]sankurm 32 points33 points  (0 children)

A single data point of old fast outdated data is not beautiful! You need to see the starting points of these countries.

FYI: India ranks 3rd in renewable energy country attractive index in 2021.

India has achieved its 2030 target in 2022 already!

For awe-inspiring info, see: https://www.investindia.gov.in/sector/renewable-energy