I 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…
> I find this article to be disingenuous. Yes, C isnt "how a computer really works". Neither is assembly. [...] He addresses all of that in the subsequent bullet points of his summary, and elaborates on it in the body of the article (your criticism stops at his first sentence of the summary). It goes into a nuanced discussion; it doesn't just make a blanket statement. I don't find it disingenuous at all.
Should you learn C to “learn how the computer works”?
81–90 of 381 posts
Re: Should you learn C to “learn how the computer works”?
#82Earlier quoted context omitted.
C at the very least teaches the difference between stack and heap memory, a crucial concept obscured by most higher-level languages.
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.
Re: Should you learn C to “learn how the computer works”?
#83I stopped reading when I got to "C also operates inside of a virtual machine." Is the author confusing virtual memory with virtual machine? Perhaps they're referring to the way a high level language abstracts away the details of the H/W. I didn't care enough to read on. That said, I learned the most about "how a computer works" in a class that taught Intel 8080 assembler on a system running CP/M. (Technically it was…
I'm confused as well. Klabnik is no doubt reading this thread. I'd like to know more about the "virtual machine" he supposes the C language targets.
Re: Should you learn C to “learn how the computer works”?
#84Earlier quoted context omitted.
C at the very least teaches the difference between stack and heap memory, a crucial concept obscured by most higher-level languages.
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.
Re: Should you learn C to “learn how the computer works”?
#85What 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.
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”?
#86C conceptually is the nearest layer to the hardware that you'll get outside assembler. 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 f…
This is very much not true in my experience. Optimization (even just -O1, which is required to make C be more worth writing than Python for large-scale apps) will do things like reorder statements, inline functions, elide local variables, set up tail calls, etc. It is a specific skill requiring experience to be able to understand what's happening when stepping through a C function in a debugger, even with source at hand and debugging information included. If you haven't been frustrated at "Value has been optimized out" or breakpoints being mystically skipped, you haven't done enough debugging work to really acquire this skill, and saying that C maps to the machine is just theory.
There is value in a highly unoptimized language toolchain for debugging, sure. But honestly CPython is closer to that than any production C binary you're likely to see.
Re: Should you learn C to “learn how the computer works”?
#87Earlier quoted context omitted.
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…
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.
Re: Should you learn C to “learn how the computer works”?
#88You'll avoid some really bad decisions that you might otherwise blindly walk into without that knowledge even in higher-level languages.
Re: Should you learn C to “learn how the computer works”?
#89Earlier quoted context omitted.
That bread analogy is on point. The old quote comes to mind, >A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyse a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die g…
I disagree with the bread analogy being on point. For one, it misses the fact that learning how to bake it doesn't benefit the eating process. Whereas, learning how to code in C benefits (but is not required) in general programming. I understand that analogies are always compromises because there is always going to be something that differs from the original motif. Also, analogies should be used when the motif is com…
Maybe it works differently for bread, but with whisky, learning how it has made has certainly enhanced my consumption, if only to give me the language needed to describe flavors and compare and contrast.
Re: Should you learn C to “learn how the computer works”?
#90C conceptually is the nearest layer to the hardware that you'll get outside assembler. 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 f…