Monday, October 14, 2019

Absolute Abstraction

Brutes abstract not - John Locke

Today I'm lucky enough to be seated comfortably at my favourite spot at the Coffee Bean Cafe. This means that I can really relax and settle down on my thoughts of the day. Or rather, what I've been thinking about lately.

I have been working on my personal projects most of the time, doing a lot of coding. When you code, your main preoccupation is getting the application functionality done in the cleanest and simplest possible way. That's something that's easier said than done.

All developers know that they are always working within time constraints. Your users wanted it yesterday. So you try to push out something reasonable quickly, often having to resort to workarounds and quick fixes. Users are happy as long as the application works. They only see the facade of the software--its user interface. As long as it meets all the requirements and does not break easily, they walk away happy. You live to code another day.

But six months down the road, they come back to you with more requirements for the application. And when you open the hood, you realized that you do not understand your own code anymore. What seemed so logically clear and obvious previously now looks like spaghetti code to you. All your workarounds and quick fixes have come back to haunt you. You have to invest a lot of time to try to understand what you or another co-worker have done. Without understanding it again thoroughly, any change could break the entire application in unexpected ways. You have to suffer the karmic consequences of your coding sins.

There's a whole slew of best practices for the programmer to avoid these pitfalls. Clean code requires modularity and separation of concerns. Every part does a small well-defined job with clear inputs and outputs. At the lowest level you have objects with encapsulated data and methods, which collectively performs the function of a specific layer or a tier of logic. The entire 'application' could also be a microservice--the building block of another larger service or application.

Each level is abstracted from the other. You can be working at the microservice layer and sees each component as having clear and clean APIs. That's all you need to know. Details and dependencies that you do not need to know are hidden away from you. Abstraction is the key to peace of mind. As a programmer, you might be responsible for all the layers of logic but at any moment in time, you are only working at a particular level of abstraction. And that is the most important thing.

Life too consists of many levels of abstractions. To a CEO, all the divisions and departments in his companies are objects and layers of abstraction. He only needs to know what resources are needed by each and what deliverables are expected of them. The departmental heads are working at another lower level of abstractions. He has workers with well-defined job functions. They need to do their part to ensure that the goals of the department are met, which then feed into the overall delivery mechanism of the company, orchestrated by the CEO.

Any individual is also made up of many levels of abstractions. You can consider your physical body as the lowest level. You have no control over how your individual cells and organs operate but you can ensure that you eat the right food, do the proper exercises and keep it safe from external harm and make sure it is well-rested. That will ensure that the machinery of your body continues functioning--you can walk, you can talk and you can think and reason.

Our ability to think opens up another dimension of abstraction. This is where we often encounter 'spaghetti code'. If we know how to abstract different domains of our intellectual and emotional lives, we'll never get them mixed up together. A lot of pain and conflict in life arise because we are too muddled-headed. We let personal issues affect work and vice versa. We are unclear about what resources are required for each and every aspect of our lives. We allocate too much time and money to unnecessary things, simply because we have no clear boundaries between the different domains, each with its individual demands.

The practice of mindfulness helps us to abstract things. We see a thought as an object that has a lifecycle. Nothing more, nothing less. No single thought hogs the entire process. They come, and they go. There's inversion of control--your awareness controls them, and not the other way round.

A bunch of thoughts make up a personality: your Self. The self is another layer of abstraction. It has an ego, which is an apparent interface requiring certain dependencies as its input. But the self is nothing more than the amalgamation of your many thoughts, which are the result of the neuro-physical activities of your brain and body chemistry. Who is it that plays at this level of abstraction? The soul, perhaps?

The soul sees the self and the human body as having a lifecycle. There's inversion of control again. The physical self is but the souls momentary instantiation. Many religion plays at this level of abstraction. They claim that the soul lives on after the physical body dies--to be judged in an afterlife or to be reborn again in another cycle of instantiation. But is the soul too another level of abstraction?

Perhaps there are infinite levels of abstractions? And we in the smallness of our self-oriented consciousness can only speculate as far as the soul. Are we not part of a higher existence which plays at many levels of abstractions? Our language is only suited for describing our very level of abstraction--so we can only speak of human-like God or gods. Are these not mere models, mental stepping-stones for exploring higher levels of abstractions? To speak of the soul, is already an achievement of abstraction of sorts. How else are we supposed to ascend to even loftier levels?

Well, let's meditate on it. Let's abstract it. It's the least we could do.