3 ms·
A good example are SQL queries. You can have two semantically equivalent queries i.e, two queries that will always return the same results. However, runtime ma
by nextos 8y ago
A good example are SQL queries. You can have two semantically equivalent queries i.e, two queries that will always return the same results.
However, runtime may be dramatically different. One may take a second, and the other one days.
That's because SQL is an imperfect abstraction. It isolates you from the underlying details on how to compute the results of a query, but only to some extent. On many occasions you need to actually understand how the declarative query is translated into an execution plan.
- parsnips 8y agoSo sorting is a leaky abstraction? Because merge sort and bubble sort can both have the same interface, isolating you from underlying details...
- elvinyung 8y agoYes, exactly. The slowness of the bubble sort "leaks" the fact that it's a bad/naive implementation of sorting.
- tabtab 8y agoAbstraction is often defined similar to "hiding irrelevant details" so that one can focus on the forest instead of the trees. However, sometimes tree-level issues affect the forest view also. An unexpectedly slow sort operation may be such a case. Normally you cay "ORDER BY x" in SQL and not worry about HOW the RDBMS sorts on "x": "How" is a "grunt-level detail" to you. But if the sort is slow or "wrong" (such as a collating sequence not expected by the customer), THEN you have to dig into the details, stepping out of the abstraction forest to visit and study individual trees.