4 ms·
C would be useful to the broadest audience. C++ programmers can read C while C programmers cannot always read C++, especially when the newer language constructs
by ryao 2y ago
C would be useful to the broadest audience. C++ programmers can read C while C programmers cannot always read C++, especially when the newer language constructs are used. I mentioned Python because of its popularity.
Interesting, the Algorithmica article the author cited is in C:
https://en.algorithmica.org/hpc/data-structures/s-tree/ https://en.algorithmica.org/hpc/data-structures/s-tree/
- npalli 2y agoC++ not C. The author explains his choices elsewhere in the site.
- ryao 2y agoThe code snippets should be accepted by a C compiler and therefore are valid C code.
- npalli 2y agoIf you want to be pedantic, there is a constexpr in the snippets, wont be accepted by the C compiler. More broadly though it is a C++ tutorial. I insisted on it because the author of algorithmica actually explains he chose C++ and perhaps sometime later C/Rust or something might be better. Should respect his POV.
- ryao 2y agoI had not seen the use of constexpr. You are correct that those are in C++.
- lubutu 2y agoC23 has constexpr, albeit only for objects, not functions. The code also uses namespaces, as in `std::aligned_alloc(P, T)`.
- ryao 2y agoYou have to be 1/3 down the page to see any of this in the code examples. By that point, you would already have seen a number of examples that are valid C code and it is reasonable to expect the rest to be. At least, that was my experience.