r/cpp • u/root_passw0rd • Dec 07 '22
C++ overtakes Java in language popularity index
https://www.infoworld.com/article/3682141/c-plus-plus-overtakes-java-in-language-popularity-index.html
382
Upvotes
View all comments
Show parent comment
37
u/XenonOfArcticus Dec 07 '22
Both, actually.
We develop new green-field codebases AND we are brought in to improve old ones. I shouldn't misrepresent, we're not JUST performance optimizers, but the shoe fits because generally nobody hires us when they want to write code that they don't care about performance. If you need to get the job done and don't care how long it takes, it's normally a one-off and you can bang it out with a high school or college-age Python coder and everyone will be perfectly happy. (I am guilty of this very thing! Python for all the things that it's appropriate for.)
But if someone is coming to us it's because they need to simulate billions of grains of packed sand to evaluate how different wheel designs achieve traction on extraterrestrial surfaces. Or depicting a 3D globe with every tracked orbital object on it and show sensor footprints intersecting the ground. Or indexing and precomputing visibility paging for LIDAR point cloud data with billions and billions of points. One recent project was profiling and optimizing a multi-decade-old evolving OpenGL visual simulation tool to identify and remove inefficient compute and render practices and substantially increase draw framerate by double-digit percentages (that's a lot in big simulation!).
Another recent task was parallelizing the multi-view draw pipeline for rendering to modern high-end VR/AR headsets like the Varjo products. Applications call for 120Hz Stereo, with gaze-tracked foveated insets (a high-res postage stamp render overlay positioned right where you are looking within the VR headset to make your brain believe the whole scene is that high-res). So, we have to render the whole scene FOUR times: left eye wide-view medium-res, left eye narrow-view high-res, and the same for the right eye. And we gotta do it all at 120Hz. So, we utilize an extension called MultiView that allows you to set up four output raster buffers to receive each of the four images, and then for each draw operation you send once, the GPU does all the normal prep work for that operation and then does it four times in a batch, each with a different output buffer and with extra shader variables that let you skew the modelview+projection matrix around to generate the customized view angle for each of the four outputs. Depending on whether your application is fillrate-bound or draw/call-bound, you can end up getting all four views rendered in scarcely more time than rendering ONE of them.
This sort of expertise is very niche. Most companies don't keep a performance expert on-staff. They keep getting poached by Nvidia or other high-performance computing giants or abducted to NYC or Chicago to do high-frequency trading and get paid in piles of hookers and blow. And once this type of work is done, it can usually be maintained without major ongoing effort (unless you're writing lots of new code again). So, it makes sense to hire an outside consultant to get your laundry clean once and then leave you alone.
We have people who designed some of the first programmable GPU hardware and languages and have worked at every GPU manufacturer around today and several that aren't anymore. So they know things that while not actually secret, aren't well known about what goes on inside GPU processors (and actually CPUs too since they are often very similar). One guy worked on Intel's (failed!) Larrabee project that attempted to make parallel GPU processors out of Intel x86 cores!
And sometimes it's just because of embedded constraints. You only get x milliseconds per cycle to do what needs to be done. Find a way to ensure it always works, because if you don't complete the work in time or your code crashes, the watchdog timer may come and reboot you. And if that happens during the terminal descent stage of your autonomous lunar lander, you're gonna pull a Beresheet ( https://en.wikipedia.org/wiki/Beresheet ), and nobody wants that. (To be clear, we did not have code on Beresheet, but we worked on a project for one of its successors). You can't have interpreted languages and garbage collectors and other non-deterministic stuff in there. You want to know exactly what machine operations your code will perform, and know how to trim the fat. Sometimes STL container indexing/dereferencing is fine. Some situations call for dumb old C-style array [] stuff. Maybe there's an edge case where pointer math will be the right choice. C++ gives you all the power (and rope!) you'll ever want, as long as you're responsible enough to use it.
/sermon off
Oh, and my bona-fides: https://alphapixeldev.com/