r/computerscience • • Oct 18 '24

how exactly does a CPU "run" code

163 Upvotes

1st year electronics eng. student here. i know almost nothing about CS but i find hardware and computer architecture to be a fascinating subject. my question is (regarding both the hardware and the more "abstract" logic parts) ¿how exactly does a CPU "run" code?

I know that inside the CPU there is an ALU (which performs logic and arithmetic), registers (which store temporary data while the ALU works) and a control unit which allows the user to control what the CPU does.

Now from what I know, the CPU is the "brain" of the computer, it is the one that "thinks" and "does things" while the rest of the hardware are just input/output devices.

my question (now more appropiately phrased) is: if the ALU does only arithmetic and Boolean algebra ¿how exactly is it capable of doing everything it does?

say , for example, that i want to delete a file, so i go to it, double click and delete. ¿how can the ALU give the order to delete that file if all it does is "math and logic"?

deleting a file is a very specific and relatively complex task, you have to search for the addres where the file and its info is located and empty it and show it in some way so the user knows it's deleted (that would be, send some output).

TL;DR: How can a device that only does, very roughly speaking, "math and logic" receive, decode and perform an instruction which is clearly more complicated than "math and logic"?


r/computerscience • • Jul 24 '22

Can linked list be implemented using arrays? As you can see in this resource said Yes and if you scroll down someone commented on this post said No. So any ideas on this question, pls?

Post image
163 Upvotes

r/computerscience • • Jan 15 '18

In a rest stop bathroom and of course you have all the usual profanity ridden writings on the door, and then this etched into it.

Post image
163 Upvotes

r/computerscience • • Feb 06 '24

Help Book Recommendation on Computer Science

162 Upvotes

I am looking for books on fundamentals of computer science (not language or framework specific)

I am an experienced dev but I often my findself digging into the low level details when I get time but these are so siloed.

I took computer science in college (but that's the time when I was too naive to appreciate the beauty of fundamentals and hurried to learn javascript instead)

Ideally I also would prefer if the book has a lot of graphics

added bonus if the book is on oreilly


r/computerscience • • Apr 09 '21

Help What exactly is a Turing Machine and why is it so important

162 Upvotes

Was reading The Emperor's New Mind by Roger Penrose and Chapter 2 is essentially dedicated to explaining what a Turing machine is.

After I watched a few videos I kind of understood what it was but all the videos I watched essentially just sad that any computable problem can be done in a Turing machine and that it was the best computational model we have. However, they don't rly explain it and I got rly confused by this. Why can any problem be done in a Turing machine and why is it the best?

Also, why is it important? What else do I need to know about Turing machines when I go to uni?


r/computerscience • • Mar 13 '20

Help Calculus and computer science

162 Upvotes

I’m actually at a loss, math is so extremely hard for me; algorithms and what not are more easily grasped but math I just can’t handle.

I’m all honesty I wouldn’t consider my math to be full on calculus since it’s pre calculus and is simply preparing me for the real thing. I’ve never struggled so hard at a subject in my life. When I look at it, it’s like a completely different language; I understand with time that it’ll get better but does anyone have any words on how impactful math was to their education or computer science career. I guess I need a little inspiration and actual input to those who have made it. Also if anybody has any advice on how I could learn pre calculus and calculus on a college level by my self since the teaching style my professor has doesn’t match with my learning style, that’ll also be appreciated.

Thanks for the advice and time.

Edit: I know people probably won’t look back at this but for the few people that helped me so much I wanna thank you guys so much; honestly I don’t think I would’ve gotten through pre calc without your guys info, help, and guidance and what to do and handle this hurdle. Thank you everyone, this was something big to me that may not be big to others and I just wanna say thank you to everyone. I hope all of you have a great day and that I could return the kindness to someone else. :)


r/computerscience • • Nov 09 '19

Code is magic

162 Upvotes

I just had a wonderful realization and I thought I might share. To preface this, I always wanted to go to Hogwarts as a kid and learn magic. I became somewhat disenfranchised with the world as I grew older, but I have recently begun to rekindle a sense of wonder and excitement for the world.

A big part of that has been learning to code. I was thinking about this the other day, and I realized that I have essentially been learning magic by any standard throughout history, and for some reason I take that for granted!

Through a high-level language, we manipulate electrons in order to create symbolic information patterns that can accomplish real tasks - to anyone from any other time in history, if they could see us they would think we were literally witches and wizards.

At Hogwarts the students learn to predict the rough future through magic. I can do the same with data analysis, game theory, and machine learning networks. They can see things from the other side of the world - I just finished coding a security cam for my dorm. They can imbue non-living matter with sentience - robotics. They can manipulate life - bioinformatics - if I had access to the right tools I could literally breed glowing animals. Artificial intelligence adds an even cooler aspect to this given we might soon be able to create sentience from non-sentient matter! Even the bad powers, killing people, controlling people etc are real - consumer programming, psychometric targeting through the internet, drone strikes, malicious hacking, etc.

By extension, everything we are exploring in modern science is really magic. We don't really know how this stuff works or why it works - if you look at the physical constants of the universe they seem somewhat arbitrary. While we do have a good sense of the relational properties between things in reality, we don't know why they are what they are - like electrons! We know the rules that dictate their interaction with other things in reality, but we don't know why they exist the way they do, where they came from, or for that matter where any of this really came from! Somehow through all these layers of abstraction, from basic properties of atoms and forces, to high-level symbolic computation, we manage to actually do stuff, and that stuff is no less absolutely amazing! I don't think it's hyperbole to say that we're all doing real magic.


