Skip to content

Abstraction

Abstraction is perhaps, one of the most important concepts to understand in the realm of computing.

Abstraction is the process by which we define an entity with only the information relevant to a user of the entity.

When we use a function print(), the process by which text is sent to the terminal (stdout) is omitted. We identify this entity (function) just by its behaviour and the properties related to its behaviour (say, the stream that it is output to, and the text that is output by it)

Why Abstract?

  • Code Readability - using abstractions like functions makes our code cleaner to read, because someone looking at them can evaluate the purpose of a chunk of code by just understanding the IO characteristics of the function.
  • Size - using abstractions reduces the size by your code.
  • Universality - the good thing about abstractions is we can mix and match layers. Code written on C for one microarchitecture can be compiled for another microarchitecture as well, using a different compiler.
  • Specialisation - in a system running without abstractions, every programmer would need to understand every aspect of the system. However, thanks to abstraction, a C developer (you!) need not know the specifications of your RAM to be able to store a variable in the memory.

Downsides of Abstraction

  • This mix-and-match compatibility can often be expensive. We want each layer to be isolated in its behaviour, which is very difficult to achieve in practice.
  • A monolithic architecture can be faster, as it does not involve the overheads needed to keep layers separate.