I've been coding for over 20 years now! (WOAH, do I feel old)
I've touched just about every resource imaginable under the Sun (too bad they were bought out by Oracle)
The C/C++ preprocessor is still a feature I miss in virtually every other language I ever touch. The ability to transmute the actual code before it is parsed is invaluable in those environments. It also ties in directly with the inline ASM on your list, where the preprocessor can be used to select the proper ASM architecture for the given platform.
A great example of this is used in crypto libraries. They generally have a basic C/C++ implementation, but also optimized versions of certain routines for x86, x86-64, AES-NI, ARM, ARM-NEON, and more.
It is also nice to have platform-specific or build-specific flags that can toggle various parts of code on/off, or change things up entirely. This helps when porting code for example, because the path to a particular file may not be the same between Linux, BSD, MacOS, and Windows.
One last trick to mention. The preprocessor can also modify the linker. In one of my projects, I have preprocessor directives to link in static libraries. These libraries are compiler specific, so instead of creating countless different build scripts, I have a single CPP file with them all listed with different #ifdef tags to target each compiler.
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
Very cool stuff! I try to stay away from languages like C/C++ because I don’t love managing my own memory. That said, I’m always surprised with how powerful those languages are.
I've been coding for over 20 years now! (WOAH, do I feel old)
I've touched just about every resource imaginable under the Sun (too bad they were bought out by Oracle)
Self-managed memory does add some issues, but it also affords some great advantages, too! Last year I worked on optimizing a web server for a micro controller that only has 80KiB of RAM so it required a lot of custom fine-tuning of memory management to get the thing to perform well.
Here is an example of one method I converted from a C++ managed memory library to some unmanaged code to help reduce the RAM consumption: gist.github.com/darkain/23da34f00e...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The C/C++ preprocessor is still a feature I miss in virtually every other language I ever touch. The ability to transmute the actual code before it is parsed is invaluable in those environments. It also ties in directly with the inline ASM on your list, where the preprocessor can be used to select the proper ASM architecture for the given platform.
A great example of this is used in crypto libraries. They generally have a basic C/C++ implementation, but also optimized versions of certain routines for x86, x86-64, AES-NI, ARM, ARM-NEON, and more.
It is also nice to have platform-specific or build-specific flags that can toggle various parts of code on/off, or change things up entirely. This helps when porting code for example, because the path to a particular file may not be the same between Linux, BSD, MacOS, and Windows.
One last trick to mention. The preprocessor can also modify the linker. In one of my projects, I have preprocessor directives to link in static libraries. These libraries are compiler specific, so instead of creating countless different build scripts, I have a single CPP file with them all listed with different #ifdef tags to target each compiler.
Very cool stuff! I try to stay away from languages like C/C++ because I don’t love managing my own memory. That said, I’m always surprised with how powerful those languages are.
Self-managed memory does add some issues, but it also affords some great advantages, too! Last year I worked on optimizing a web server for a micro controller that only has 80KiB of RAM so it required a lot of custom fine-tuning of memory management to get the thing to perform well.
Here is an example of one method I converted from a C++ managed memory library to some unmanaged code to help reduce the RAM consumption:
gist.github.com/darkain/23da34f00e...