Recently I talked to a friend who wanted me to teach him programming. I said okay, but I wasn't sure where to begin. At this point I’ve accumulated almost two and a half years experience in my software development career. This article uses the knowledge I’ve gained and attempts to give a five minute introduction to programming (before writing any code).
Programming is all about giving computers instructions to execute. Computers consume instructions in the form of binary numbers - which is a base two integer (0 or 1). The reason why computers use a binary language is because the processors and memory inside computers are made up of many transistors (when I say many - the iPhone X has 4 billion transistors in its processor). Transistors handle electrical currents and can be in one of two states - on or off1. This makes them a perfect match for binary, which also has two states. Each binary number is known as a binary digit, or bit for short.
While easy for a computer to understand, humans don’t naturally communicate in zeros and ones. I do find it fun to play around with binary for academic purposes - for example the 3-bit binary digits from zero to four are 000, 001, 010, 011, 100.
Obviously programmers do not spend their time working in binary (well, at least the sane ones don’t). We use different programming languages, and with those languages we create applications that people use on their computers every day. However, all the code that controls applications is eventually converted into binary instructions for the computer’s processor to consume.
The concept that allows developers to work in high-level programming languages instead of binary is known as abstraction.
The process of hiding away implementation details at a lower level to create a simpler high-level framework. In programming languages, abstraction is used to hide away the complexity of machine level instructions at a low level, while presenting a human readable language at a higher level 2. Inside a piece of software, certain complex components can be abstracted away and presented to future developers in a simpler form. In a non-programming context, abstraction is classically used to describe how a car has simple high-level operations such as braking, moving forward, and moving backward. At a low level, a car is made of many small pieces working together - however the driver does not need to understand how they work. These low level operations are abstracted away.
In programming languages there are multiple layers of abstraction. The first layer of abstraction from binary is called assembly language. Assembly consists of instructions that are written in a more human readable form than binary. Instructions are processed by computers one at a time. When assembly language is executed, it is converted into binary for the computer to read.
Assembly language is still a very low-level abstraction above binary. The following MIPS Assembly code adds two numbers (7 and 3) together and prints out the result:
If you aren't sure what is happening in this code that is completely okay. The important takeaway is that assembly code is verbose and forces developers to think like a computer. Because of these drawbacks, assembly code is rarely worked in.
The same six lines of assembly code above can be rewritten in one line with the high-level Python language.
Due to their ease of use, programmers usually work in high-level languages. Just remember that when you execute high level code, it is converted to an assembly language and then binary for the computer processor to consume.
As a beginner, the first challenge is to learn a high-level language and slowly explore into the unknown (the de facto standard language to teach beginners these days is Python). It is never too early in your software development career to begin building your own applications. Developing applications is the only true way to learn how the ever-growing programming ecosystem works.