If you're doing metaprogramming using the C preprocessor, it's time to move to a more advanced language.
People often take bias to mean that a source is false or untrustworthy and I think this is a nice counterexample.
41–50 of 50 posts
If you're doing metaprogramming using the C preprocessor, it's time to move to a more advanced language.
People often take bias to mean that a source is false or untrustworthy and I think this is a nice counterexample.
If you're doing metaprogramming using the C preprocessor, it's time to move to a more advanced language.
On the other hand, I think it's sad that so much time and brainpower is going on contriving ways to get bad tooling to do something, rather than on the actual meat of the problem solving.
You'd think that in 50 years somebody could have invented a better preprocessor, and save the need for all the while(0) and other trickery needed for macros.
Today I learned that for modern processors, quicksort code is small enough that the compiler can inline them if the definition is visible during compilation. See here for comparison of isort function implemented using plain static functions vs the macro in TFA: https://godbolt.org/z/arGjPGhKE . It's not as flexible as the macro form (not being able to pass two arrays at once like the sortByAge example in TFA), but I…
Earlier quoted context omitted.
I wrote one back in 1983 or so for 16 bit DOS, too! A few years later, I was at a C++ conference where they asked me to sit on an "Ask us anything" panel. I was there along with the developers of Microsoft C, Borland C, etc. The first question was "do you still ship a version of your compiler that will run on a floppy disk system?" Vendor 1 said sure, and launched into a long description of how the files could be shu…
Wow, in 1983 I hadn’t even seen a hard disk in person!
That said, I hate the way a lot of programmers use the preprocessor. For me, macros should be just simple expressions or functions (i mean they sohould be invokeable like functions) . But very often, there's a lot of magic inside macros, making them hard to use, let alone understand.
Today I learned that for modern processors, quicksort code is small enough that the compiler can inline them if the definition is visible during compilation. See here for comparison of isort function implemented using plain static functions vs the macro in TFA: https://godbolt.org/z/arGjPGhKE . It's not as flexible as the macro form (not being able to pass two arrays at once like the sortByAge example in TFA), but I…
Did you try inline as well? Why are they not as flexible as the macro? Couldn't the swap not also process two arrays?
I guess you're right, since the function accepts a void pointer, it could also point to an array of two array pointers. So yes, it can also process two arrays.
Earlier quoted context omitted.
Maybe they don't want to move to a more advanced language, maybe they want to mess around with the C preprocessor. :)
If you want to show cleverness, by all means! I still use some primitive tools, and know there are better alternatives, but I'm not going to defend sticking with them. BTW, I did win the Obfuscated C contest one year, and (naturally) used the preprocessor: https://www.ioccc.org/1986/bright/bright.c
Earlier quoted context omitted.
About a year ago I had a look at a C compiler for 16bit computers, featured in disk form on I think Adrian's digital basement YT channel. The compiler was very basic, nothing like you'd expect from a compiler even from the dragon book. So simple and it was a production compiler too! Sadly I can't remember the name of it to reference here.
I wrote one back in 1983 or so for 16 bit DOS, too! A few years later, I was at a C++ conference where they asked me to sit on an "Ask us anything" panel. I was there along with the developers of Microsoft C, Borland C, etc. The first question was "do you still ship a version of your compiler that will run on a floppy disk system?" Vendor 1 said sure, and launched into a long description of how the files could be shu…