Earlier quoted context omitted.
I'd argue that you shouldn't be driving a car unless you've rebuilt a transmission yourself, but that argument wouldn't go far.
That'd be like saying your end user should understand cache misses, however if you're starting a car design/repair shop you might want to know about how transmissions work. The primary reason for dropping down to native is to get better performance. If you're going to do that you'll leave 10x-50x performance on the table if you don't understand cache misses, prefetching and the other things that manual memory placeme…
Should you learn C to “learn how the computer works”?
101–110 of 381 posts
Re: Should you learn C to “learn how the computer works”?
#102Re: Should you learn C to “learn how the computer works”?
#103You should learn C to learn what every language is loosely based on and what unrestricted memory access looks like. It's the programming equivalent of learning Latin. It isn't required, but you will be better at pretty much everything you do involving modern English, Spanish, French, etc., as you will understand where things came from. It's even more useful though, as in the programming language world pretty much eve…
Not really, there was a world of computing outside AT&T walls.
Lots of papers and computing manuals are available online for those that care about the actual history of computing.
Re: Should you learn C to “learn how the computer works”?
#104Earlier quoted context omitted.
A computer does not need to implement a stack What general purpose computer exists that doesn't have a stack? Push/pop have been fundamental to all the architectures I've used.
RISC-type architectures with a branch-and-link instruction (as opposed to a jsr- or call-type instruction) generally have a stack by convention only, because the CPU doesn't need one to operate. (For handling interrupts and exceptions there is usually some other mechanism for storing the old program counter.)
Re: Should you learn C to “learn how the computer works”?
#105What really made computers click to me was reading a book that had the premise: "learn just enough assembly to be able to implement C features by hand; we'll show you how". Sadly, I don't remember the title. Another 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 opt…
Re: Should you learn C to “learn how the computer works”?
#106I find this article to be disingenuous. Yes, C isnt "how a computer really works". Neither is assembly. The way a computer works is based off of transistors and some concepts built on top of that (ALUs for example). However, there is no need to know about any of that because you're presented with an abstraction (assembly). And thats really what people mean when they say C is closer to how a computer actually works: i…
But in addition to the mismatch between the abstractions provided and the real hardware, C qua C is missing a huge number of abstractions that are how real hardware works, especially if we pick C99 as Steve did, which doesn't have threading since that came later. I don't think it has any support for any sort of vector instruction (MMX and its followons), it doesn't know anything about your graphics card which by raw…
Can you elaborate? I thought I knew what register renaming was supposed to do, but I don't see the tight connection between register renaming and C.
Re: Should you learn C to “learn how the computer works”?
#107Earlier quoted context omitted.
> What that means is that most C operations can be easily translated into the machine code equivalents and that makes debugging of compiled code so much easier. A disassembly of many binaries will reveal their C roots by function calls being equivalent to jump statements, as an example. If you have the C source then you can usually figure out what's going on. This is very much not true in my experience. Optimization…
Why would you turn on optimization while debugging?
Re: Should you learn C to “learn how the computer works”?
#108What C teaches is that the underlying memory model is a flat, uniform, byte-addressed address space. One of the consequences of C is the extinguishing of machine architectures where the underlying memory model is not a flat, uniform, byte-addressed address space. Such as Symbolics or Burroughs architectures, or word-addressed machines.
We have our differences, but you’re totally correct here, and I’m not sure why you’re downvoted. The “byte addressable” thing is exactly why C was created over B, even, right? That was one of the crucial features not supported.
Re: Should you learn C to “learn how the computer works”?
#109Earlier quoted context omitted.
Why would you turn on optimization while debugging?
Sometimes the bugs don't happen when optimizations are off. (-:
EDIT: I suppose the other possibility is that the program is doing some weird things, like reading its own machine code from memory.
Re: Should you learn C to “learn how the computer works”?
#110Earlier quoted context omitted.
You can also learn that difference in something like C#. You don't need C for that. And C pretends there's a distinction between the stack & heap that doesn't actually exist. There is no significant difference there.
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.
char *dupstr(const char *src) {
char new[1024];
strlcpy(new, src, 1024);
return new;
}