I think the article is well-presented and educational.
I don't think so. Anyone with a solid understanding of C understands pointer arithmetic. I think the article isn't obvious only to those who have a weak understanding of the language.
I got asked some years back why I defaulted to C in some interview questions -- I grew up with the language, understand the nuances and many of the implementations.
It's now possible to make your way through a university education in CS without ever touching or understanding C. This is a problem.
I did not study CS, but I had a number of CS modules/classes. LaTeX was the only programming language I recall using. Students with better handwriting could probably get away with not doing any programming at all.
It's not clear to me that this is a problem, but I imagine that the systems requirement of most CS programs will involve C.
For what it's worth, I default to python in interviews even though it's my least favorite out of the languages that I use frequently.
Why is that ? I would image that you'd use the language you are most comfortable with and trust the most during an interview ? What makes Python a good 'interview' language but a less good bread and butter language for you ?
I really like the modern incarnations of C++ and statically typed ML-influenced, but not necessarily ML-derived, languages.
There are many criticisms that one could make about R, but I like some of its lispier features.
I suppose that this is the case. But really, to me this is article does not reveal anything beyond what I already knew from basic pointer arithmetic.
Having done even a semester of any type of assembly (not just part of a class) is probably enough. Other /low level/ languages like Forth (Imagine you /only/ had assembly, and wanted to build something a /little/ less painful) could probably work too.
Hi! Could you take a guess at what percentage of C programmers who write C professionally fit your definition of that (I realize you were being hasty in your phrasing, but still)?
Obviously your answer should be betweeen 0% (no programmer who writes C professionally) and 100% (every programmer who writes C professionally.)
I'm genuinely curious what you think! Thanks :)
I very much doubt that 85% of C programmers know these things. It would be interesting to find out!
And what's wrong with learning something from an article? This is really not about pointer arithmetic at all. Rather it's about a particular use of C's near-infinitely composable type system.
I must nitpick. sizeof may or may not be evaluated at compile time. It is not possible to always evaluate it at compile time (see VLAs). The standard even includes an example of this:
#include <stddef.h>
size_t fsize3(int n)
{
char b[n+3]; // variable length array
return sizeof b; // execution time sizeof
}
int main()
{
size_t size;
size = fsize3(10); // fsize3 returns 13
return 0;
}I find C somewhat logical, but it has an easy-to-learn simplified version of itself that can be learned before re-reading the spec to complete your understanding of the language.
? I'd reword that to say humans are more entertained by a small set of complicated rules. Simple rules are easy for humans, but they can be boring.
However, in reality here, we're comparing apples to oranges. The instruction set for a computer is it's language. Asking a computer to speak English - that's our (humans') language, and with the tables turned, one could ask whether the computer thought better in English or Chinese, and the answer may be different but still meaningless.
C evolved in a different age and is fraught with undefined behavior.
You just need to get it, and really its no harder than, say context managers in python, or promises in js. Its not relevant at what 'level' those constructs are. They are novel in they way in which they model and solve real problems in context.
So 'lack of clarity' is really due to misunderstanding the context and problem space the langue was made to operate in.
rather than calling out that pointer arithmetic implicitly relies on 'sizeof' in order to be useful, its treated like some kind of magic. i.e. i don't think it points out the not subtle but rather obvious connection, and instead distracts from it...
>rather than calling out that pointer arithmetic implicitly relies on 'sizeof'
Article:
>arr has the type int , where as &arr has the type int ()[size].
For me this is calling out the implicit use of sizeof by pointing out the type.
There's a reason this meme exists: http://i.imgur.com/Z6pFTjj.jpg