In my opinion, C really needs some officially supported reflection for the names of enums and such things. People have reinvented the wheel so many times and it never quite gets there.
In my opinion, C really needs some officially supported reflection for the names of enums and such things. People have reinvented the wheel so many times and it never quite gets there.
without JSON macro:
char* j = "{ \"key\": [\"value1\", \"value2\"]}";
with JSON macro:
char *j = JSON({ "key": ["value1", "value2"]});
But yes of course, due to the stringify no C values can be embedded - i wouldnt even know how one would solve this with a macro, but maybe someone has an idea and can comment on that.
C is good as it is an someone has the chance to hold all its features in his memory. If you need or want to complicate things, there's C++ or Rust.
People think they know C, in reality they never read ISO C document, aren't aware of the differences between ISO C standard library and POSIX, how each compiler handles ill formed no diagnostic required, implementation defined and UB parts of the standard, and to top that even better compiler specific extensions.
Nowdays C++ has inherited the same mentality as many performance minded C developers, which is a bit sad, given that during the 1990's it felt we had a better security first mentality, especially with the vendor specific frameworks that were shipped alongside the compilers.
Regarding static analysis tooling it is kind of sad that many developers still think they known better than the language authors themselves, as per Dennis own words,
> Although the first edition of K&R described most of the rules that brought C's type structure to its present form, many programs written in the older, more relaxed style persisted, and so did compilers that tolerated it. To encourage people to pay more attention to the official language rules, to detect legal but suspicious constructions, and to help find interface mismatches undetectable with simple mechanisms for separate compilation, Steve Johnson adapted his pcc compiler to produce lint [Johnson 79b], which scanned a set of files and remarked on dubious constructions.
-- http://cm.bell-labs.co/who/dmr/chist.html
And to come back to the original point, the worst part regardless of the language is that most tricks are done due to cargo cult and hearsay, without reaching to a profiler a single time.
I've never saw anyone claim that doing UB in Rust is okay because its wrapped in an unsafe block?
If anything I've saw the exact opposite of this, cases of UB in libraries is considered a bug almost always, vs in C or C++ where "its the users fault for doing the thing wrong".
I notice you spreading an awful lot of bs about rust lately, not sure what the deal is but its pretty childish and lame, not to mention objectively wrong.