10
typodeaf
40d

Ok c++ professionals out there, I need your opinion on this:
I've only written c++ as a hobby and never in a professional capacity. That other day I noticed that we have a new c++ de developer at the office of which my first impression wasn't the greatest. He started off with complaining about having to help people out a lot (which is very odd as he was brought in to support one of our other developers who isn't as well versed in c++). This triggered me slightly and I decided to look into some of the PRs this guy was reviewing (to see what kind of stuff he had to support with and if it warranted his complaints).

It turns out it was the usual beginner mistakes of overusing raw pointers/deletes and things like not using various other STL containers. I noticed a couple of other issues in the PR that I thought should be addressed early in the projects life cycle, such as perhaps introduce a PCH as a lot of system header includes we're sprinkled everywhere to which our new c++ developer replies "what is pch?". I of course reply what it is and it's use, but I still get the impression that he's never heard of this concept. He also had opinions that we should always use shared_ptr as both return and argument types for any public api method that returns or takes a pointer. This is a real-time audio app, so I countered that with "maybe it's not always a good idea as it will introduce overhead due to the number of times certain methods are called and also might introduce ABI compability issues as its a public api.". Essentially my point was "let's be pragmatic and not religiously enforce certain things".

Does this sound alarming to any of you professional c++ developers or am I just being silly here?

Comments
  • 7
    never having heard of PCH is... :/
  • 6
    Yeah, I also don't have a single clue what PCH is.
  • 0
    Isn't PCH the thing that protects from multiple inclusions of the contents of a header? If not, I have no idea either. Been C++ dev since the 90s.

    Oh, pch.h, some MS thing for doing precompiled headers:

    https://stackoverflow.com/questions...
  • 1
    I think you are mistaking his ability to sound good on his resume as him knowing what he is doing.
  • 2
    It's fair to be a bit concerned.

    On shared_ptr: it's not so much the overhead of shared_ptr that has me worried, so much as that its use seems to indicate that various objects crossing the API boundary do not have well-defined lifetimes. Hitting the heap in the middle of low-latency work is generally a bad idea.
  • 0
    @Demolishun isn't multiple inclusion really prevented by mechanisms such as pragma or include cards in the headers themselves? I.e. preprocessor mechanisms, while precompiled headers is more a concept used to prevent that those system headers that rarely change won't be built every time, as that would significantly increase build time. From what I understand this is a cross OS thing that is supported in both clang and gcc. Not sure if it was originally pushed by Microsoft though, that's outside of my knowledge.
  • 0
    @halfflat that is a good point! I also assume that since it's real-time we will be dealing with small amounts of data at the time (in a streaming fashion), which probably makes copy faster than heap usage. I'm a bit torn whether copy or good memory locality on the heap is better for these types of thing though. Do you happen to have any insight? :)
  • 0
  • 0
    @typodeaf

    "isn't multiple inclusion really prevented by mechanisms such as pragma or include cards in the headers themselves?"

    Yeah, I was guessing, then I found out what pch means. Never had a call to use pch I guess. I always thought that detail would be handled by the compiler. I am working on several large projects right now that are mostly Linux based and there is no reference to pch anywhere. So apparently my colleagues have never heard of it either.
  • 0
    @Demolishun oh that is an interesting insight actually. I was under the impression that this was kinda standard stuff for, is or will be, large codebases as it has a really big impact on compilation time. Although I guess larger projects might also have more modular design that enables smaller compilation units, so that might be why many professionals haven't used it. I think it should have positive effect even on smaller projects though, but maybe it's not worth the overhead.
Add Comment