5 ms·
Lack of support for type-safe containers (need to be hack toghether via macros) and overreliance on macros in general (which are not IDE and debugger friendly)
by badpun 29d ago
Lack of support for type-safe containers (need to be hack toghether via macros) and overreliance on macros in general (which are not IDE and debugger friendly) are two aspects of C that are off-putting for majority of people in 2026. That's even assuming you're willing to forego pointer/memory safety.
- flohofwoe 29d agoIndeed, picking C doesn't make sense when you actually want to write C++ code in C ;)
- wasmperson 29d ago> Lack of support for type-safe containers (need to be hack toghether via macros) Are templates really so much better than macros that the latter deserve to be called a "hack"? The following two examples are both type-safe and have roughly the same semantics and #LoC: Macros: // pair.h struct id(pair) { T a, b; }; static inline struct id(pair) id(make_pair)(T a, T b){ return (struct id(pair)){ .a = a, .b = b }; } #undef id #undef T // main.c #include <stdio.h> #define T int #define id(n) n ## _int #include "pair.h" int main(void){ struct pair_int p = make_pair_int(12, 13); printf("%d %d\n", p.a, p.b); } Templates: //pair.h template<typename T> struct pair { T a, b; }; template<typename T> pair<T> make_pair(T a, T b){ return (pair<T>){ .a = a, .b = b }; } //main.cpp #include <stdio.h> #include "pair.h" int main(void){ pair<int> p = make_pair(12, 13); printf("%d %d\n", p.a, p.b); }