Hook
Computers make no sense. Throw some metal in a box and boom. What the heck is going on here? All of computer science (worth knowing) sponsored by Brilliant. Inside your PC is a central processing unit or CPU. It's basically just a piece of silicon with billions of microscopic switches called transistors, depending on the flow of electricity, they can be on or off, which gives us a light bulb, which gives us two states: 1 and 0. The value of switches is called one bit. One bit by itself doesn't really do much. But put them together and a group of 8 bits is called a byte. It can have 256 different combinations of zeros and ones. Congratulations, we can now store information in a system called binary. Every bit represents a power of 2. One means the power is included, and zero means it's not. So this number has 1 * 64 and 1 * 4 and 1 * 1, which adds up to 69. This is brilliant. But I like this. Hexadecimal is even better. It's often denoted by 0x and is a more readable format than binary. Four binary bits can take any value from 0 to 15. Hexadecimal uses 0 to 9 and A to F to represent those values. So a group of four binary bits can be replaced by one hexadecimal digit. Okay, now that we can store numbers. We just need the computers to actually do something with them. Using transistors, you can make logic gates, which are electronic circuits that encapsulate logical statements. You can think of it as a light bulb with two switches. It only turns on under certain conditions. For example, only if A and B are on. By combining logic gates in a clever way, you can build circuits that perform calculations according to boolean algebra, which is a system formalizing mathematical operations in binary. But even though computers understand zeros and ones, for humans it's not really all that useful. So using a character encoding like ASCII, we can assign a binary number to each character. When you type it on your keyboard, it gets translated into this binary code. As the computer sees this, it says, ah yes, that is capital A. And slaps it on the screen. How these devices fit together is handled by an operating system kernel, like Windows, Linux or Mac, which sits between computer hardware and applications and manages how they all work together. For example, with device drivers. Input devices allow you to give the computer instructions, but at the lowest level, computers only understand instructions in machine code, which is binary code telling the CPU what to do and which data to use. Following these instructions, the CPU is kind of like a demented goldfish with a CPU. It can handle any instructions but cannot store any data. So it's only really useful with random access memory or RAM. You can imagine it like a grid where every box can hold one byte of information, which can be data or instructions, and has an address so the CPU can access it in 4 steps: fetch from memory, decode instructions and data, execute, and store the result. This is one machine cycle. Since a program is basically just a list of instructions to run it, the CPU executes them one by one in machine cycles until it's complete. Oh yeah. This happens like, really fast. Modern CPUs can do billions of cycles every second, which are coordinated and synchronized by a clock generator. The speed of this clock is measured in Gigahertz, and people often overclock their CPUs to improve performance, which is nice, but might just set your PC on fire. What's even crazier though is that a CPU has multiple cores, which can all execute different instructions in parallel, so at the same time, each core can be split into multiple threads, which allows every core to handle multiple instructions concurrently, switching between them really quickly. Okay. Okay, that's cool. But it doesn't matter how powerful a computer is if you have no way to give it instructions in the first place. Typing machine code by hand would probably make you go insane. But luckily, you don't have to. The kernel is wrapped in a shell, which is just a program that exposes the kernel, allowing for simple command line interface with text inputs. But the best way to make a computer do something useful is with a programming language, which uses abstraction. So that instead of this, you can write code that looks like this, which is then converted into machine code for you. Some languages like Python use an interpreter, which directly tries to execute the source code line by line. Other languages like C or Go use a compiler, which converts the entire program into machine code in a file the CPU can execute. Now every programming language has different syntax, but they all have the most basic tools almost all of them have. The most basic way to use data is with variables.
More breakout videos from this creator.