Abstraction is an extension of encapsulation. It is the process of selecting data from a larger pool to show only the relevant details to the object.
Abstractions are nice… until they stop working. cough cough Robotics.
In terms of my thoughts on the layers of abstraction (from NVIDIA):
- One could argue that clean code is when there are lots of layers of abstractions, and things are modular and all of that. But it is just so hard to understand, when you have to jump from functions to functions to functions
It should definitely help that the naming of the variables should be explicit. However, seeing how the Comma code was written, it’s not that good.
Our World Is Based on Abstractions
Our entire world operates on abstractions. Here’s one more recent abstraction that I learned: When you enter a website URL, this seems to be what is going on:
You think that you are communicating with a server located at
www.medium.com. However, once you start understanding how the Internet works, you realize that you actually need the IP Address. So there is a whole DNS name resolution process behind the scenes:
CS241 deals with these abstractions more at the software level.
It is important to truly understand how we move between these abstractions.
- 1st abstraction: From a sequence of 0s and 1s (Machine Language) Opcode(Assembly Language)
- 2nd abstraction: Label
- 3rd abstraction: Variable
In ECE222, we also really get to learn the layer of abstractions, now more at a hardware level. See Layers of Computer Program.
They talk about role of abstraction: “In symbols one observes an advantage in discovery which is greatest when they express the exact nature of a thing briefly and, as it were, picture it; then indeed the labor of thought is wonderfully diminished.”
- When you abstract, you have to think less hard.
But I mean, simplicity has its pros and cons.
Abstraction is great for users. But if you want to innovate, you need to dig under all these abstractions and really understand what is going on under the hood. Become 10x Developer.
I mean when we talk, it’s really an abstraction of what is really going on under the hood. Into something more tangible and understandable.
Abstraction is like doing PCA, where you reduce down the dimensions to something simpler. Well… I am not 100% sure about this analogy.
It’s like when I try to understand Priority Queue, or essentially any ADT. Different data structures have different uses cases. YOU can operate at a higher level of abstraction, where you just memorize the time complexities of that data structure.
OR, you can actually try to understand why those are the time complexities, and that will also help you remember that information better. But to do that, you need to go down a layer of abstraction.
So do you really need to go down a layer of abstraction to understand why insertion for Priority Queue is ? Not really, you study it for the programming interviews.
When do you go down a layer of abstraction?
There are connections with High-Level Low-Level Thinking. Go down a layer of abstraction when you need it, but when you do, make sure you FULLY understand. Ask not only HOW, but also WHY.
I feel that I still operate at too high of a level of abstraction to understand how robotics works. I am able to use all these libraries. But now, I want to be able to write my own.
Andrej Karpathy talks about this idea of leaky abstractions. It can be attributed to this.
To read: The Law of Leaky Abstractions (2002 blog)