Should you learn C to “learn how the computer works”?
words.steveklabnik.com
Should you learn C to “learn how the computer works”?
1–10 of 381 posts
Re: Should you learn C to “learn how the computer works”?
#2But, pointers yes definitely. Even some assembly. You really should understand how things like .size or lengh() aren’t “free” and how they work.
Re: Should you learn C to “learn how the computer works”?
#3C... IDK. Maybe. But, pointers yes definitely. Even some assembly. You really should understand how things like .size or lengh() aren’t “free” and how they work.
That said, I 10000% agree that pointers are a thing that is great to learn.
> You really should understand how things like .size or lengh() aren’t “free” and how they work.
You're talking about strings here, right? This is not true in all languages, but certainly is true that these are not free in C :)
Re: Should you learn C to “learn how the computer works”?
#4Another revelation much later on, was, as discussed here, the realisation that C is indeed defined over an abstract machine. I think much of those realisations were because of reading about how crazy compiler optimizations can be and how UB can _actually_ do anything.
Re: Should you learn C to “learn how the computer works”?
#5C... IDK. Maybe. But, pointers yes definitely. Even some assembly. You really should understand how things like .size or lengh() aren’t “free” and how they work.
Funny enough, pointers are a great example of an abstraction provided by C that people assume is isomorphic to hardware, when they don't: https://blog.regehr.org/archives/1621 That said, I 10000% agree that pointers are a thing that is great to learn. > You really should understand how things like .size or lengh() aren’t “free” and how they work. You're talking about strings here, right? This is not true in all langu…
It costs O(1) in memory to delimit strings with a null terminator and O(n) in time to execute strnlen(), right? It's not free. Though, if you're lucky your string is in rodata and the compiler can calculate the sizeof() in advance, this is very-nearly-free.
EDIT: misunderstanding, disregard
Re: Should you learn C to “learn how the computer works”?
#6Re: Should you learn C to “learn how the computer works”?
#7C... IDK. Maybe. But, pointers yes definitely. Even some assembly. You really should understand how things like .size or lengh() aren’t “free” and how they work.
Funny enough, pointers are a great example of an abstraction provided by C that people assume is isomorphic to hardware, when they don't: https://blog.regehr.org/archives/1621 That said, I 10000% agree that pointers are a thing that is great to learn. > You really should understand how things like .size or lengh() aren’t “free” and how they work. You're talking about strings here, right? This is not true in all langu…
Re: Should you learn C to “learn how the computer works”?
#8Do you need to bake bread to eat it? No. Should you learn to bake it? Yes.
There are lots of things you should learn to do because they're useful and teach you about how the world works. The miracle of society is that you don't have to learn most of them to enjoy using them.
Re: Should you learn C to “learn how the computer works”?
#9Earlier quoted context omitted.
Funny enough, pointers are a great example of an abstraction provided by C that people assume is isomorphic to hardware, when they don't: https://blog.regehr.org/archives/1621 That said, I 10000% agree that pointers are a thing that is great to learn. > You really should understand how things like .size or lengh() aren’t “free” and how they work. You're talking about strings here, right? This is not true in all langu…
> You're talking about strings here, right? This is not true in all languages, but certainly is for C :) It costs O(1) in memory to delimit strings with a null terminator and O(n) in time to execute strnlen(), right? It's not free. Though, if you're lucky your string is in rodata and the compiler can calculate the sizeof() in advance, this is very-nearly-free. EDIT: misunderstanding, disregard
Re: Should you learn C to “learn how the computer works”?
#10Earlier quoted context omitted.
Funny enough, pointers are a great example of an abstraction provided by C that people assume is isomorphic to hardware, when they don't: https://blog.regehr.org/archives/1621 That said, I 10000% agree that pointers are a thing that is great to learn. > You really should understand how things like .size or lengh() aren’t “free” and how they work. You're talking about strings here, right? This is not true in all langu…
> You're talking about strings here, right? This is not true in all languages, but certainly is for C :) It costs O(1) in memory to delimit strings with a null terminator and O(n) in time to execute strnlen(), right? It's not free. Though, if you're lucky your string is in rodata and the compiler can calculate the sizeof() in advance, this is very-nearly-free. EDIT: misunderstanding, disregard