Abstraction simplifies complex concepts or systems by hiding underlying implementation details. Examples of abstraction include dogs representing animal species and battery representing stored energy. In software, programming languages, operating systems, databases, and network protocols provide abstraction. Abstraction has advantages like being more concise and hiding details, but also disadvantages as troubleshooting can be difficult and performance issues may be hard to detect. All non-trivial abstractions are "leaky" to some degree as they may not perfectly simplify or insulate from lower level implementation realities.
12. Examples to deep dive
● Imperative vs Declarative
Having a list of animals species to find all sharks
SELECT * FROM animals WHERE family = 'Sharks';
13. Imperative vs Declarative (cont.)
An imperative language tells the computer to perform
certain operations in a certain order. You can imagine
stepping through the code line by line, evaluating
conditions, updating variables, and deciding whether to
go around the loop one more time.
In a declarative query language, like SQL, you just
specify the pattern of the data you want—what
conditions the results must meet, and how you want the
data to be transformed (e.g., sorted, grouped, and
aggregated)—but not how to achieve that goal. It is up
to the database system’s query optimizer to decide
which indexes and which join methods to use, and in
which order to execute various parts of the query.
14. Advantages of declarative language
● More concise and easier to work with
● Hides implementation details
● Make parallel execution easier
15. Disadvantages of declarative language
● Troubleshooting and performance tuning can be difficult
● Has some learning curve
17. Examples
Abstractions do not really simplify our lives as much as they were meant to
● Performance difference between iterating over a large two-dimensional array horizontally and vertically
● Performance difference between two logically equivalent SQL queries
● Dropbox drive slows down due to network latency
● Cannot drive fast in a heavy rainy day
18. The law of leaky abstraction
All non-trivial abstractions, to some degree, are leaky.
19. Working vs Learning
The abstractions save us time working, but they don’t save us time learning.
–Joel Spolsky(JOEL ON SOFTWARE)