Live data from Hacker News

Should you learn C to “learn how the computer works”?

words.steveklabnik.com

71–80 of 381 posts

Re: Should you learn C to “learn how the computer works”?

#71
post #63

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…

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”?

#72
C 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 figure out what's going on.

That simplicity and the smallness of the C language makes it truer to the hardware underneath and as you don't need to descend through layers of frameworks, like a high level language such as python, to understand what the heck is going on.

Re: Should you learn C to “learn how the computer works”?

#73

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.

Re: Should you learn C to “learn how the computer works”?

#74

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…

> 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). I'd argue you should know how that works. Cache-misses, pipelining and all these subtle performance intricacies that seem to have no rhyme or reason just fall out out understanding exactly how you…

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.

Re: Should you learn C to “learn how the computer works”?

#75
post #58

C doesn't necessarily teach you how computers work. But it does teach you how software works. Our modern software empire is built on mountains of C, and deference to C is pervasive throughout higher-level software design. >You may have heard another slogan when talking about C: “C is portable assembler.” If you think about this slogan for a minute, you’ll also find that if it’s true, C cannot be how the computer work…

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”?

#76
If you don't know C and it would be the lowest-level language you would otherwise know, you should learn it.

Same with assembly.

Same with writing your own operating system in some combination of C and assembler. At that point you're really targeting the hardware and getting a better idea about how everything works.

There's no question as to the value of knowing these things. Should learning them be a top priority for you? Depends on you.

Re: Should you learn C to “learn how the computer works”?

#77
post #58

Earlier 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.

Or passing by value vs passing a pointer, or the importance of memory management... Modern languages solve problems created developing in legacy languages (primarily C). The issue is that knowing a solution without knowing the prior problem which the solution addresses, doesn't really lend itself to clarity.

They don't solve problems created by C, they just solve problems C doesn't. The problems still exist, and sometimes the high-level compiler even picks the wrong solution. Learning C helps you understand when and why this has happened.

Re: Should you learn C to “learn how the computer works”?

#78
post #53

I 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 stopped reading when I got to "C also operates inside of a virtual machine."

The very next section, beginning on the very next line, begins to explain what the author means.

Re: Should you learn C to “learn how the computer works”?

#80
For someone coming from a high(er)-level programming language like Python - who wants to learn more about how computers work - I think it would be a useful stepping to learn C. C introduces some of the concepts and techniques that you need to understand Operating Systems & lower level things like that.
Post reply on HN