Abstraction and API

Abstraction is a manner in which a person interacts with a program or system without directly working with more complex details “under the hood” or in a “black box”, so to speak. Complex details that may not be of interest are abstracted away so that the programmer works with only what is necessary to him. Abstraction is a key part of computer science and even in life in general. Earlier in the curriculum, students have seen that, although perhaps not of the highest level, C is a high level language, with machine/assembly code a level below, and binary code even further below. Such lower level languages are abstracted away so that the user can program in C without necessarily needing to know what goes on under the hood in machine code and binary. Similarly, APIs (Application Program Interfaces) are a level of abstraction used so that others may use function calls without needing to know what exactly happens when the function is called.

In this section, we’ll go over the idea of abstraction in the context of the CS50 library function get_string();, our own functions, strings in C, and the Google Maps API. By building upon preexisting creations in the computer science community, we can avoid “reinventing the wheel” and instead focus on innovating above and beyond what we have today.