Abstraction. And why it is more than just a software concept.

Abstraction is almost everywhere around us and is often the most unnoticed thing. Abstraction can be found in things ranging from an electronics circuit of an FM transmitter to a full-fledged computer or a mere text editing app to a highly complex multiplayer RPG game.
But Apoorv, what is abstraction?
The Wikipedia definition of abstraction goes like:
“Abstraction in its main sense is a conceptual process where general rules and concepts are derived from the usage and classification of specific examples, literal (“real” or “concrete”) signifiers, first principles, or other methods.”
Abstraction aims at modularity and re-usability of a module or a piece of information so that its functionality can be converted into a black box with a known behavior hiding its implementation for ease of use and multitude of other reasons. Now for someone from a programming background this may sound familiar and for those wondering why that is, we will come to it later in this piece.
Abstraction in Mathematics
Now this might sound weird, but yes, we use abstraction in mathematics. Many of our operators use other abstracted operators to simplify the operations. For a simple but naive example, remember how we used to sum numbers by counting sticks, so 4 would be |||| and 2 would be ||.
Now moving onto multiplication we say it is repeated addition. So 2x3 is basically counting 3 times 2 so 2x3=2+2+2 which in turn can be interpreted as counting 2 sticks 3 times counting 1 stick at a time. Exhausting, innit?
Abstraction in electronics
Abstraction in electronics exists for countless decades now. It started commercializing with the manufacturing of ICs or Integrated Circuits. With time, these ICs started getting smaller and packed more mini (more like micro now) circuits on them.

To keep it simple, let’s say you have a simple circuit that amplifies the signal given to it, an amplifier that is. Now this circuit finds its use in various places ranging from FM radios to cars, but, combining every circuit element to create an amplifier every time, is a waste of time and resources, as additional time may be spent constructing the circuit and debugging it. So instead its functionality is abstracted away into a small circuit, a black box(literally), which hides its implementation details and focuses on its functionality and is sure to work the way expected most of the time.

For someone interested in delving deeper, one may read about Moore’s law which is said to govern the current rate of technology growth and the number of transistors(sub-unit which combine to form a circuit, a lower level of abstraction per se) that can be packed into a single chip. Abstraction in electronics is now a major technological achievement and a bottleneck for the current state of technology as technologists across the world struggle with finding new ways to pack more logic into chips.
Abstraction in Computer Science
Computers are literally constructed and built on top of the concept of abstraction. A fully functioning computer has multiple layers of abstraction.
Starting from the very hardware, let’s take an example of a CPU the “brain” of the computer. CPU is made up of different units namely Random Access Memory(RAM), Read-Only Memory(ROM), Cache, Memory Unit, Control Unit(CU) and Arithmetic Logic Unit(ALU). ALU is made up of small digital logic circuits to perform operations like addition, and multiplication among others. Now these circuits, adders, multipliers, etc. are composed of smaller logical circuits made up of, you guessed it, ICs and in fact some of them are shipped as a piece of IC themselves to further abstract the functionality and decrease layers of abstraction.

Now onto programming languages, earlier we mentioned that abstraction is a common concept in programming languages, indeed it is one of the many important concepts of coding and is one of the core concepts of languages like JAVA which heavily depend on abstraction for different reasons like optimal operation and security among others.
Starting from the bottom we have machine languages which is responsible for bit and byte operations in our abstracted hardware. This code is a necessary evil as it is very hard to logically code in but is required by the hardware. So we create small modules of this code to perform operations like adding and subtracting (using our abstracted ALU circuit). We abstract away these modules to create what we know as lower-level languages which as more human-understandable but still close to the machine, as we say. We further use these languages to create what we call Higher level languages that are further closer to the user and are easier to code in. We can stop here, but we don’t and have actually created languages that further abstract away the functionality of languages to provide some user-friendly features.

So going from top to bottom this time, user-friendly language to a higher-level language to lower-level language to bit code.

Now earlier we talked about how we abstract away operations in mathematics. Now imagine a simple code written to sum 2 numbers in a high-level language like Python which would probably span a few lines, would turn into a much bigger code in the lower level language behind Python and which in turn might turn into hundreds of lines of assembly code. Scary isn’t it. Remember next time you print “Hello World” you are actually using thousands of lines of code.
Also, developers these days focus on reusable modular code which can be used multiple times instead of writing the logic for a task again and again. Companies like amazon have abstracted the functionality of their internal tools so in the future they can be added to their cloud platform which now has a humongous amount of services.
Abstraction in modern frameworks
Many modern frameworks like React and Flutter now use the concept of abstraction to make the developer experience less painful by avoiding repeating the same lines of code once and again. These frameworks use Components(React) or Widgets(Flutter), which are basically UI elements whose behavior is abstracted away by the developer and can be used and reused as need calls.

Bottlenecks of abstraction
As astonishing abstraction may sound it leads to some unwanted things as well.
- Imagine creating a program where you need to sum two positive numbers. Now to do that you are using an abstracted operator the “+” sign which is also capable of dealing with negative numbers. This additional property of the operator might mean that it has additional lines of code apart from the main functionality that is important for our current scenario. This additional bunch of code might result in a performance drop in some cases.
- Apart from this the other way round is that abstracted functionality needs to consider and deal with all possible cases to be robust otherwise it may cause errors for example. Say the operator “+” that you abstracted away can only deal with positive numbers and may fail or give incorrect results when running with negative numbers compromising the integrity of the program.
- Apart from that, due to abstraction and the way how things are implemented behind the curtains, simple reasons like using parentheses in a block of expression might result in huge performance differences.
That said, abstraction is a necessary evil as it lets us build faster and more efficiently or speaking in general terms it saves a lot of time and effort for us by avoiding to deal with specificity of individual tasks and treating them as atomic units to deal with a bigger task.