r/computerscience • • Oct 05 '19

Article Processing 40 TB of code from ~10 million projects with a dedicated server and Go for $100 (13129 words)

Thumbnail
boyter.org
162 Upvotes

r/computerscience • • Feb 04 '23

LGP-21 Optimum Address Calculator

Thumbnail
gallery
161 Upvotes

r/computerscience • • Dec 06 '22

The connection between math and CS

161 Upvotes

I'm a sophomore in college and I can't find the connection between math and CS. I know they're closely related. I'm currently finishing Calc 3 and we're doing flux integrals. They just seem so irrelevant to my future! I can understand math's capacity in cryptography. What I can't understand is derivatives and integrals. It's so hard to find motivation to complete these math courses when I can't relate them to high level programming. I could understand the application for simulated physics or something but I just don't see how that will be relevant to my future.

Anyways, I just want some clarification or reading on how closely related these two fields are. Some sort of connection to inspire me to do well in math. A book or something. I need a rabbit hole. Thanks


r/computerscience • • May 03 '21

When to use recursion?

Thumbnail self.computerscience
161 Upvotes

r/computerscience • • Feb 03 '21

Happy birthday k-nearest neighbor

161 Upvotes

Today marks the 70 years since the inception of k-nearest neighbor by Evelyn Fix and Joseph Hodges - the first true machine learning algorithm. Happy birthday k-nearest neighbor.


r/computerscience • • Jan 17 '23

Discussion PhD'ers, what are you working on? What CS topics excite you?

160 Upvotes

Generally curious to hear what's on the bleeding edge of CS, and what's exciting people breaking new ground.

Thanks!


r/computerscience • • Aug 03 '22

Discussion As Moore's law breaks down, will there be a resurgence in low level languages in the not too distant future?

160 Upvotes

I believe the emphasis on vms, interpreters and containers and the like will be replaced when we need more efficiency.

These things are likely a luxury of the era that we live in

Also, this: https://en.m.wikipedia.org/wiki/Jevons_paradox

In economics, the Jevons paradox (/ˈdʒɛvənz/; sometimes Jevons effect) occurs when technological progress or government policy increases the efficiency with which a resource is used (reducing the amount necessary for any one use), but the falling cost of use increases its demand, negating the efficiency gains.[1] The Jevons' effect is perhaps the most widely known pitfall in environmental economics.[2] However, governments and environmentalists[needs update] generally assume that efficiency gains will lower resource consumption, ignoring the possibility of the effect arising.[3]

In addition to my original point, I think the current state of technology is allowing deeply inefficient code to ship. I wonder if the inefficiency is encouraged by use of certain technologies and frameworks and if they are "long for this world?"

I'm curious as to what your thoughts are about this and how this would play out over time. Personally I can see low level languages becoming popular again but with heavy abstractions over it, something like a gui app that makes programming very easy but all the real, highly optimized work is done by an expert system (or an 'AI' if you wanna call it that)


r/computerscience • • Jul 13 '22

Advice Computer Science books to read in free time

160 Upvotes

Hi everyone! I am finishing my Bachelor's degree in Computer Science.

During my studies I discovered that I really enjoy the topics of functional and logic programming, theory of computer science and computations, and such similar topics (e.g., Category theory, Type theory, Lambda Calculus, Turing machine...)

I want to read books on those topics, but I am quite busy with my schedule.

Could you recommend some books which I can read in my free time, which do not require some exercises or coding in order to follow along?

Thanks in advance!


r/computerscience • • Jan 06 '21

Linus Tovalds Blames Intel for Killing ECC RAM in Consumer Systems

Thumbnail
extremetech.com
160 Upvotes

r/computerscience • • Feb 19 '25

JesseSort is getting faster...

159 Upvotes

Pushed a C++ version and tested it against std::sort on 2^24 values.

JesseSort: 2.24347 seconds
std::sort: 0.901765 seconds

Getting closer... Still haven't implemented Powersort's optimal merge tree and this version is missing the saved index locations between loops. Anyway, I'm excited so I thought I'd share. Have a good night!

Edit: Just realized this is also missing the base array copies. I bet that'll speed it up too!


r/computerscience • • Nov 21 '22

What are the main Computer Science theorems?

159 Upvotes

I have been wondering which theorems like Little's Theorem were groundbreaking on computer science?


r/computerscience • • Mar 07 '21

Why computer architecture does not suck

159 Upvotes

Hello,

I hope that this post does not break any rules (I checked the sidebar and didn't see anything against this). I just made a video talking about computer architecture, false sharing, and showed a practical example of how much of a performance degradation false sharing can cause.

I believe that computer architecture is an incredibly dope area of computer science and found that too many people hate it for the wrong reasons. If this sounds like it would be up your alley, then feel free to check out the video here: https://youtu.be/BJ2mwsXjleM

I am open to criticism and other feedback. I am very new to making videos and video editing, so any feedback on how I can improve my content is welcome :)

~ArseniyKD.


r/computerscience • • Dec 20 '20

Advice CS Pleasure Reading Books

159 Upvotes

What are some good CS related books for pleasure reading?


r/computerscience • • Jul 31 '19

Math Basics for Computer Science and Machine Learning [PDF]

Thumbnail cis.upenn.edu
159 Upvotes

r/computerscience • • Mar 12 '19

30th anniversary of world wide Web today.

159 Upvotes

r/computerscience • • Oct 24 '17

Quality Sorting algorithms visualized.

Thumbnail
imgur.com
158 Upvotes

r/computerscience • • Mar 12 '26

RIP Tony Hoare 1934 - 2026

Post image
157 Upvotes