18 ms·
I'm 17 and wrote this guide on how CPUs run programs
- Dwedit 3y agoThen there's the OTHER side, Flipflops, MUXes, ALUs, register files, combinational logic, yadda yadda, then you have your CPU.
- nicechianti 3y ago[dead]
- lagniappe 3y agoThis is great work :) thanks for sharing it with us. Unexpected Linkin Park bit at the end was nice, but now I'm wondering if Linkin Park is now considered 'oldies'
- speed_spread 3y agoLinkin' Park is where you went when compiling a really large C++ app (before mold)
- ageitgey 3y agoDefinitely oldies now! Their hits are two decades ago. If you were born in the 80s, Linkin Park is as old now as the Beatles were then.
- bee_rider 3y agoThe gap between Nirvana and now is significantly larger than the gap between Nirvana and Zeppelin, and the worst part is some kid might come along and not understand how crushing that is.
- IggleSniggle 3y agoI mean, of course? AC/DC has got to be the "moldy oldies" of today, which leaves Elvis or The Champs nothing but genetic parasites to the degree that they are still recognizable. Wagner? Vivaldi? Ockeghem? Fuhgeddaboudit. To be clear, that's the bizarre/absurdist arbitrary line I'm tracing to Linkin Park
- speps 3y agoActual guide link: https://cpu.land/ https://cpu.land/
- matteason 3y ago> The bottom of every page is padded so readers can maintain a consistent eyeline. That's a nice little detail, I haven't seen that before
- AnimalMuppet 3y agoCan you (or archmaster) explain it? I'm not sure I understand what it's for.
- matteason 3y agoIt means that you can keep your eyeline focussed on the middle of the viewport (or the top, or wherever's natural for you) as you scroll new content into view. On a regular page, once your scrollbar reaches the bottom you have to start reading down the viewport because there's no more space to scroll. I don't know how much practical difference it would actually make to readability - would be interesting to measure - but I thought it was neat
- SushiHippie 3y agoWhen you scroll to the bottom while reading text you always only need to look in the middle of the screen when it's padded. Otherwise at the end of the page you would need to look at the bottom of the screen
- archmaster 3y agoWhen many people read an article on the web, they keep their eyes in one small vertical area on the page and scroll to shift the text (rather than reading the whole visible area and then scrolling to the next "page"). However, when you reach the end of the scroll area, you're suddenly forced to move your eyeline down the page. Adding a bunch of space adds means you can keep scrolling the text to be underneath your eye-area. (sorry for the crufty explanation lol, it's kinda hard to visualize)
- ggambetta 3y agoVery nicely written, and congrats on doing such a deep dive on this kind of topic. These days 17 year olds can get away with "programming" by gluing things they don't understand, but I think they'll eventually hit a ceiling. So what you're doing is super valuable, not for yourself, but for everyone else who will learn from your materials. Well done :) EDIT: now go write an emulator if you haven't already, it's a ton of fun :)
- onion2k 3y agoThese days 17 year olds can get away with "programming" by gluing things they don't understand... I've been doing that for 26 years. ...but I think they'll eventually hit a ceiling. I wonder if it'll happen soon.
- ggambetta 3y agoI'm not sure it's always obvious to ourselves when we have. We humans are amazing at denial and telling ourselves whatever story we want to believe in. I'm not picking on you. If there's one thing I'm terrified of, it's blind spots.
- ethbr0 3y agoIn my experience, it's an unknown-unknown problem (don't know what we don't know). Is it important you can recite cache eviction algorithms from memory? No. Is it important you know there are such things as caches and roughly how they work? Yes. Because then you can quickly look up the details when/if you need them.
- wizzwizz4 3y agoIs it important that you understand cache eviction algorithms well enough that you can look at a description of an algorithm and see how it applies to your system? Yes. And if memorising is the way you gain that ability, then memorising is what you need to do. And what is it important for? Why, for making sure that your software makes efficient use of system resources. This is essential if you're writing application software that's used by other people – but if you're writing server-side code, or some one-a-month business-logic data-processing scripts, or code that's only ever going to run on five specific machines, it's not that big of a deal. I haven't needed this skill yet.
- rvz 3y agoFantastic work by the author. The best part: > I talked to GPT-3.5 and GPT-4 a decent amount while writing this article. While they lied to me a lot and most of the information was useless, they were sometimes very helpful for working through problems. LLM assistance can be net positive if you’re aware of their limitations and are extremely skeptical of everything they say. That said, they’re terrible at writing. Don’t let them write for you. Good. Thank you for disclosing this. Great to know that even teenagers like the author know the limits of LLMs and know where and when to use them and haven't fallen into the hype and mania in blindly trusting them, unlike the millions of so-called new wave of 'AI startups' out there. Once again, fantastic work and keep it up.
- lordnacho 3y agoWhat's your advice on how to teach programming to my kid? Curious to hear what another young person thinks. Kid is 11, has all the basics, knows how to type, knows how to open a terminal. What things did you think were important to learn, what kinds of things motivated you most? What did you do when you got stuck?
- archmaster 3y agoI taught myself everything — my parents are not technical and sorta disliked computers (which I'm sure helped motivate me lol). So what helped me most was just experimenting a lot, banging my head against a wall repeatedly. When I got stuck I just had to keep trying. Knowing I could Google problems was really helpful, but I also had to learn how to Google. I was motivated by the amazing feeling of finishing something I built, and also the fun of learning and then applying that knowledge. It's hard to remember my tiny self so I wish I could give better advice. I most of all wish that I had a mentor figure, someone I could ask for questions or who could show me where to look, or even just be a role model. Getting into open source and talking to people online was amazing, although I didn't start that until I was ~12. It took me a really long time to get where I am. There are probably more efficient ways to do so other than banging my head against things. But it does work! So just encourage them to keep going, and MOST IMPORTANTLY, FOLLOW THEIR INTERESTS!
- ethbr0 3y agoNot author, but I've always wanted to approach programming from an algorithms-first perspective with younger kids. Not called algorithms, of course. If they can create/combine algorithms to solve a problem... that's most of programming. I'd start with the "robot" problem: have them write a set of steps to complete a simple task, and then have them (or better, someone else) go through the steps precisely (no cheating and assuming they meant something they didn't write!). Then iterate and add/remove steps until the task is actually doable. (Disclaimer: idea cribbed from someone else) That gets them to grok the "everything needs to be in a program, and a program is only everything that's in it" idea. The traveling salesman problem (recast in whatever form would be most interesting to the kids) and graph theory problems are also especially visual and explorable.
- archmaster 3y agoHi! I'm Lexi, I wrote this article/mini-book. There's a classic question of "what happens when you load a website?", but I've always been more interested in "what happens when you run a program?". About 3 months ago, I was really annoyed at myself for not knowing how to answer that question so I decided to teach myself. I taught myself everything else I know in programming, so this should be easy, right? NOPE! Apparently everything online about how operating systems and CPUs work is terrible. There are, like, no resources. Everything sucks. So while I was teaching myself I realized, hey, I should make a really good resource myself. So I started taking notes on what I was learning, and ended up with a 60-page Google Doc. And then I started writing. And while I was writing, it turned out that most of the stuff in that giant doc was wrong. And I had to do more research. And I iterated and iterated and iterated and the internet resources continued to be terrible so I needed to make the article better. Then I realized it needed diagrams and drawings, but I didn't know how to do art, so I just pulled out Figma and started experimenting. I had a Wacom tablet lying around that I won at some hackathon, so I used that to draw some things. Now, about 3 months later, I have something I'm really proud of! I'm happy to finally share the final version of Putting the "You" in CPU, terrible illustrations and all. I built this as part of Hack Club (https://hackclub.com https://hackclub.com), which is a community of other high schoolers who love computers. It was cool seeing some (accidental) reception on HN a couple weeks ago while this was still a WIP, I really appreciated the feedback I got. I took some time to substantially clean it up and I'm finally happy to share with the world myself. The website is a static HTML/CSS project, I wrote everything from scratch (I'm especially proud of the navigation components). I hope you enjoy, and I hope that this becomes a resource that anyone can use to learn!
- iancmceachern 3y agoThis attitude and ability to execute on your vision will serve you well. Excellent work, stay awesome
- amelius 3y agoIt's a bit dated but perhaps you should check out Structured Computer Organization by Andrew Tanenbaum.
- bobboies 3y agoThe only thing is I hate titles like this—the title is bragging a bit too much. Maybe a title more like: “How I’m helping my high school peers learn about CPUs”. That way it implies you’re young, smart, and care about others—all of which I imagine are true :)
- bdcravens 3y agoExcept the title wouldn't be entirely accurate - there's plenty of "Senior Engineers" who are really just framework assembly liners who could learn something from this writing :-)
- simonw 3y agoHacker News automatically removes the word "How" from the beginning of submissions (and then Title Cases them for good measure) - so I believe submitting that title would instead result in this: I'm Helping My High School Peers Learn About CPUs I might be wrong though, it might only do this with "How to ...".
- seabass-labrax 3y ago'How to' is one of the title forms that isn't modified, currently.
- simonw 3y agoI submitted https://simonwillison.net/2023/Aug/6/annotated-presentations/ https://simonwillison.net/2023/Aug/6/annotated-presentations... the other day - title "How I make annotated presentations" - and it was automatically re-titled to "I Make Annotated Presentations" - but then renamed back again, I presume by a moderator. https://news.ycombinator.com/item?id=37024398 https://news.ycombinator.com/item?id=37024398
- topaz0 3y agoGood to hear I'm not the only one who finds that form of title unpalatable. IMO one of the most annoying headline trends of the clickbait era.
- alaintno 3y agoI'm almost 40 years old, and I've never accomplished something like this. I was just about to cope about my impostor syndrome. Well, I guess I need to cope more! Great job :p
- cezart 3y agoIt's never too late to start doing what you think will make you feel accomplished. Be it when you're 17, 40 or 80. You still have plenty of time ahead, and there isn't even much reason to rush. Just pick an inspiring idea and slowly work on it in the little free time you can allocate to it. The key I guess is to feel proud of working on it. The end product will result on it's own eventually.
- jona777than 3y agoThis sounds like Eventual Consistency as applied to life.
- skizm 3y agoMeta point: I'm curious of people's thoughts when OPs in general post "I'm N years old..." or "I'm a blind programmer who..." before posting something unrelated to their life situation. Personally I think this falls into the "girls do not exist on the internet" rule of thumb. No reason to state that you're a girl (or 12 years old or whatever) other than to prime people to look upon your writing with lower standards. I think it is fine to mention your situation in passing or as a footnote if it is interesting, but unsure it really adds anything to lead with it (personally I think it detracts). That's just my opinion. Anyone else have thoughts? FWIW this seems pretty well written from just skimming the intro and a bit of chapter 3. Edit: sorry I did not mean for this to be the top comment and push OP down so far. The writing here is really good and folks should definitely click through and at least give it a skim if they're interested. I was just curious what people's thoughts were on this topic.
- throwaway290 3y agoIt's always great when I see someone's work and it's interesting so I look the person up and it turns out that is not the stereotypical demographic (eg. 20 to 40 yo dude), but if I see demographic factor paraded upfront I feel like it is meant to compensate for lacking work (if not then what is the purpose?) and I automatically counter compensate so it tends to lower my first impression
- ggambetta 3y agoFully agree with this, I have a very similar response when I see these. That said, the tone of my reply to OP would have been different if hadn't known their age. Or more likely I would have thought to myself "so you understand CPUs, cool" and moved on.
- balder1991 3y agoMaybe in this case it’s a way to avoid too harsh criticism. It’s like, “hey, if I’m missing something I don’t have a degree so don’t take this as an authoritative piece”.
- throwaway290 3y ago
- not_the_fda 3y agoThis is really great. There are many developers with decades of experience that don't understand these things.
- racl101 3y agoCount me in.
- js2 3y agoCongrats on completing this guide. > There aren't many comprehensive systems resources if you aren't going to college, so I had to sift through tons of different sources of varying quality and sometimes conflicting information. The absolutely best resource you will find is Charles Petzold's Code: The Hidden Language of Computer Hardware and Software. The 2nd edition was just released. https://codehiddenlanguage.com/ https://codehiddenlanguage.com/
- archmaster 3y agoThank you! Looks hardware-y and very interesting, I may well read through it at some point.
- js2 3y agoIndeed. It starts from first principles, assuming the reader doesn't know anything about computers or even electronics. The final chapters are about coding. Your guide could actually serve as an addendum to the book. Based on the title of your guide, I was expecting something more like Code, but now having read your guide, it's more of an introduction to operating systems with a particular focus on Linux and the CPU/memory aspects. Well done.
- gonehome 3y agoI’ll +1 this too - it’s very good and he’s a good teacher, it’s enjoyable to read.
- grimgrin 3y agoI'm going to +1 this book but I also think this book would electrify you, as it did me: https://en.wikipedia.org/wiki/The_Information:_A_History,_a_Theory,_a_Flood https://en.wikipedia.org/wiki/The_Information:_A_History,_a_...
- unethical_ban 3y agoYes! I was reminded of this book looking at the website. I bought it 15 years ago and my eyes glossed over the CPU arch section, but maybe I am ready now. I bought 2e recently.
- jack_riminton 3y agoNice one. You'll go far. Especially if you ignore the cranky resentful people on here
- morjom 3y agoI wish I was taught these things in my basic degree. Thank you for the writeup
- lfkdev 3y agoWow, so because you're 17 we should click on this article? I was 17 also some time ago
- mplanchard 3y agoAh but did you make anything interesting when you were 17? Most people were 17 at some point, but most of them didn’t make anything particularly impressive at that age.
- ac1spkrbox 3y ago[flagged]
- dang 3y ago"Please don't pick the most provocative thing in an article or post to complain about in the thread. Find something interesting to respond to instead." "Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something." https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- lfkdev 3y agoTrue, sorry
- wkjagt 3y agoThe best resource I've found so far that helped me understand how computers / CPUs work, is Ben Eater's work. Both his 6502 computer, and 8-bit CPU series are amazing. Looking forward to reading your guide. Thanks for sharing!
- WC3w6pXxgGd 3y agoThis is fantastic. Great job! I like the easier to comprehend language than what you typically find when reading information about this stuff (wikipedia is one of the worst...). You'd probably like Nand2Tetris. To be frank, I never finished it (it's so long!), but building a CPU from scratch was insightful (at the time - I don't remember much now, sadly).
- ranting-moth 3y agoOP, don't excuse your work by prefixing it with your age. Your write-up is better than most people will ever do. Nice work!
- bityard 3y agoI'm 43 and I agree with this.
- I_am_uncreative 3y agoThe fact that you're 43 makes me even more impressed.
- aio2 3y agoThe fact that you're impressed makes me impressed.
- deleted 3y ago[deleted]
- codemiscreant 3y agoThis post would have zero traction on here if they did otherwise. The tubes are full of excellent resources that die on new. They decided to market with the age bit and clearly it worked.
- vunderba 3y agoPrefacing self promotional material with an age (either skewing young or old) is a marketing angle that's worked for well... ages, so I don't begrudge her leveraging it.
- whywhywouldyou 3y agoVery unlikely anyone would care about this ChatGPT-level summary of how a CPU works if the author didn't mention they were 17.
- deleted 3y ago
- vpastore 3y ago[dead]
- diarrhea 3y agoThis is on my reading list. This little bit sold me on it in the past: > The bottom of every page is padded so readers can maintain a consistent eyeline. Such a tiny and, in hindsight, obvious detail. It's surprisingly pleasant. When I noticed that, I knew I had a passion project in front of me.
- kaycebasques 3y agoThere are quite a few very nice UI touches. I think the bit about the author (authors?) being 17 is relevant because it seems like they put a lot of thought about how to represent a book on the web and came up with some new conventions, just like you'd expect from a new generation. The chapter navigation widget at the top for example, where the previous and next chapters are slightly opaque. Haven't seen that before.
- EspressoGPT 3y agoYeah, that simple frontend definitely got a lot more thought than your average shitty convoluted company website.
- bhasi 3y agoThat is indeed a nice touch. I've seen that before in presentations generated usingn LaTeX Beamer templates.
- globular-toast 3y agoLooks like a cool guide. Something seems off about this, though. Can't quite put my finger on it.
- asynchronous 3y agoWould just like to comment that the presentation is top notch, really appreciate the level of detail put into it.
- scovetta 3y agoI read through the first couple parts, this is exceptionally well written, clear, and AFAICT, accurate. Nicely done.
- yakkomajuri 3y agoThis is awesome, and so is your website. Programming, writing, flying, music, that 's wild. Congrats!
- yakkomajuri 3y agoNote, in response to the title, that I don't mean "awesome for a 17yo", I mean awesome, period.
- linux2647 3y ago> The envp argument contains another null-terminated list of environment variables used as context for the application. They’re… conventionally KEY=VALUE pairs. Conventionally. TIL! It seems a lot of (newer) programming languages make this assumption. > …I love computers. Me too, kid. Me too.
- NuSkooler 3y agoI've only skimmed so far, but this looks really great. Good work!
- 0x978 3y agoWow, found your github from this and getting insane imposter syndrome haha, very impressive work
- deleted 3y ago[deleted]
- t0b1 3y agoThat‘s a very nice writeup, I like the style. The mix of text to illustrations/memes was really pleasent. I have my reservations about the RISC/CISC nomenclature but I guess that‘s „each to their own“ >.> As someone who has spent some time figuring out how parts of the kernels work I can sympathize with the pain it probably was (but well worth it given the article imo). For NT, I think that Windows Internals covers a lot about the stuff one wants to know and Microsoft‘s documentation is also not bad (certainly better than Linux‘s kernel docs imo); it‘s a really good starting point. For more info about Windows I can recommend gamehacking forums/resources. There‘s a lot of filtering needed but they are a pretty good source of info for niche things sometimes. As a last note, I noticed that the font of some code blocks are pretty large when viewed on my smartphone making them hard to read (e.g. Ch. 6/main.c) P.S.: > If you are a teenager and you like computers and you are not already in the Hack Club Slack, you should join right now Way too remind me that I‘m getting old lol
- deleted 3y ago[deleted]
- brunooliv 3y agoDamn. If you're producing this type of content at 17, I can't even imagine the amazing things you'll be able to do it you choose to pursue the field professionally. Absolutely amazing!!
- fnordpiglet 3y agoWhen I read this and looked through her repos my thought was the opposite in a way - I hope she doesn’t go into the tech field professionally and finds a way to do what she’s doing without her soul being crushed by petty management, pettier corporate goals, and pointless career growth. She’s doing great work as is, I wish there were a fellowship that could let her just keep going without crushing her soul in the hamster wheels of tech.
- osclarto 3y agowow 17! excellent work. You're going places for sure if you keep this up. I would guess even most working Devs don't have any real concept of how things work at the CPU level let alone during high school.
- needlesslygrim 3y agoAs a fellow (very nearly) 17 year old, good job! :^) Just 20 minutes ago I was trying to figure out how to extract the first byte of a 16 bit integer and finding out about Endianness, and you're writing a whole book about CPUs! I'll make sure to read this once I've finished Crafting Interpreters, although it may take a while since progress with that has certainly slowed down (as it does with many of my other projects lol).
- tech_ken 3y agoWow what incredible timing, I was just looking for something like this yesterday!
- dghughes 3y agoGoing down the Rabbit Hole is fun for any subject you learn a lot. For electronics I went down the hole power, current and voltage, EMF, magnetism, ferromagnetic metals, domains (as in magnetic area no networking i.e. electron alignment), virtual electrons, physics, quantum mechanics... Similar for computers you see the high level stuff but then you can go right down to the wire level where bits are voltages +5/-5/0V and clock timing. Although being too curious can be bad thing. You have to know when to stop or where to start. I think we've all heard stories of people troubleshooting who are very intelligent. They're tearing into a problem down to the hardware level or going over code line by line when all they needed to do was reboot.
- mckirk 3y agoAre there any pointers you could share on what would be a good way to go down the electronics rabbit hole? I'm great with software, but still often notice a glaring lack of knowledge when it comes to hardware topics.
- dghughes 3y agoFundamentals of Electronics is what I used for a textbook or one I liked. One thing I'd strongly recommend is to brush up on your math if it's been a while. Calculus included. Electronics is very mathy!
- wizzwizz4 3y ago> when all they needed to do was reboot. That's not fixing the problem: that's ignoring it. Which might be the right decision if you need the computer to work now, but fixing it would mean it never happens again.
- GuestHNUser 3y agoOP, you should take a look at Casey Muratori's course at computerenhance.com The first part of the course's homework creates a simulator of the 1978 intel 8086 (which modern x86_64 assembly still closely resembles). You will learn a lot of things about computers that are really difficult to find elsewhere.
- codenlearn 3y agoThank you for posting the link.
- bityard 3y agoI'm 43 and wanted to say nice work.
- randombits0 3y agoI love this! Maybe dive a little deeper? Like, what happens from power on to login prompt. Like, power good > get instruction from predetermined address > execute (BIOS code) > init hardware > change to protected mode > load OS, etc. Different cpus are different, of course, but they all go through a similar start up sequence. Again, nicely done.
- ChrisArchitect 3y ago[dupe] The other link for this is cpu.land -- stick to your 'official' urls! -- shared and discussed a few weeks ago https://news.ycombinator.com/item?id=36823605 https://news.ycombinator.com/item?id=36823605
- xivusr 3y agoYou've found your calling! Keep up the amazing work.
- ChrisArchitect 3y agoWhat happened to the Show HN: on this?
- dang 3y agoI took it off because reading material isn't supposed to be Show HN. That's not any judgment about the content, which as far as I can tell is great. https://news.ycombinator.com/showhn.html https://news.ycombinator.com/showhn.html
- charcircuit 3y agoThis site doesn't explain how CPUs run programs. It only explained the instructions that CPUs will run and some abstractions on top of that, but not how CPUs typically run those instructions.
- tornato7 3y agoHalfway through part one and I'm hooked! Thanks for writing this. It's something I didn't know I needed.
- elSidCampeador 3y agoNicely done!
- racl101 3y agoVery cool. What a novel way to show your skills to employers.
- nrabulinski 3y agoAs someone who has worked a bunch with debugging Linux itself, debugging qemu, and vulnerabilities in kernel and userspace, I really struggle to appreciate stuff like this because my initial reaction is “well, duh, of course that’s how it works” but looking back at myself getting into those fields I really applaud you and thank you for creating this great content
- headline 3y agoGreat work!
- kaycey2022 3y agoThis is awesome with such good presentation. Well done! I would also recommend the linux programming interface book for those looking for a very in depth introduction to this topic.
- fredfoobar 3y agoWhere did you hear Linkin Park?
- firebirdn99 3y agoThere's a teens react to LP video on YT. It's refreshing. It's how previous generations discovered older music. Also the one on Blink 182...is like, "my Mom loves that song"...so a lot of times that's how.
- archmaster 3y agoI have 10,610 songs in my music library, I listen to a lot of different music! Linkin Park, however, is quite popular — of course, "In the End" itself was widely shared as a meme when I was younger, but I've also just heard it playing out loud in the world.
- effie 3y agoMrmrmmm, the youngling, an engineer with skills in writing, is not just that. An effective PIRATE, and a connoiseur of fine music, she is also. Great things, destined to do, she is.
- petecog 3y agoVery nicely written. Great work! I'm passing it around. Thanks
- camdenlock 3y ago[flagged]
- sethrin 3y agoThe author uses the pronouns "she/her".
- camdenlock 3y agoYes. The author is, like me, a male trans woman.
- bangint 3y agoWhy do you think there are so many of you fellows in this industry, compared to the general population? It's a noticeable skew that has always baffled me.
- sethrin 3y agoWe tend to be introverted (for reasons), and if you can code you're more likely to have the socioeconomic status to be able to transition, or rather the same conditions are correlated with both abilities. It's also a non-public-facing industry in general, which makes it less likely we'll be discriminated against in hiring or employment. So part of it is predisposition and part of it is simply greater visibility.
- sgt 3y agoHow do you know this, though?
- globular-toast 3y agoFacts. What I wonder is if everyone else wants to believe or really just doesn't care. For some reason, I really hate being lied to.
- camdenlock 3y ago
- jononomo 3y agoHow much help did you get from GPT-4?
- archmaster 3y agoI covered this: > I talked to GPT-3.5 and GPT-4 a decent amount while writing this article. While they lied to me a lot and most of the information was useless, they were sometimes very helpful for working through problems. LLM assistance can be net positive if you’re aware of their limitations and are extremely skeptical of everything they say. That said, they’re terrible at writing. Don’t let them write for you. https://cpu.land/epilogue#acknowledgements https://cpu.land/epilogue#acknowledgements To elaborate, I had perhaps 4-6 "conversations" with various GPTs. They consisted of me asking some question or expressing confusion about something I was having trouble researching in case the LLM could either pick up on my confusion and be helpful, or give me a better source to look through than Google. The latter approach never worked, it always made up bullshit, but the former did once or twice — before the conversation deviated into lies, at least, the models helped me get my thoughts straight. At their best they felt like talking through a problem with someone smarter than me. At their worst they were a waste of time and actively misleading. They were usually at their worst. I did not use language models as primary sources for anything; where they helped me clarify my thoughts, that simply helped me know what to research normally, and the only other time I used them was to find a file in the Linux kernel that contained some code I was looking for but didn't know verbatim. Otherwise, the article is entirely originally researched and certainly originally written.
- tails4e 3y agoNicely done, congrats. A really good reference, and the style and flow is very nice.
- yveezy 3y agoYo this is fantastic! Keep doing work like this :-)
- deleted 3y ago[deleted]
- asdefghyk 3y ago"... run programs ...." can be considered at a number of (abstract) levels, until the lowermost level is reached , which is machine language. ( Actually, the preceding statement is not correct , since there is often, [ but not all ways] CPU micro code , below Machine language. Machine language is assembly language translated into ones and zeros , that is loaded into the CPU. CPU microcode is a language used to control the internal CPU logic to execute the machine language.
- beders 3y agoI like that Gen-Z. Back to the basics! Listening to 80s music! Go younglings, go!
- adam_oxla 3y agoAmazing article. I have not seen such a comprehensive guide yet. Although when I have seen the title I was expecting it would be focused more on CPU inner workings: superscalar pipelines, frontend, backend, instruction fusing, memory banks, instruction cache, branch prediction, instruction reordering etc.
- 878654Tom 3y agoWhat a lovely guide and the best part is that it is a genuine guide. Many articles posted on the internet are meant for one thing, guide a user to buy a certain service or product. But after reading the whole guide I only had the feeling of someone wanting to share knowledge. The hackclub also seems to be a very interesting organisation and I hope more and more teenagers will join you guys and contribute to society as you have contributed by making this guide.
- Southworth 3y agoThis is really, really awesome. Excellent work. You’ve a bright career in front of you, I reckon.
- kazinator 3y agoThe guide is stuck in some false then versus now thinking. A preemptible kernel isn't "modern". Cooperative multitasking isn't "old". These are just choices in the design space that can be relevant at any time. Fully preempted real-time operating systems existed many decades ago. Meanwhile, today, there seems to be a renewed interest today in coroutines and fibers and such, and they are showing up in programming languages. Those mechanisms are forms of cooperative multitasking. If you need an embedded system to do a few simple things, why would you threaten its stability with preemptive, interrupt-driven task switching?
- bfay1 3y agoI was about halfway through chapter 3 and thought to myself, "I haven't listened to In the End by Linkin Park in a while, let's spin that up". my reaction when I scrolled down ten seconds later...XD
- demizer 3y agoKid, first of all great job! Second of all I am jealous you understand this as such a young age. I was pounding 40 ounces of Old English in the hood at 17, but should have doing something like this. Granted, the internet was just a baby when I was 17.
- keithnz 3y agoGreat effort, but really still needs a bunch of work. In some places the sentences just don't make sense. I think in terms of CPU, a good starting point is the Von Neumann architecture which most computers are designed around. The current description of CPUs mix things up with OS concepts. You may want to look into things like memory management units ( MMU ) that builds on the basic Von Neumann architecture to provide "virtual memory" such that an OS can use it to provide process isolation that OS's can use. Also the more capable CPUs have what are often called "modes" (protected mode in x86, ARM have a similar thing) to isolate running programs from each other and be able to create rings for things like kernels and device drivers.
- filleduchaos 3y agoI haven't read all of the article yet, but CPU modes are very clearly mentioned?
- dave7 3y agoThere's a whole section on the MMU, virtual memory, paging, process isolation in there already?
- hughesjj 3y agoThis is legit, nice work! I'm going to link this to some friends
- lakomen 3y agoWhen I was 11 I coded in assembly and machine language, what do I win?
- itwy 3y agoIt's just someone impersonating a kid to get GitHub stars. I am baffled HackerNews bought it.
- PrimeMcFly 3y agoDepends, did you do anything more than "Hello world"?
- nemo44x 3y agoI thought it’d be lower level as it’s still very abstract and more of an operating systems guide than a guide on how CPUs physically run programs. Like how a string of current representing 1s and 0s allows the CPU to do certain things, etc. But well organized none the less!
- phkahler 3y ago"After executing an instruction, the pointer moves forward to immediately after the instruction in RAM so that it now points to the next instruction.' What is a pointer? How does it "move" inside the computer? This is low level stuff, but still probably somewhat mysterious to the layman. Never mind the obscurity of the word "syntax".
- archmaster 3y agoThat's true - some level of technical knowledge is assumed, but I'm fine with that. Every article needs an audience. I can't write something that's perfect for everyone.
- dave7 3y agoI see it's already mentioned upthread and you've added to your reading list - but I just want to add yet another recommendation here - Code by Charles Petzold is so so good in it's early chapters when it gets to the program counter and the fetch/execute cycle. I'm sure you'd really enjoy it!
- 1letterunixname 3y ago:x86: Apart from the drawing boards at Intel when the 80286 was designed, can anyone find any evidence or have first-hand experience that rings 1 and 2 were ever used in any specific commercial purpose? (I haven't heard or seen of it.) 286 protected mode was generally a flop (outside of OS/2), while 386 protected mode was significantly better. The LDTR (-> LDT) and hardware task switching (reloading TR) aren't typically used. GDTR (-> GDT), TR (->TSS) and IDTR (->IDT) setup are essential. The TSS includes where to find the 6-7 stacks, and for a permissions mask for port I/O. Double fault handler (in the IDT -> INT 8) is typically what leads to a colorful screen of death. When the double fault handler fails (or the IDT or was overwritten), a triple fault happens and the CPU halts or the virtual machine does it own impression of a colorful screen of death without (usually) actually killing the host machine. An invalid opcode handler permits handling CPU-unknown opcodes in the OS such as using emulation or other hardware. Note that generally most PCs prior to UEFI/EFI booted in real mode with 1 core running, so writing a parallel and concurrent OS typically involves setting up protected mode structures, switching to protected mode, and then talking to the APIC for every other core. Resources: https://sandpile.org https://sandpile.org http://ref.x86asm.net/geek64.html http://ref.x86asm.net/geek64.html https://cdrdv2.intel.com/v1/dl/getContent/671200 https://cdrdv2.intel.com/v1/dl/getContent/671200 https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html https://www.intel.com/content/www/us/en/docs/intrinsics-guid... https://www.amd.com/en/support/tech-docs/amd64-architecture-programmers-manual-volumes-1-5 https://www.amd.com/en/support/tech-docs/amd64-architecture-... SVGA/VGA/EGA https://wiki.osdev.org/Expanded_Main_Page https://wiki.osdev.org/Expanded_Main_Page http://www.osdever.net/FreeVGA/home.htm http://www.osdever.net/FreeVGA/home.htm https://archive.org/details/gpbb20/ https://archive.org/details/gpbb20/ https://archive.org/details/programmersguidetotheegavgaandsupervgacardsbyrichardf.ferraro19943rdedition/ https://archive.org/details/programmersguidetotheegavgaandsu... System management https://wiki.osdev.org/Symmetric_Multiprocessing https://wiki.osdev.org/Symmetric_Multiprocessing https://pdos.csail.mit.edu/6.828/2018/readings/i386/s09_08.htm https://pdos.csail.mit.edu/6.828/2018/readings/i386/s09_08.h... <- CPU fault handlers https://ctyme.com/rbrown.htm https://ctyme.com/rbrown.htm https://wiki.osdev.org/UEFI https://wiki.osdev.org/UEFI USB https://beyondlogic.org/usbnutshell/usb1.shtml https://beyondlogic.org/usbnutshell/usb1.shtml Emulators https://www.qemu.org https://www.qemu.org (qemu-system-x86_64 or qemu-system-i386 for very retro) You'll usually want to create an ELF32x64 binary kernel image that's a bit of real mode, ia32 and then switches to 64-bit registers mostly (ia32e [amd64/x86_64]).
- ec965 3y agocomputers are _so cool_ :)
- max23_ 3y agoRecognize OP is the same author for water.css. Thank you for this good writeup on how things work internally.
- JSavageOne 3y agoWow this is amazing. The writing is actually really good too, I love how personable it is, in contrast with a dry boring textbook. Love it, and wish I had this drive at your age.
- scubbo 3y agoVery nice guide! I love your writing style, and your research skills are clearly top-notch. Great stuff! You might enjoy reading some articles by Julia Evans (https://jvns.ca/ https://jvns.ca/), who has a similar informal, conversational, exploratory style. Stay curious!
- archmaster 3y agoI am very glad you liked it! Julia Evans is one of my biggest inspirations ever. I have a lot of her zines. SHE ACTUALLY READ MY ARTICLE EARLIER AND I JUST ABOUT EXPLODED https://twitter.com/b0rk/status/1689331862487932928 https://twitter.com/b0rk/status/1689331862487932928
- scubbo 3y agoWHOOOO! Congratulations, that's awesome!
- alarge 3y agoThis is so cool! And I'm dismayed that you have been subjected to the typical Hacker News cynicism. By looking through some of your other project and interests, I can see that you likely have a healthy sense of your own capabilities and certainly don't need my validation or approbation. But I'm going to give it anyway. Piffle on anyone who knocks you on tone! It is not trivial to make this level of technical information available in such an approachable fashion. When we first start our careers, detailed technical knowledge and the ability to solve low-level problems are super important. But the way you "crawl up the value chain" in software engineering is to become a "force multiplier" - someone who can make other people more productive. And the ability to communicate well (both what to communicate and how to communicate it) becomes a more and more important skill. This work clearly demonstrates your communication skills. I hope you make software engineering your career choice. The field could use more people like you.
- stodor89 3y agoAwesome! All I could do at 17 was chase skirt and get drunk.
- dreamcompiler 3y agoGreat job! I'm an expert but you were right: I learned some things from Chapter 3. A couple of very minor points: "The first mass-produced CPU was the Intel 4004, designed in the late 60s by an Italian physicist and engineer named Federico Faggin." The first microprocessor (CPU on a single chip) was Faggin's Intel 4004, but mass-produced CPUs existed before that. Earlier CPUs were built from multiple chips, and before that multiple individual transistors, and before that multiple vacuum tubes, and before that multiple relays (although it's fair to say that relay computers were never mass-produced). "The CPU stores an instruction pointer which points to the location in RAM where it’s going to fetch the next instruction." This is also called the Program Counter or PC outside the Intel universe. This is confusing as "PC" also stands for "Personal Computer" but people who learned computing in the days before Intel became popular still call it the PC register.
- archmaster 3y agoI am glad you enjoyed and learned something, thank you! Thank you for the nitpick on the 4004! I think I will actually make a minor correction about that. I know about the Program Counter terminology, and explicitly chose not to use it to be more architecture-independent... but maybe it was a mistake not mentioning it at all, considering it's such absurdly prevalent terminology.
- rrr83 3y agoVery nice work and I am going to save this copy for my 6 years old daughter! Keep it up with your creative skills and deep learning!
- hotsauceror 3y agoHey. Nice work! I really enjoyed reading this. This is the kind of sensible, from-the-beginning writeup that I wish I'd had way back in the day when I first got started. It's a nice synthesis of a large amount of complicated information, and builds a good mental model for someone who isn't looking for a PhD-level understanding. I remember not truly understanding how, when I would load a program on my Commodore 64, "yeah but how does it actually know to run? All I did was read some data from disk and then it just, like, went." This would have provided exactly that kind of understanding. Anyway, good on you. Your article was a real pick-me-up, it makes me happy to see this out there, from young folks. I enjoyed the hell out of it, and I hope you enjoyed creating it.
- archmaster 3y agoI am really happy to hear that, because that was exactly my goal! Thank you.
- gatekempt 3y ago[flagged]
- HocusLocus 3y agoYou are a very skilled technical writer. One way to discern this is asking at a given point, "What question just likely popped into their mind after what they have read?" (you don't have to be right, just close) ... and importantly, "Do they need a little break from the main outline?" Your brief tangents in light blue are a perfect answer to both questions. Your terminal examples show what things really look like, or how they appear to people who work with the code every day. Your narrative glue shows impeccable grammar and flow. Don't try to change your style one bit, let it change itself over time. Never went to college or high school. When I was 17 in 1981 and had been already been deep diving into several different types of computer systems over 3 years, I would have died to read what you have written, just the way it is written. It would have answered so many questions directly, fortunately I sometimes had other peoples' code to look at (and Vector Graphic actually included commented Z80 assembler for their entire BIOS in the manual, many pages!) but when you are short on examples to look at, that's when the real disillusionment sets in. I love today's world, one is only a few keywords away from great examples. The challenge is to present them in a way that someone reading puts it all together and becomes excited about understanding. Great work!
- archmaster 3y agoThank you so, so much for the kind words. I'm always learning, and I'm sure my style will change — hopefully for the better — but it's really nice to hear that cpu.land was anywhere close to as well-written as I was hoping!
- quackduck 3y agoExactly
- nklymok 3y agoHi! Great job! I really enjoyed reading this mini-book and I'm recommending my friends in college to read it. It mentions a lot of topics that we studied during an "Operating Systems" course. We don't have HackClub here where I live, thus I never heard of it, but what they do sounds awesome and inspires me to promote it or even start it here (especially since there's no HackClub in Ukraine). Thank you for sharing this experience, it was one of the best reads I had in a while!
- hghar 3y agoThis is a really cool project, kind of touches a point about the history of computers as we know them now, a wealth of information can be found on classic books such as “The art of computer programming” by Knuth, this is more related to how things work now which has changed a lot over the years but the basics are still there.
- rohinbharg 3y agoSeriously impressive, I'm 27 and I didn't know half the stuff you put in this guide.