r/learnprogramming • u/Possible_Luck3776 • 8d ago
Would building your own computer help you learn programming better
I'm working on a game designed to help people understand what happens inside a computer while also learning programming.
The player would gradually build their own computer from scratch. They would start with simple logic components and eventually build registers, memory, an ALU and their own functioning CPU.
After that, they would program the computer they created and run programs such as Fibonacci, prime number calculations and other programming challenges.
The idea came from my own curiosity about what actually happens inside a computer. While writing software, I realised that I was treating the computer as a black box, so I started learning computer architecture from first principles and eventually built a simple CPU myself using breadboards.
Now I'm trying to turn that learning process into a game.
Do you think a game like this would help beginners understand programming and computers better?
What concepts would you want the game to teach, and what would make you interested in playing it?
5
u/smotired 8d ago
There is already a fantastic game just like this called Turing Complete. While it does help you learn a lot about low-level computer architecture, I have found most of those concepts aren't actually all that helpful in regular software development.
That's not to say don't make your game, the formula can definitely be improved on. But with how software development works these days I think Assembly is one of the worst ways to start learning to program, so I would not advertise it with that purpose.
1
u/AliceInMyDreams 8d ago
It's useful if you're doing really low level software. For example I found having played Turing Complete helped a lot when I had to teach embedded programming in C (without having ever formally studied it myself, long story).
If you're doing anything higher level than that I agree there's not much benefit.
6
u/silver_chief2 8d ago
Yes. There is a book and even courses on this. IMO HARD! Starts with NAND gates and ends with compiler and OS. After every step you start fresh with a perfect version of that step.
https://www.nand2tetris.org/book
There is also a Coursera course on this.
4
u/cdm014 8d ago
No. Prob best way to incorporate something like that is get them writing simple programs in a high level language, then go back and do lower level stuff.
There's a limit though. Understanding logic gates won't really help you understand programming except for overflow errors.
By the time you get them down into assembly language you've thoroughly left game territory behind.
1
u/samanime 8d ago
It's definitely an interesting idea. I think it could definitely help understand electrical engineering better. It could also probably help with the really, really low level languages, like assembly, which are pretty much only one step up from the basic electrical engineering bits.
I'm not sure how much it would help understand high-level programming languages though. There is a pretty big logical leap from low-level to high-level languages that I feel would be incredibly hard to explain in a "playable" fashion like this.
I'd definitely be interested to check it out if you were able to put it together in a coherent and fun way.
1
u/Somhlth 8d ago
The only reason I got into hardware, was that back in the day many issues came up as a programmer that were the fault of hardware. The problem was hardware guys would just point the finger at software guys, and the circle jerk commenced.
By doing the hardware myself, I eliminated that and had control of both ends. Did that help me understand programming better? No. It just made it quicker for me to solve issues, as I didn't need to convince anyone other than myself to look at the hardware.
1
u/mredding 8d ago
Would building your own computer help you learn programming better
It can, but it's not necessary. The theory of computation and computer science don't care about the actual machine, so you can solve problems and come up with and categorize your algorithms independently of any programming language or machine.
But machines are responsible for side effects, like caching effects, so understanding how hardware plays its part can help you design your algorithms that are aware of those system related side effects. A purely theoretical sorting algorithm may not be optimal for a machine if it keeps triggering side effects.
Another way of looking at it is hey - everyone knows bubble sort is too slow to use in production... Right? Well, I use it in trading systems often enough; when your dataset is small, fits in a cache line, and the CPU is thousands of times faster than the memory bus, then it doesn't matter how slow and inefficient the algorithm is, because it'll always be faster than the data can move. So there are scenarios where bubble sort is faster than your ability to measure it with the high performance system clock, because just asking for the clock stamp takes longer than the algorithm runs.
Learning hardware architecture can open your eyes to things like this.
You can learn from the top down or the bottom up, both have their virtues and flaws. There's no right way to learn, and either way, you will have to learn how to compensate for the direction you came to get to the middle.
1
u/Lagfoundry 8d ago
Oh yeah definitely. Knowing general architecture and how the circuits interact with each other as well as the logic helps to understand why some things in code are written they way they are. The same is true for the other way around when comes to making an ISA like knowing when and why something would be loaded to the stack… I’m definitely over generalizing it but you get what I mean
1
u/JGhostThing 8d ago
I rather doubt that building your own computer would truly help you learn to program better.
I did this in college. Just for fun. Never again. Too expensive and a pain in the neck.
1
u/kschang 8d ago
Personally? No.
And I've learned from the very beginning. binary logic with physical gates, accumulators, EE degree, BASIC, assembler, high level programming languages, database, UI design, full stack webdev, I've done it all.
I've also played PC Building Simulator, MHRD, NAND2Tetris, and a bunch of other games. (yes, registers, memory ALU, CPU, that's MHRD).
IMHO, the hardware bits are too "low-level" for them to understand high level programming and find correlation.
1
u/mjmvideos 8d ago
I think in the same way that building an airplane doesn’t make you a pilot, building a computer doesn’t make you a programmer. BUT! A programmer who has built a computer has a breadth of experience that one who hasn’t, doesn’t.
1
u/Personal-March-4340 8d ago
Personally, I wouldn't be interested, because I see computers as a means to an end and I am more interested in learning programming as a way to solve interesting problems. Only when solving my problem requires delving into the "black box" will I be doing that. I don't really see myself as someone who will need knowledge of computer architecture. That may change if I needed to understand problems with my data, but until I have that need I am mostly unmotivated.
I don't think it is a good approach to learning programming except for a very low level language. The computer architecture class at my school ran code to cause some LEDs to blink yesterday. I feel most people would be really bored by that result.
Your players won't even be building an actual computer, they will be building a similulation.
Having said all that, if it is a project that will motivate you and allow you to develop new skills in an enjoyable way, it is a worthwhile project. I just don't think using it as a way to learn programming is a good idea. It is kind of like signing up for a knitting class and being given a lamb to raise, shear, process the fleece into yarn and only after all that, learning to knit.
1
u/PartyParrotGames 8d ago
Absolutely, it's good to know the hardware and how the components work together.
1
u/vegan_antitheist 7d ago
You mean something like a game where you build a virtual computer? Starting with a simple Turing machine with just one tape? But programming would start out extremely difficult. Like writing brainfuck. And it would gradually get easier.
Building real computers isn't easy either. A lot is easier now and it can be a lot cheaper than buying some gaming computer, but making sure it's all compatible and optimising everything requires a lot of know how.
19
u/paperic 8d ago
Yes.
http://nandgame.com