Any C++ devs who got off the train and went C-only to focus their skill set and spend more time on picking up other archtectural type skills instead of keeping up with the new features and standards?
The rapid succession of new standards obviously overwhelms the compiler developers. Personally, I prefer code that is compatible with as many toolchains as possible and therefore stick with old standard versions. There is hardly a feature of the new standards that I miss. In the case of embedded systems with limited resources, I continue to work with C (and soon Micron).
I am a dev who work mostly on C-only codebases and it's so... relaxing when I get the opportunity to write C++ so I can use stuff like std::vector or std::string. I think of C++ as a scripting language. On the other hand, I'm not looking forward to reading other people's C++.
Mind if I ask what do you do? I'm trying a long shot to break into some C jobs but so far stuck with my data engineering job(yeah I know it's a long shot)
- Companies that manufacture hardware (drivers are often in C). People often think little when they think about Hardware, but it's much more than usually comes to mind. I bet you didn't think about Cars and Tractors when you thought Hardware.
- Companies that develop operating systems (like Google, which develops multiple OSes, Microsoft, Sony, Nintendo, Cisco, Synology, Apple, Samsung, etc).
- Companies that use or write low-level system libraries or software that needs to be absolutely fast (think OpenSSL (security), networking stuff, databases, gaming engines, virtualization, compilers, AI, virus scanners, etc).
- Companies that do Open Source stuff (a lot of Linux stuff is still written in C).
I have seen that managers decided to let something rewritten in C, for various reasons, mostly to set the language culture.
It seems obvious to me, that no C++ coder would switch voluntarily to C, since then he would reminded of the features he is missing every day glaringly.
So either you switch to Zig, Rust,... or (if you are finally fed up) to a functional language or you choose to code in a certain subset.
C++ has become a large language. Within any team it seems that each member has their preferred subset of the language. Going back to C only makes sense where C++ features do yield benefits. Personally I prefer code-reviews and project level standards/conventions to maintain cohesion and consistency.
I've seen a few people/companies do this and it always baffles me. You don't have to use every C++ feature in existence, but a little bit here and there is far more productive and safe than writing C.
You do, if you have to work with an existing code base in which every feature in existence was used.
Even if you start a new greenfield project and get to impose your own coding convention that includes what C++ features should be used, it won't stay that way when people come on board who have different ideas.
Think in object orientation: Put related nouns and verbs together: it is much easier to organize your thoughts using constructors and methods. However do not use virtual methods unless you really must, and if you do, make the class a well-defined explicit interface having only abstract methods. That said, avoid using implementation inheritance: overriding one defined method for another.
Get rid of pointers: When passing objects by reference, using references instead of pointers, especially reference to const, makes code much easier to read. When combined with vector instead of raw arrays, most uses of raw pointers go away.
Do not implement your own fancy data structures: instead use the Standard Template Library. I use STL map, set, and vector all of the time and they remove the need for most other data-structures. Also, when you can, use iterators to traverse these containers, rather than the visitor pattern. Using iterators keeps the control flow of the client contiguous, so it is much more flexible than visitors.
>Do not implement your own fancy data structures: instead use the Standard Template Library. I use STL map, set, and vector all of the time and they remove the need for most other data-structures.
Don't the STL tree and map data structures have notoriously poor performance?
From memory, std::map is comparatively slow because the spec requires pointers to indices to be stable. In practice it is slow; see khash and many others
Personally i don't think this matters too much; you're using c/c++; you're already fast
I mean it depends on the project and scope, but if you just write C-style code but use unique_ptr, vector, string, and <algorithm>, you're already at an advantage.
Take strings for example. In C you have to manually manage memory and there are a million pitfalls. Lots of programmers are lazy and use fixed-sized arrays and "unsafe" functions like strcpy which results in security vulnerabilities and large-input bugs. But even if you do it correctly you have all this mental overhead and lots of lines of code.
No because of the current active community around C++. The large standard template library is safer to use than in-house implementation of the same data structures. The C++ Boost library also gives you a large arsenal of utility functions that is vetted by the community.
I went from C++ for personal projects to Python for wrapper and C libraries with Python callable code. I basically prototype shit in pure python, and then if i decide i need more speed, I just rewrite the thing in C extension. Its pretty easy to do. ChatGPT can even do 90% of the work for you.
Python 3.12 without any C is usually fast enough for pretty much anything I do. Most of the bottleneck is latency, and for stuff I was using C for, mainly OpenCV for image processing, pytorch already has all the kernels that can run on Nvidia hardware that are way faster anyways.
How about C w/ Python? I think Python is better at high-level bits than C++ IMO, and you can use C or Cython modules that expose functionality that has to be fast.
https://250bpm.com/blog:4/
https://250bpm.com/blog:8/