Do programmers really need to know binary?

When people think of binary code, the matrix automatically comes to mind, and trying to understand how to read it is near impossible. Programmers do not just have one job, and just like developers, they can vary. So do programmers need to know binary? Let’s find out.

Programmers need to understand how binary works related to data formatting, general formatting specifications, and a concept known as flags that hold true or false states of something in particular. For this reason and many advanced ones, developers need to know binary; however, people don’t really need to know binary if they are only learning languages. 

This article will detail if all programmers need to know binary code and if it is still relevant in today’s digital world, and how it works. Then we will take a look at how necessary binary code actually is to developers and what type of a difference in understanding it would make to their job. 

Do programmers really need to know binary?

Many individuals who want to become programmers often ask the question, “why do you ever need to know binary.” It may seem like binary code is a form of code that you will never really need to use in programming, and the truth is if all you plan to do is learn a language or make the most basic of applications, then you probably don’t need to learn binary. 

However, the ability to actually design and make proper systems and applications requires that you understand binary for many reasons. Let’s take a look at how important binary is for a programmer. 

binary under code
Everything you use on your computer is essentially built with binary. Coding languages are like a layer over binary which makes it actually possible for us to understand the code. As a Web Developer I don’t really need to know binary in any detail, but knowing how it works related to data formatting and to some coding statements is beneficial. When I just started programming I had no idea how it works, and that is completely fine.

Is binary code still important?

It is essential to understand that every single thing on your computer is coded with binary, from the application I’m using to write this article to the websites you browse on the internet, videos you watch, the music you listen to, and everything in between.  All of these digital systems are coded in binary to precise requirements.

For example, computers use ASCII (American Standard Code For Information Interchange), a system that converts text to binary digits. Each letter of the alphabet will be assigned an ASCII value, and when a computer reads this ASCII value, it will convert the text to binary. 

How does binary code work?

Binary code is the simplest numerical system, only having two integers, namely 0 and 1. The zero, in essence, stands for “off” while the 1 stands for “on”. You can think of this concept as similar to a switch. In fact, a switch is a perfect example because a switch allows you to turn the current on or off accordingly. This holds true because computers need electricity to function, and binary code is so small it can be stored in a transistor. 

A switch in computers uses a Boolean logic system to control how a computer will interact with electricity. This is, in essence, is the switch. When the logic system reads TRUE, the switch will turn on, and when it reads FALSE, the switch will be turned off. This is how electricity and computers work together. It is important to note that a computer can read binary code at a speed that is probably beyond the imagination of an average human being. This is what makes it so powerful.

Video: Binary Numbers and Base Systems Explained

How important is binary to programmers?

Considering data formats

As we said, a programmer might not need to code in binary, but understanding it is imperative, especially regarding data formats. For example, the bytes of a binary code regarding a specific file format will be coded in a particular way. If you don’t understand this, it will be challenging to develop systems around the file formats. Let’s take a BMP file:

A BMP file is a simple form of a graphics file that follows a specific format with regard to binary code. The first two bytes of a BMP file will represent the file format. This means the first 16 digits (ones and zeros) of binary code will implicitly state that that file is a BMP file and no other file type. 

The next four bytes of any BMP file will specify its file size. This means that the next 32 digits of binary code after the initial 16 digits will tell the computer how big the file size is for that particular file.

Hence, if you don’t understand binary, you will have a more challenging time trying to follow data formats requiring you to express values in binary. With our example of the BMP file, if you try and save it, you will have to specify that data is in binary, or it won’t work (be able to be saved).

Considering format specifications in general

When trying to develop anything computer-related, many format specifications will require a programmer to have a knowledge of binary to write programs that can produce or read that particular type of data. 

Many well-designed data format specifications will often use binary data in various ways. This will especially be true that anytime within the format that some “quantity” has to be known. This can be understood by taking our previous example of binary code determining file size. Almost all these types of quantities will be expressed in binary. This is due to binary being the shortest and fastest way that your computer can read any value. 

In simpler terms, if you are looking to create some system or application on a pc or looking to integrate it with other computer systems, many of the determining values of the important data will be represented in binary. This is because computers can read this super quickly and easily. 

Considering flags

Another reason that a programmer should understand binary involves a concept known as “flags”. (This is not a flag on top of a flag post). Flags are virtual representations in binary code of several true or false states of something in particular. Let’s use a game for our next example. 

The example entails you trying to design a game and keep track of several false states of the player’s weapons that may or may not be in the player’s inventory. The game has a total of eight weapons, so how could you keep track of them? 

Well, if you understand binary, you could do that with a single byte (remember that a byte consists of eight digits of binary code). Each binary digit could represent each individual weapon. The number 1 would represent that you have that particular weapon in your inventory, while a zero would define you not having it in your inventory. 

These digits of the binary inventory byte could change to reflect each weapon and its true or false state depending on when you find the weapon or remove it from your inventory. 

It is important to note that flags are everywhere in programming, and that is why it is being mentioned here. You will run into flags often with data formats, and understanding how they work and understanding how to turn “on” and “off” binary values are fundamentally important. 

Furthermore, in many instances where the source code you read contains advanced operations on binary data, you will need a complete understanding of it. Without understanding how to count and read values in binary, you will be unable to understand the code correctly. 

These are the simplest examples we can explain when it comes to understanding binary and but not at all the only ones. Subjects like advanced data formatting also incorporate binary code, but that is beyond this article’s scope. 

Conclusion

We discovered that binary code is used for everything on a computer. It is impossible for us to use or have them without binary code. We also now understand that programmers on a fundamental level need to know how binary works in order for them to do their job correctly. 

However, coders and developers in the sense of programming languages may not need to have such a detailed understanding of binary as an engineer does.