A convenient untruth: Array notation in C is a lie
blog.feabhas.com
A convenient untruth: Array notation in C is a lie
1–10 of 176 posts
Re: A convenient untruth: Array notation in C is a lie
#2It's not that convenient an untruth seeing as these are probably some of the first things you learn in C, and some of the first gotchas that'll getcha.
Having said that, the article was well written.
Re: A convenient untruth: Array notation in C is a lie
#3I don't know how this is a lie or untruth, even in jest. In a language that exposes memory management directly of course you can manually traverse an array.
Re: A convenient untruth: Array notation in C is a lie
#4Is this article a sign that C has fallen out of mainstream use?
Re: A convenient untruth: Array notation in C is a lie
#5Is this article a sign that C has fallen out of mainstream use?
What is "mainstream" these days?
Re: A convenient untruth: Array notation in C is a lie
#6Re: A convenient untruth: Array notation in C is a lie
#7I suppose this article is tongue-in-cheek but it doesn't really demonstrate lies in the C language. It does point out some of the quirks of arrays in C but not calling them real arrays is a matter of interpretation of terms. C defined what the term array meant for a lot of the languages that followed it. That today's languages have diverged from C's definition of array is not surprising.
Re: A convenient untruth: Array notation in C is a lie
#8Brings back fond memories of the first time I learned C, when I really had to dig into what the difference was between storage durations (auto/stack, dynamic/heap, static, thread local). It makes it increasingly important to think about when an object is going to be stored, and for how long. To me this is still a really useful concept that most high-level languages seem to have all disregarded in favor of extremely eager GC or refcounting, with the exception of Rust.
Re: A convenient untruth: Array notation in C is a lie
#9Is this article a sign that C has fallen out of mainstream use?
If by "mainstream use" you refer to applications then maybe yes. If you refer to embedded use, for sure not.
Re: A convenient untruth: Array notation in C is a lie
#10It's not that convenient an untruth seeing as these are probably some of the first things you learn in C, and some of the first gotchas that'll getcha. Having said that, the article was well written.
Some of the first things that people learn in C is the fallacy that "arrays and pointers are equivalent". An array is a series of contiguously laid-out objects that has a size known at compile time (except C99 VLAs). A pointer, on the other hand is merely a "single cell" that is supposed to contain an address and can be added/subtracted to, also dereferenced.
The truth is that array names decay to pointers except when the array is an operand to the `sizeof` or `&` operator.