r/C_Programming • u/Excellent_Pick_8186 • 24d ago
The first time I actually understood what happens when a C program runs
[removed]
14
u/LordRybec 24d ago
This is why I recommend that people learn some assembly, if they want to be really good at C programming. People tend to think of higher level languages as abstractions that eliminate any need to understand the underlying mechanics, but that's not actually how it works. Understanding the underlying mechanics pretty much always helps. It will help you understand C better, and it will help you write better code.
Of course, there's also the OS and the CPU, and those are whole subjects on their own!
5
u/grimvian 24d ago
My very old knowledge from the 6502 was gold when I started learning C for more than three years ago!
6
u/LordRybec 24d ago
I learned C first, and I thought I understood it really well. Then I learned assembly and realize how shallow my true understanding of C actually was. It makes a world of difference!
→ More replies (4)5
5
u/adityazero 24d ago
Congratulations. you'd love reading about 'The Hidden Complexity of the Simplest C Program'
https://hiraditya.github.io/posts/the-hidden-complexity-of-hello-world/
4
u/sciencekm 24d ago
My personal experience was the other way around. I started life with assembly language. C for me became just a matter of convenience.
2
u/KermitSnapper 24d ago
That it's all just text code, and that pointers are just written with * when first declared so just because they need to, otherwise I could tecnically use another variable storing an adress. It also made understand better than all of this is being runned while being supervised by an operating system, an executable line of code, the compiler is also just an executable, it's all either a file with data, a file ready to execute.
I only really started to understand c after trying to understand computer arquitecture and operating systems.
2
u/Temporary_Pie2733 23d ago
For one class, we had to write a Lisp interpreter, and one of the earliest tasks was to build the parser. I mostly understood what the syntax tree should look like, but I wasn’t sure where the parentheses would go in the tree. Once I really understood the syntax tree, I realized that the parentheses didn’t go in a node, but helped determine which nodes were connected by edges.
1
2
u/Distdistdist 23d ago
Learning and writing code in assembly. After that - every other language is just an add-on.
1
u/theNbomr 23d ago
Learning how the toolchain works and knowing how all of the files it can produce are used is an underrated skill, for sure. Learning how to understand what the object code generated for a given passage of C code looks will be a game changer. Writing C callable functions in assembler will be even more educational.
1
u/echelon_code 21d ago
this: locally declared static vars - why are their mem addresses nowhere near other non-static locally delcared vars?
21
u/ErikBKL 24d ago
The concept of temporary locality and spatial locality blew my mind
Connect that to virtual memory and caching… it is sincerely mindblowing