11 ms·
What if you knew how computers work? (2015)
- xwdv 6y agoWhat if? While I’d love to really know how computers work at this level of depth, I can’t help but feel like it’s a colossal waste of time these days if you already have other sharply tuned high level programming skills. The ROI isn’t great, the time you spend learning this is time you could have spent going deeper into your chosen craft and becoming even more masterful. By the time you do learn a dangerous level of assembly and reverse engineering knowledge, you’ll still have to fight for entry level gigs to get in the industry unless you’re really good at finding niche and high paying work... meanwhile people still want to pay you six figures+ for your decade or more of experience writing everyday software at scale. Alas, where as it once seemed like anything was possible, as I get older I come to realize the best use of my time is to further perfect the things I already know how to do well, so that one day I can truly become a sagacious master, or at the very least not fall behind my peers and become “outdated”. Learning opportunities like this are inspiring, but ultimately just a passing curiosity. I hope someone young finds it well.
- libraryofbabel 6y agoAgree. Yes, it’s extremely interesting. I look back fondly on my youthful hours/days/weeks spent tinkering with assembly. And yet. To a junior dev who asked me for advice on this stuff today, I’d just say read Code: The Hidden Language of Computer Hardware and Software, and if you like that then work through Nand to Tetris, and then go back to whatever you need for you day job.
- the_only_law 6y agoI've tried to deep dive the modern PC a few times before and I always end up giving up because it quickly becomes a proprietary and undocumented minefield.
- SV_BubbleTime 6y agoOpposite for me. I’m a CE and need to know exactly this stuff. What I don’t need to know, and don’t at all, is how web APIs really work, what a kubernetes is, there is something called Elixir I think and it may or may not be related to some Etherium not-money, and have you heard about elastic searches? Because I haven’t. But I do need to know extremely tight programming for tiny microcontrollers, how many cycles per instruction this or that will take, when pipelines get flushed, device drivers, and datasheets and silicon erratas. If you deal in higher level stuff, you likely use more ram for a text field than I may have on my entire chip.
- xwdv 6y agoThis isn't 1991. The only reason I don't use less RAM for a text field is because it doesn't fucking matter, RAM is cheap and when you're building web applications your user is probably not going to run out of it, it's not even a thought. RAM sitting around doing nothing is a waste of money, might as well put it to use.
- SV_BubbleTime 6y agoI have 4KB of ram on a brand new microcontroller I’m developing for. No, ram is not cheap. PC ram is cheap. We don’t all program for PCs.
- xwdv 6y agoPeople who program for PCs need not concern themselves with the needs of microcontrollers.
- _____s 6y agoYeah, although I think understanding how computers work at a basic level (the components of a CPU, what instructions are, caches, etc.) has a pretty good ROI because it makes it easy to understand some concepts at a higher level (concurrency for example), understand why some things work a certain way, think about some common performance optimisations, tradeoffs, etc. I think that's true of most things—you don't need to (and likely cannot) know everything in real depth, but having some knowledge tells you where to look, what to look for, etc.
- xwdv 6y agoA good blog post can probably explain most of the important bits of those things without investing so much time.
- xkcd-sucks 6y agoThis is all totally correct, but why not transition into management and get even more money? Dealing with people is more future-proof than any computer programming
- deleted 6y ago[deleted]
- ganzuul 6y agoThe CPU / RAM bottleneck isn't getting any faster. Latency is actually increasing with newer versions of DDR. Most of your CPU time is spent waiting on memory. Compilers are hard-pressed to make you choose efficient data-structures. You just need to know the implementation details to get a responsive user experience.
- analog31 6y agoThis looks pretty interesting. I didn't look into the course materials, but I wonder if someone learning "how computers work" would benefit from a casual introduction to a simple microprocessor hardware architecture. For me, it was the Z80, because there happened to be a book at Radio Shack, published by Howard Sams, that was extremely well written. But since this is about x86 assembly, the old 8086 isn't all that bad in terms of grasping how the different kinds of instructions actually play out in the registers, memory and i/o busses, and so forth. And it's not so bad to learn about the features of modern processors in light of how they compare to early chips. For instance in the 8086, a pointer is not an abstract concept, but a real physical thing! Despite modern microcontrollers being much more sophisticated than the Z80, that foundation has helped me learn and understand things like how to read the documentation for special function registers and advanced peripheral chips.
- smabie 6y agoI think 6502 (commodore 64/apple 2 CPU) is perhaps the best introduction to asm. The instruction set is designed for people and while it only takes a day to learn, it takes a lifetime to master. Probably the pinnacle of CISC human oriented asm.
- justinlloyd 6y agoI've developed software for 6502 (the first processor I learned assembly language for, but not the first CPU I programmed at the machine code level), Z80, 6809, 68000 series (x00, x20, x30, x40), a variety of MIPS (R3000, R4000, R10000), ARM and a number of variations on it, x86 and all its variations, T800 Transputers, various 4-bit and 8-bit microcontrollers, and well over a dozen more CPU types over the years. For real world processors, I would say that the 68000 is probably the best introduction to assembly level programming. For a real-world CPU. Lots of registers, usually a flat and easily understood memory map, a clean instruction set, and instructions that have direct parallels to many of the basic operations you would find in higher level languages, e.g. multiply, divide, addition and subtraction of 32-bit numbers, easily understood loops, various conditionals and so forth. Certain early ARM variants would run a close second of "try this out, it's easy to understand." Though even then, I'd hesitate to introduce someone to ARM programming unless they had a real interest in learning assembly programming. 6502 is simple, I agree with that, but moving beyond the most basic of operations takes careful thought. So for an introductory assembly language on a real world processor, I would have someone start with 68K. Once they grasp that, which, if they are a reasonably competent programmer, facile in their language of choice, they should be able to crank out 68K assembly that does useful work in a couple of days. It is possible to then consider the 6502 or Z80 or 6809 as options for a less capable, but certainly more difficult next step in assembly language. I would strongly disagree that 6502 is designed for human readability or that it is the pinnacle of assembly language programming options. For real world processors, I would be hard pressed to rank it in the top 10 of "processor of choice to solve this task because of capability." Perhaps up to about 1982 it could be considered reasonably competent. But "pinnacle" is not a word I would ever use to describe that CPU no matter how fond my memories are of learning to program it or shipping my first video games on it. The 6502 CPU has a number of shortcomings that were clearly evident in the late 1970s when it was at peak popularity. The one thing it did have going for it was that it was cheap and that it was easy to get going on a board with some supporting chips.
- sircastor 6y agoOne of my favorite College courses was my digital logic class, where we went from logic gates to building a 4-bit microprocessor. It really gave me a deeper understanding of what computers are and how everything ultimately works together. I took this class when I was already A dozen years into my software development career. It’s certainly not necessary to write software, but I’m really glad I know the underpinnings of computing.
- ryeights 6y agohttps://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-004-computation-structures-spring-2017/ https://ocw.mit.edu/courses/electrical-engineering-and-compu...
- henrikschroder 6y agoI had a course like that in my CS programme, and even though we really, really didn't go deep, we wired our own super simple 8-bit processor, and wrote the microcode, and then wrote a program in assembly to do something. Stepping through the fetch-execute cycle one cycle at a time, watching your CPU do its little thing, and then realizing that that is exactly what actual CPUs do, they're just doing it billions of times per second, that was amazingly eye-opening.
- ibeckermayer 6y agohttps://github.com/ibeckermayer/Nand2TetrisFPGA https://github.com/ibeckermayer/Nand2TetrisFPGA
- SV_BubbleTime 6y agoIf you knew how computers worked.... Websites wouldn’t be 4MB on the front page... Some of you would be ashamed of the choices you make in typed languages... Others would be horrified to find out what happens in the back end of not typed languages... You would constantly find it amazing that single CPU core systems aren’t ever actually doing more than one thing at a time and the concurrency of moving the mouse on the screen and ANYTHING else the system is doing is just an illusion... You wouldn’t shit on C language... at least less. ... IDK, I’m sure there are a ton more I’m not thinking about. I’ll leave it up to someone else to articulate better... something something FaceTime is usually a massive waste of technology. These are bad musings from an embedded programmer who is dealing with a 2020 released chip and it’s 4KB of ram.
- giantDinosaur 6y agoI don't think knowing how computers work stops 4MB of JS on websites, just that the kind of person inclined to learn about the foundations of computers is more likely to not want bloated websites in the first place, and is less likely to work as a web developer.
- scollet 6y agoMaybe. I still have an affinity for server-side rendering.
- quattrofan 6y agoThis
- na85 6y ago>You wouldn’t shit on C language... at least less. Anyone who still thinks C is the way computers work is in for a surprise when they realize all modern x86 machines are just emulating x86 in microcode for backward compatibility reasons.
- deathgrips 6y agoUhhh.... C doesn't just compile to x86?
- jimmyswimmy 6y agoI do know how computers work, at the transistor level. But it boggles the mind to try to understand how a computer works from the transistor level to the point of where your mouse icon traverses across the screen. Trying to understand it at all levels will really give you a headache. Or at least, it does for me. I tend to think that if more people understood how to program at this level, the weight of software and websites would be a lot less. I can't log in to my bank website without download 1 MB of crap. It's super easy to program using by importing * but if you can write in assembly you can really optimize. It's just not worth the effort these days. So the improvement of Moore's law (RIP) ends up going to programmers' salaries instead of to performance improvements. Kind of an interesting way to think about it.
- woo49 6y agoMy CS systems PhD advisor used to say, 'you waste the abundant resource' in systems design. Lots of CPU cycles available, lots of bandwidth available (except when not!) - so waste it and save programmer time. At least, in theory. It's not about knowing assembly or not. It's resources, time, cost, money, ROI.
- xmprt 6y agoEven after knowing assembly, there's probably significant optimizations that can be done if you design chips and ISAs that are specific to a certain problem. There's "waste" at every stage of abstraction.
- deathgrips 6y agoThat's not waste, that's a tradeoff.
- ClikeX 6y agoIt's a choice you need to make when developing. I had to build a one-time export yesterday. Am I gonna spend a lot of time optimizing the speed of it? Or am I going to make it work and get the export to the client faster? It would've wasted my time and the clients money if I optimized the queries. Sure, the export itself took longer. But overall, the task was done quicker. If the client wanted this export to run on their server frequently, I would've spend the time making sure the export itself runs faster.
- _____s 6y agoLooks pretty interesting. I took a computer architecture class in Jan-Feb this year, and it was one of my favorite things in a long time. I've written software for ~6 years but I didn't really know much about how CPUs work, what an instruction is, what registers are, etc. so I learned a lot. I thought a lot of these details could be boring or hard to grasp, but it was the opposite—to me, things like how logic gates worked, how we remember values between computer cycles were all very fascinating, especially compared to the kind of work I've done for a long time. I've learned a bit more about operating systems and databases since then, and I think knowing a bit of computer architecture helped me understand several topics in much better depth. So even if knowing these things doesn't have a very direct ROI in terms of getting a job, I think it's worth spending the time to learn at least the basics.
- georgeoliver 6y agoI think there already is a subculture of programmers who value the lower resource use (i.e. power as well as memory/speed) and availability of free/open hardware that knowing how computers work affords. Whether that remains a niche or becomes more mainstream is an interesting question.
- Ccecil 6y agoBack when I was in electronics during our Digital circuits section we built all the logic from gates and such (TTL, CMOS) and then at the end we learned 8085 assembly using an "Emac 8085 primer trainer" which we all had to build ourselves. It had no battery backup (optional) and we were not using the serial output at all...so we lost any programs we made on power off. It was very interesting to learn and I feel fortunate that I understand computers on that level. That being said...I don't really do code at all :) Most of what I do is on the hardware side of things. Edit: Emac...not emacs
- PaulDavisThe1st 6y agoIn 1986, after quitting my PhD in computation molecular biology and starting out on a career as a software developer, I tried to figure out what the goal for the next 5 years was. I settled on satisfying myself that I understood (enough about) every level of the computer from semiconductor physics up to GUI/UX work. Luckily I had the semiconductor stuff already covered from my undergrad days and a friend from that time who was an EE major. The rest took a bit longer than 5 years (maybe 7), and of course the learning didn't stop there. But I do remember thinking in the early 1990s "OK, I understand the entire stack at this point, what comes next?" My understanding had reached a level I was satisfied with - it would not have compared with someone who spent their entire working life focused on that level, but it was far, far beyond any normal computer user's understanding. In the 2 decades and more since then, not a whole lot has changed that has invalidated the understanding I think I gained at the beginning. Microcode was a bit of a shock. The biggest shock has been watching a whole new generation of programmers who barely grasp the lower 80-90% of the system. Maybe that's good, but it doesn't feel obviously right.
- genidoi 6y agoIt feels no less wrong than having, at best, a surface-level understanding of how seratonin / dopamine / norepinephrine receptors work and still being comfortable enough to drive a car at highway speeds, knowing full well that an error along this obscure signal processing pipeline is a potentially fatal swerve into oncoming traffic.
- deleted 6y ago[deleted]
- antonios 6y agoI found that one of the most important insights when studying how computers work on a fundamental level, is that deep down data and code don't make much difference. This realization can open the gates of looking at higher programming language concepts in a new light; even if one never delves into bare metal engineering.
- saagarjha 6y ago> data and code don't make much difference You can really take this two ways: one part being about von Neuman architectures, the other side culminating in Lisp. They’re fairly separate but both interesting views on computing. Of course, the opposite viewpoints also do exist, as Harvard architectures and your favorite “blub” language is still used today…
- tmerr 6y agoThis became apparent to me once I learned a Turing machine can compute anything λ calculus can and vice versa. Is this also also a conclusion you can reach by thinking about computer hardware? Would love to hear more about the thought process.
- whytaka 6y agoI'd spent one of the most educational years of my life this last year reading, "Designing for Data-Intensive Applications", "CODE: The Hidden Language of Computer Hardware and Software", and "The Design of the UNIX Operating System". While they haven't given me any expertise on how to actually use these technologies to solve intricate problems (only experience and true depth can do that), they have given me a near-complete picture of what ordinary computers do today. Nothing is magic. Everything is a logical operation. I only regret I hadn't read these back when I was a teenager. PS. Next thing I would like to learn is the general design of modern CPUs and branch prediction.
- teleforce 6y agoFor introductory learning about modern CPU design, Inside the Machine book by Jon Stokes is really good.
- whytaka 6y agoThanks for the suggestion!
- shostack 6y agoI'm 50% through Code right now. How is Designing for Data Intensive Applications? What would you say was the most valuable thing you got from it?
- whytaka 6y agoDesigning for Data Intensive Applications is a must-read imo. The book is chock full of very straight forward explanations of what happens in data-related operations, from DB transactions to stream processing. The most valuable thing(s) I got from it are clear explanations of Transactions, Isolation Levels, and examples of errors that occur due to asynchronous operations.
- dt3ft 6y agoThis is an ad for a course.
- adder46 6y agoThere's much more to "How computers work" than just assembly. Where are networks, operating systems, databases, compilers, architecture, etc?
- dinoqqq 6y agoA couple of years ago I was in this position. I wanted to know how computers work and stumbled upon this resource. I can highly recommend the exercises given on Github by Xorpd. It really requires no prior knowledge and a lot of the exercises have answers now (still a work in progress though). Next to that it might be convenient to have something like asmdebugger.com next to it. Another book that also really helped working with this was "Code: the Hidden Language of Computer Hard and Software" by Charles Petzold. This explains how computers work from light bulb/transistor level, all the way to the top to the OS, the monitor and the keyboard.
- mkatx 6y agoI second Charles Petzold's book Code! It was my first technical book and probably the reason I'm going to school for computer science right now. I recommend it to anyone interested in learning how computers work, even non-techies!
- arthev 6y agoThe site implies assembly is how computers really work. IMO, assembly is just an incidental implementation detail of little note. High level language chips are possible, after all.
- leowoo91 6y agoThis reminds me of nand2tetris course, which I think really helps to understand practical implementation of today's computers (https://www.nand2tetris.org https://www.nand2tetris.org)
- retsibsi 6y agoThe associated book ('The Elements of Computing Systems') was eye-opening for me. Not sure if 'today's computers' is quite right -- if I understand correctly, a lot of the simplicity has been optimised out of the hardware stack, to the point that even experts don't have a fully detailed understanding. Still really worthwhile to read and understand the basic principles, though.
- SonOfLilit 6y agoI have the great pleasure of knowing this guy in real life. He's a legend. Don't miss his amazing x64 poetry book, at https://www.xorpd.net/pages/xchg_rax/snip_00.html https://www.xorpd.net/pages/xchg_rax/snip_00.html
- Balooga 6y agoI have a soft spot for the Usborne computer books from the 80s. https://usborne.com/browse-books/features/computer-and-coding-books/ https://usborne.com/browse-books/features/computer-and-codin... Scroll down to the bottom of the page for links to the pdfs.
- MilnerRoute 6y agoI also recommend the book "But How Do It Know? - The Basic Principles of Computers for Everyone." It attempted to explain circuit-based logic gates, how you could use binary trees for all the basic math operations, and then for other characters, building up to more and more complex operations... I had to stop and sit and think several times while reading that book, but it was a real thrill when I started to understand it, feeling that small flash of near-omniscience...
- fuzzfactor 6y agoIf you really know how computers work I would say you are most aware of how they barely work.