C is all about fixed length arrays accessed by indexes called pointers.
// Variables are effectively stored in arrays of length one.
int i = 1;
// Let's get a pointer to the array element that i is stored in.
int *a = &i;
// Now we can modify i through the pointer into the array it is stored in.
a[0] = 2;
// Just like with an explicit array.
int q[4];
// But the array evaluates to a pointer to its first element.
int *r = q;
// But the elements are modified in the same way.
r[0] = 1;
// Since the array evaluates to a pointer to its first element we can skip using r.
q[0] = 2;
C is reasonably simple once you understand that it is:
All about arrays.
A primitive language designed to make mediocre compilers easy to implement.
Point 2 is why C is so wide-spread -- writing a shoddy C compiler is very easy, so there are shoddy C compilers for pretty much everything.
Writing a good optimizing C compiler is quite difficult, so it took considerable time for C implementations to become competitive with assembly.
Writing a good optimizing C compiler is quite difficult
Still infinitely easier than for something like C++ though, which means there's not only more bad compilers but also better good compilers.
Also, to expand a bit on the array thing: that's actually a huge benefit when comparing to other languages, since arrays (unpartitioned, sequential bytes in memory) play very nice with caching, which has led to arrays performing better than other data structures even where it's counter-intuitive, like deleting elements faster than linked lists.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
C is all about fixed length arrays accessed by indexes called pointers.
C is reasonably simple once you understand that it is:
Point 2 is why C is so wide-spread -- writing a shoddy C compiler is very easy, so there are shoddy C compilers for pretty much everything.
Writing a good optimizing C compiler is quite difficult, so it took considerable time for C implementations to become competitive with assembly.
Thank you for the in-depth comment - I'll be sure to keep this in mind in the coming weeks 😄
Still infinitely easier than for something like C++ though, which means there's not only more bad compilers but also better good compilers.
Also, to expand a bit on the array thing: that's actually a huge benefit when comparing to other languages, since arrays (unpartitioned, sequential bytes in memory) play very nice with caching, which has led to arrays performing better than other data structures even where it's counter-intuitive, like deleting elements faster than linked lists.