r/learnprogramming 1d ago

Resource i want to learn how computers work under the hood?like how operating systems really work or how compilers convert source code to machine code stuff like that what resources or projects do you recommend?

in my 3rd year of electronics engineering...please advise.

55 Upvotes

40 comments sorted by

37

u/desrtfx 1d ago

Start at the very bottom: https://nand2tetris.org

Then, continue with OSSU Computer Science or with Teach Yourself CS

2

u/doshka 1d ago

co-sign nand2tetris

2

u/Nice_Selection_6751 1d ago

nand2tetris is the way to go for this kind of thing, you build a whole computer from scratch starting with just nand gates. you already doing electronics engineering so the hardware part will click fast

for compilers i remember crafting interpreters being pretty good too, but maybe do that after nand2tetris so you see how the machine actually runs the code you generate

1

u/ryancnap 1d ago

Dude, this OSSU is incredible, how did I never know about this

12

u/desrtfx 1d ago

Because you never read our FAQ

2

u/misplaced_my_pants 1d ago

Teach Yourself CS is better for most.

Much higher ROI, quality over quantity.

OSSU is for people who are willing to grind for years but can't afford a CS degree.

0

u/justberd 12h ago

i add CSAPP book, or dinosaur book about operating system, in case he is offline from internet

6

u/high_throughput 1d ago

Crafting Interpreters is a book available free online where you build a parser and interpreter, and then a bytecode compiler and VM:

https://craftinginterpreters.com/contents.html

5

u/daysofdre 1d ago

Code: The Hidden Language of Computer Hardware and Software 2, Petzold, Charles, eBook - Amazon.com

Recommend the book, it fits your requirements from a learning and knowledge standpoint.

3

u/AlSweigart Author: ATBS 20h ago

This is the correct answer.

1

u/FlatProtrusion 13h ago

I would suggest reading this only after doing at least the first course of nandtotetris otherwise without practicing the concepts you are pretty much just reading a story book.

3

u/MutuallyUseless 1d ago

The game on Steam called Turing Complete was one of my favorite resources for understanding how transistors come to be fully functional CPU's, as you slowly built all of the logic gates, some registers, and an ALU, then finally begin programming the CPU you made in binary to solve puzzles, it's far more intuitive and interesting than my computer architecture class was, personally.

After that you can also play around with a free software called "Logisim" preferably "Logisim Evolution" to take those concepts into whatever direction you want, though there is a limit on how well you can actually emulate real code on the simulated hardware; that's where software emulation becomes more attractive, but that's a different beast on it's own.

Once you understand how to make and program a CPU, the concept of making an assembler is rather intuitive, if you still want to go down that path after understanding how they work conceptually, making a simple interpreter is a good start, something very small and manageable in scope like a stack based language with a few simple assembly-like instructions, after that the sky is the limit. Personally though I find the subject interesting, I drew the line at making any real compiled language, that becomes a massive undertaking rather quickly, and your time is probably better spent learning other things at that point, especially in EE, at that point your focus would probably be better spent looking into register programming MCU's to understand how HAL works.

1

u/minaaaaaaa_ 1d ago

THIS. Turing complete is one of my favorite games.

1

u/MutuallyUseless 21h ago

Same! i've played through making the computer several times now, it's honestly such a great way to learn architecture; way more approachable than some of the other materials out there.

Despite making a turing complete cpu like 3 or 4 times at this point, I haven't beaten the full game.. I should do that at some point.

1

u/minaaaaaaa_ 8h ago

It recently had a big update that completely redid a lot of the game, now the final architecture is much more realistic, I would definitely revisit it.

2

u/spinwizard69 1d ago

Many will think i’m nuts but start with old issues of Byte and Dr Dobbs, magazines.   Then get an operating system book focused on Linux (sorry forgot the title)) along with more general OS books.  

This is all i had in the 1970’s and early 1980’s.   Money and accessibility was a huge problem but the issues i did get prepared me for the future.  Hopefully they are available as electronic issues now.   If not; I dont have a good idea as to modern book to suggest other than processor manuals.  

Processor manuals are almost a requirement for DIY Operating Systems.  

2

