First off, people don’t code in binary directly. The lowest level any remotely sane person works in is machine code, which is still a step above raw binary.
As for how we use binary to code in the broader sense, the full story is a bit complicated, so let’s work our way up.
Firstly, we break up a string of binary into blocks. A standard size for a block is 8 digits, known as a byte, but there are both larger and smaller blocks that are used. For our examples, we’ll stick to a byte.
You’re correct that binary can only store numbers directly. In the case of a byte, we can store anything between 00000000 to 11111111, or 0 to 255 in decimal. But, we can still use that to store text. Imagine you’re sending a message to a friend, but you can only do it via numbers. What you can do is agree beforehand that a particular number corresponds to a particular Latin character. Say, 1 through 26 is A through Z. If you receive the numbers 3, 1, and 20, you can refer to the code you agreed on and realise they’re sending CAT.
You can encode whatever you’d like onto those numbers. The alphabet, numbers, whole words, colours, whatever you can think of. We call a particular code a format, and there’s hundreds of them for all sorts of different things. We can even encode the information about different file formats so the computer knows how to interpret a particular file.
And to circle back around to the original question, one of the things we can encode is what we call instructions. Instructions basically tell a computer what to do on the hardware level. I’m not going into how *that* works because there’s not really any ELI5 way to do it. Suffice it to say, the CPU can receive a number and then based on how it’s been built/programmed, it can execute an instruction. A set of these instructions is called, surprisingly, an Instruction Set. Right now, there’s two main Instruction Sets that are used, x86 and ARM.
You could code on a particular instruction set, but that’s not common. Low level programming is usually done with Assembly, which is effectively hardware instructions, but optimised slightly for human readability.
Most software development is done on high level programming languages, however. These are much more human readable than Assembly, but don’t correspond directly to instruction sets like Assembly does. They thus need to be transformed into a format that the hardware can understand directly, which is the job of a compiler.
Latest Answers