C, Lisp, and probably many other languages have gone through a similar
historical arc - first they are designed to solve problems, and be a
useful and powerful means of expression - then they become official,
standardized, and legalistic - then they become commercially
competitive, and leverage the legalisms, benchmarks, and other
collateral that has accrued - at this point, generations later, the
language is evolving with no appreciation or understanding of the
aesthetic and practical principles of the original language effort.
My old-man-grousing for today.
On 11/18/2024 05:00 AM, Anton Shepelev wrote:
Dan Cross <crossd(a)gmail.com> wrote:
Programmer ability is certainly an issue, but I
would suggest that
another goes back to what Rob was alluding to: compiler writers have
taken too much advantage of UB, making it difficult to write
well-formed programs that last.
Following the letter, rather than the spirit, of
the standard?
The `realloc` function I mentioned earlier is a
good case in point;
the first ANSI C standard says this: "If ptr is a null pointer, the
realloc function behaves like the malloc function for the specified
size. ... If size is zero and ptr is not a null pointer, the object it
points to is freed." While the description of `malloc` doesn't say
thing about what happens when `size` is 0, perhaps making `realloc(0,
NULL)` nominally UB (??), the behavior of `realloc(0, ptr)` is clearly
well defined when `ptr` is not nil, and it's entirely possible that
programs were written with that well-defined behavior as an
assumption. (Worth mentioning is that this language was changed in
C99, and implementations started differing from there.)
But now, C23 has made `realloc(0, ptr)` UB, regardless of the value of
`ptr`
Something similar happened with so-called strict aliasing, when the
compilers started assuming pointers to incompatible types as always
pointer to different non-overlapping locations:
See, e.g.:
<https://www.geeksforgeeks.org/strict-aliasing-rule-in-c-with-examples/>
Linus ranterd about it: <https://lkml.org/lkml/2018/6/5/769>
My sense is that tossing in bad programmers is
just throwing gasoline
onto a dumpster fire. Particularly when they look to charlatans like
Robert Martin or Allen Holub as sources of education and inspiration
instead of seeking out proper sources of education.
I am a bad one as well, to
have liked some things in Martin's books
/Clean Code/ and /Clean Architecture/ . True, heis no Wirth, nor
Dijxtra, nor Knuth, but why a charlatan?