Abstraction

Before starting, I’d like to mention that I’ve added the ability to post comments on individual entry pages. Also, I’ve added rudimentary syntax highlighting for code examples. As always I greatly appreciate any feedback as I continue to make improvements and tweaks to the site. Enough with the maintenance, let’s dive right in!

So I’ve decided to write my first “real” blog post about a subject that I am passionate about. Abstraction. To be clear, I define an abstraction as the separation of a tool/idea/method from its implementation. For instance there are several ways of communicating a message: by voice, email, letter, instant message, etc. The abstraction is simply ‘communicating’. The medium is irrelevant.

For those that are not software developers or engineers, the concept of an abstraction may seem foreign but they are in fact vital to our way of life. The fact of the matter is that there is far too much information for any one person to process. Abstractions insulate us, protect us, and allow us to understand complex systems from a higher level. Because of this, you don’t need to be a mechanic to drive a car, an electrician to operate a television, or a computer programmer to access a website.

This concept of abstraction is of vital importance to technology, but by design abstractions are generally to be ignored and taken for granted. Because of this we are able to live without convulsively having to know just exactly how every piece of technology that touches our lives is used. Increasingly, I find it useful to analyze these abstractions and traverse their different layers.

I recently finished Code by Charles Petzold and really enjoyed his bottom-up way of teaching. He begins with an example of two children using flashlights late at night to shine messages into each other’s bedroom windows. From this foundation he explains the fundamentals of morse code, the telegraph, and eventually the logic gate. To quote Joe Rose, my first programming boss and mentor, “Nothing we will ever do here is that complicated. Tedious? Yes. But complicated only if you try to look at it all at once.” Going back to Petzold’s book, this bottom-up approach really exposes the reader to every level as it is taught and then abstracted. By doing this it empowers the engineer-hopeful and gives them a powerful tool in analyzing the world around them.

While this ability to black-box things has been responsible for our technological growth, there are some consequences to its application. One thing I’ve seen time and time again in subjects of math, science, and engineering is a willful refusal to sometimes break abstractions and trying to understand things. I guess even outside those domains I see this as an issue sometimes. It blew my mind to save as much money as I did by learning some basic maintenance of a vehicle. I guess this is why I find the bottom-up approach so appealing. With it, working at any level of abstraction requires you to know at least a few layers deeper. With the incredible availability of information these days there’s very little that you can’t research and figure out yourself, given enough time.

On the other hand, undervaluing abstractions can easily lead to poor engineering, over-complication of a problem, and headaches. I guess my point is that like all tools they need to be understood in the context of their applications. In designing a full system, I think that a top-down approach helps to alleviate this. By designing interfaces at a single level, you can avoid making an issue overly complex by ignoring any of the details and not over-engineering a solution. For a simple example, the code block below demonstrates complexity by utilizing different levels of abstraction and not performing a singular identifiable task.

1
2
def cylinder_area(radius, height):
    print 2 * 3.142 * radius * height + 2 * 3.142 * radius * radius

While this isn’t too difficult, imagine seeing that single evaluation in a couple-hundred lines of code. To make it more complicated, imagine replacing the 3.142 with a mathematical approximation of Pi with Machin’s formula. Pi is a great example of just why abstractions are so useful to us.

To get back to the first example, a better solution would be as follows:

1
2
3
4
5
def cylinder_area(radius, height):
    pi = 3.142
    border_area = 2 * pi * radius * height
    end_area = pi * radius * radius
    print end_area * 2 + border_area  # 2 endpoints

Admittedly this example is incredibly simple and not one I would implement myself (most languages have an established Math.Pi constant as well). It does however illustrate my point of differing layers of abstraction. Imagine for a second that you had no clue what Pi approximates to or even the proper way of calculating the area of a cylinder. The first method is cryptic and assumes that the reader will understand the approximation of Pi. The second works at a single layer of abstraction by defining a constant before executing and then building up a solution progressively. In both of these examples, the same answer is returned and as such can be treated as a black box with the appropriate abstraction. In the first case such an abstraction serves to insulate us from a sub-par implementation.

This is a subject to which I could write much more but feel that my point has been made so will leave it with some closing thoughts.

  1. Abstractions are of vital importance to us and our way of life. Embrace them and learn how to apply them to your self-discovery and learning.
  2. I would advocate a bottom-up approach to learning a tough subject. This is taught to us in mathematics but is often ignored for very similar types of learning.
  3. When designing a system, I would go with a top-down approach. This allows you to quickly list the necessary modules for a “complete” solution.

Hello World

Greetings everyone. This is my first blog post in well over a decade but I plan on making many more with the hopes of helping other curious folks as I continue my studies in computer science.

My name is Roland Heintze, I work as a Django Developer out of Tampa for a small startup. I graduated from Georgia Southern University in 2013 with a bachelor’s in Computer Science but believe that this was merely a new start to my journey into solving technical problems as a lifestyle. I consider myself a decent programmer but have worked with some very sharp people and picked up some good tricks along the way. Before programming professionally I was in the military as a Reconaissance Marine. I hope that this will lend an interesting tilt to my writing and I’ll try to draw up parallels and analogies between these drastically different fields whenever possible.

I have created this site as a means to showcase my work, share tidbits of things I’ve learned, & encouraging myself to continue learning but also to start documenting these experiences. I’ve tried many different languages and frameworks but this is the first that I’ve thought about cataloging these kinds of efforts. In doing this I believe it’ll help me to reflect on lessons learned and better retain the important bits. Additionally I get the added benefit of possibly helping other students along the way.

I don’t want to pursue any single aspect of computer programming/introspection so I expect the content to vary wildly depending on my mood and interests at the time. In the coming months I have considerations of covering various Python libraries, Jekyll (what drives this site), useful scripts, Angularjs, nodejs & its tools, static analysis, and various problems that I have been faced with.

As of now the site is fairly generic and I imagine it changing drastically as I get more feedback from my readers. If you would like to contact me with any questions, thoughts, or ideas for this blog please feel free to do so. I can be reached by email at rheintze on the linux.com domain. I can also be found idling freenode on #shaft.