Re:Should you learn C to “learn how the computer works”?
by Sir_Cmpwn on Tuesday October 02, 2018 @01:40PM
(#18123876)
You're joking. There's a very serious distinction between the stack and the heap - perhaps they live in the same memory but they are used very differently and if you mix them up your things will break.
[ Parent
| on HN ]
Re:Should you learn C to “learn how the computer works”?
by TheOtherHobbes on Tuesday October 02, 2018 @03:01PM
(#18124638)
There is no hardware distinction between stack memory and heap memory.
In fact C teaches a model of a semi-standard virtual architecture - loosely based on the DEC PDP7 and/or PDP11 - which is long gone from real hardware.
Real hardware today has multiple abstraction layers under the assembly code, and all but the top layer is inaccessible.
So there's no single definitive model of "How computers work."
They work at whatever level of abstraction you need them to work. You should definitely be familiar with a good selection of levels - and unless you're doing chip design, they're all equally real.
Re:Should you learn C to “learn how the computer works”?
by arcticbull on Tuesday October 02, 2018 @04:51PM
(#18125594)
There definitely is, unless there's a hardware heap pointer and hardware allocation and deallocation instructions, as there are for the stack :)
Re:Should you learn C to “learn how the computer works”?
by Sir_Cmpwn on Tuesday October 02, 2018 @06:24PM
(#18126207)
This isn't true. Modern instruction sets have clearly been influenced by and designed to optimize the C ABI.
Re:Should you learn C to “learn how the computer works”?
by rrauenza on Tuesday October 02, 2018 @02:05PM
(#18124123)
...like returning a pointer to the stack:
char *dupstr(const char *src) {
char new[1024];
strlcpy(new, src, 1024);
return new;
}