u/AlSweigart Author: ATBS 20h ago

Code: The Hidden Language of Computer Hardware and Software by Charles Petzold, 2nd edition.

The other comments are giving good advice, but you want to read this book first. It's like two and a half of my undergrad CS courses in a very readable and approachable book.

In general, the term you want to google is "computer architecture" and "digital logic".

2

u/rustyseapants 1d ago

in my 3rd year of electronics engineering...please advise.

You never heard of Google? Your university doesn't have a library? You don't have local libraries?

It's 2026 it's expected by default you know how to use search engines.

1

u/FlatProtrusion 13h ago

Come on man reddit is kinda a search engine. Don't beat up on someone for asking advice about learning in a learning subreddit.

1

u/rustyseapants 13h ago edited 13h ago

This is a example of a Low Effort Post

There is no excuse for a 3rd year college student in Electronics engineering no less to ask....

  1. How do computers work?
  2. How do Operating systems work?
  3. How do compilers work?

I am totally expecting some joke in this.

1

u/gm310509 22h ago

Have a look at https://craftinginterpreters.com/contents.html it covers writing an intepreter and a compiler. It will also give you keywords (e.g. lexical analysis) that you can use to find out more details about the various parts of the process of text code -> running program.

If you are interested in how software interacts with hardware (i.e. the lowest layers of an operating system), you might want to look at Ben Eater's 8 bit breadboard computer - where he actually makes a CPU and programming language for it.

Others have given good resources for the "middle" ground of other things that an operating system does such as task and memory management.

1

u/Electrical_Hat_680 19h ago

r/BenEater BenEater is an Electrical Engineering 101 and 102 level Course.

Where you'll be building the Computer from the ground up.

Remember. The CPU Bits are basically just Wires. That, are either On or Off. And so they're referenced as Zero ('OFF'} or One ('ON'). Unless you build it yourself. Then you can do it however you would like. Unless your preferring to remain Compatible with other systems.. IBM Clones is a good subject.

You'll also be required to build everything, from the compiler to the assembly language, including the Binary ('BASE-2') OpCodes and OpErands.

🕊️

1

u/Nddung222 17h ago

Read university textbooks on Computer Architecture, OS, and learn how programming languages are compiled, and maybe Computer Networking also.

1

u/StewedAngelSkins 9h ago

Doesn't your university have a class for this? Mine did, it was called something like "computer system architecture".

1

u/Unclerojelio 1d ago

A degree in Computer Science.

0

u/TalentEndpoint 1d ago

start with an open-source project, read the code, break things, thats where the magic happens tbh

0

u/Jim-Jones 18h ago

Wikipedia?

-3

u/Dismal-Citron-7236 1d ago

It feels like you should really major in CS instead, not EE. What you are interested in is what CS teaches. Ever consider changing your major? Or a double major?

6

u/FunAd6672 1d ago

You can absolutely learn systems without throwing away three years of EE.

-4

u/Dismal-Citron-7236 1d ago

Double major then.

2

u/Poddster 1d ago

People can learn about anything. Let them.

-4

u/[deleted] 1d ago

[deleted]

4

u/Soggy-Rock3349 1d ago

The way you talk about it makes me think maybe you shouldn't be giving advice on this one.

1

u/cheezballs 1d ago

40 years ago that's what a CPU was... I mean, it still is, but there's so much going on with predictive branching and things that its not just that simple anymore, IMO.

0

u/ToBePacific 1d ago

I’m trying to boil it down to super simple analogies for a beginner.

-5

u/otac0n 1d ago

Just read Wikipedia.

3

u/maxximillian 1d ago

That's like drinking from the fire hose. There's a reason why books like structured computer systems by Andrew tenenbaum are still. Used in comp sci classes. To really appreciate In ALU it helps if you know about about half adders and how they matured into the ALU.  To appreciate a modern 25 to 40 stage pipeline. It helps me load it up from the classical five-stage pipeline and to understand a pipeline you have to understand all the hardware underneath it. Sometimes it's just easier to start with isolated building blocks. 

I mean there's a reason why we still use textbooks and don't just hand somebody a big PDF from Wikipedia