I came across this interesting article “10 Basic Programming Principles Every Programmer Must Follow” and it made me write this blog which I had been contemplating for a long long time. The article talks about best practices in coding, but what I want to write about is what I learnt from Software Programming in general and how I related those concepts with outside world or other real-life matters.
I graduated as a Mechanical Engineer and was placed in a leading Indian software company through campus interviews. The interview process consisted of solving mathematical puzzles during a written test, and solving more puzzles during interview! I couldn’t have asked for more! I did fairly well and was happy that I got to know few new puzzles. I also thought that that’s what they did in software programming – solving puzzles using a computer program! Well, not in the places where I worked later on…
Since my joining was few months away, and I had no background in Software Programming, I joined a prestigious course by C-DAC called Diploma in Advanced Computing. The course was rigorous and well-designed (was at par with Computer Engineering or more advanced, in some areas) and the faculty was really good!
We started with “C” language and learnt about Data structures and database queries and implemented using C – usual popular exercises such as sorting a list (Bubble Sort, Quick Sort), finding prime number, palindrome, creating a calendar, basic payroll processing etc.
The first learning was that C was a procedural language and not Object-oriented i.e. C program would run sequentially – the only way to jump the control was by calling a procedure (or a function or a routine), in which case the control would jump to that procedure, finish execution and then return back. But the flow was always fixed and only 1. This was a serious limitation – because real life things (or “objects”) are not sequential or linear in nature. Events don’t take place one at a time, many events happen “at once”. And events are inter-dependent on each other. So C was useful for doing a task or activity (e.g. calculating the compound interest, given rate of interest, number of months and principle amount) but it was not capable of “simulating” the real-world objects; and it was not capable of parallel processing or multi-tasking.
This led to learning “Object-oriented” programming! I learnt C++ and Java. But before that I learnt “Object Oriented Programming” Concepts. In nutshell, everything in the world consists of Objects – which have Properties (attributes or characteristics) and Methods (functions or behavior). For example, if you are reading this post you belong to a class = Human Being (hopefully you are not a machine or a humanoid!) and you have properties such as Age, Gender, Height, Weight, Date of Birth, IQ (hopefully!) etc. and you have methods such as reading, smiling, scratching, frowning, sitting, standing, running, drinking etc.
You are an “instance” of class “Human Being” i.e. you are one living copy of the template called “Human Being”. There are 700 billion such instances! Then there are other classes such as “Cat”, “Dog”, “Donkey”, “Tree” etc. You interact with other instances of your class or other instances of other classes.
Remember, you cannot interact with a Class directly, because it doesn’t exist! You can interact with an instance of a class i.e. manifestation of an abstract concept called class into a real-world object. Does it sound like God (Class) and God-man or reincarnation of God as human (Object)? Well, it is…
Once you establish that the entire world is Object-Oriented, it seems so obvious that it is difficult to imagine why it was not thought of in the first place. Well, the answer again lies in a phenomenon you can observe in real world – evolution! Necessity is the mother of invention. Early programming languages were developed to add numbers and calculate interest amount and sort a list. They were meant to do stand-alone “tasks”. When you are at that level, you don’t have to have object-oriented view. And that’s how it was. As purpose and utility of computers expanded to solving business problems and automating business processes, the “object oriented” view emerged.
Then there was another revelation from the real-world understanding of Evolution – that species evolve from other species – or classes morph into other classes. Homo Sapien (today’s human) is a “descendant” of “neanderthals”, which in turn is a “descendant” of “monkey”. In other words, class Human Beings inherited genes from Neanderthals which in turn inherited genes from Monkeys. Inheritance! Another learning from the world which was adopted to Programming. The world is not only object-oriented, it consists of classes which are “inherited” from ancestors. You cannot exist as an isolated entity in this object-oriented world. Nothing can. Everything is in form of Class and Object.
So inheritance means copying. Or passing on the qualities (properties and methods) from Parent class to a Child class. But then what use is it if we are just copying the qualities from one generation to another? In real-world we “adapt”, we “mutate”. i.e. we “inherit” some qualities but then we give a new meaning to them! We retain some qualities as they were. And we may also drop some qualities if they are useless (the way humans dropped a tail).
This was incorporated in Object-oriented programming as “Polymorphism” – something existing in many forms. So a child class would not inherit certain quality from parent but would give new meaning to the same quality. For example, monkeys would use nails to protect themselves. Humans use it for nail painting! Same attribute, different meaning/use – that’s polymorphism.
Hey, but there is another interesting thing programmers learnt – that you can “invoke” parents’ quality whenever you want. Most of the times you would use nails for fashion – but on rare occasions you would use nails the way your ancestors did – for safety, or even for attacking! Programmers quickly figured out that it is a useful mechanism – which we give new meaning to inherited qualities, we should also have access to its old meaning, if need be! This is achieved through “overloading/overriding”. You override the current meaning/utility of nails and invoke ancestral utility (Animal Instinct!)
That’s brief learning from Object-oriented programming.
Then I learnt about Databases and database structures. Relational databases and structures/unstructured data, and database query. In early days of Software Programming the focus was entirely on structured data and somehow trying to fit everything into structured data. You tied to classify everything as multiple structured data tables and created a “reference” or some unique identifier across these tables so that you can run database queries and fetch records. The emphasis was entirely on keeping things sorted or “sorting” things at run time. But the effort and time taken to achieve it increases exponentially as database grows!
This was another big learning for me. And the vague learning, understanding I had was cemented when I recently read a book called “Algorithms to live by”. I briefly mentioned it during one of my earlier blog post.
The sorting time and computation effort increases exponentially when the data size increases. This understanding needs no proof. It is inculcated on us to be “organized”, to keep things neat and clean and always in sorted manner. And we do try hard (some not so hard, but they do try). The problem is, it is simply impossible to do it as number of objects to be sorted increases. Mathematically, effort increases exponentially. So after a point we tend to give up (even the best ones who really want to keep things tidy).
The same was the case with early years of programming. Computing power was increasing rapidly (Moore’s Law) and it was outpacing the increase in data by huge margin (because the records were generated manually – through data entry). However, with advent of Internet the “good sorting boy” broke down. All of a sudden, the entire world became data entry operators. And to make matters worse, they were generating unstructured data – a kind of data which cannot be fit into structured table (Key-Value pair) – for example, free text or text and and image etc.
And that is when programming world turned their attention to “searching” rather than “sorting”.
Searching is for lazy people. If you don’t keep things sorted you would end up searching for it when you need them. And that was considered as a bad quality. You would be considered unorganized, lazy, inefficient if you didn’t know where was your car key or mobile charger. And simplest way to overcome that was to be organized, be process-oriented, follow some structure and rules – exactly like “structured database and sorting” approach.
But what if you had an amazing knack of “searching” anything that you wanted in almost zero time? You need not be organized, or follow a process/rules. You can leave things anywhere and retrieve any time you want! That’s what “search algorithms” did! With Google search and other search engines you could leave things unsorted and search when needed. And you could search on unstructured data as well!
When a tidy, organized, careful person suddenly becomes untidy, unorganized, care-free, that’s called paradigm shift in his personality. You can no longer apply same rules/constraints. In programming world, it is called change of Architecture!
In last few years the architecture has completely changed – what started as Standalone (everything on same machine), then Two-tier (client-server), then three-Tier (Client-middle ware – server), has now evolved into multi-Tier and multi-component based Architecture. And this has transformed the programming languages as well. Core Java knowledge is still necessary; but not sufficient. Because there are so many layers built upon the core languages which deliver the programmes needed for current applications.
This brings me to my last learning – related to language and literature – and culture.
Before software programming I had learn Chess “notation”. I was also aware of musical “notations” – be it Tabla notation or synthesizer. But I had never paid attention to the word “notation” (as opposed to language).
Notation is used to describe the subject matter and to communicate within a limited scope. I can read notations of a Chess game and reconstruct or re-play the game. Musicians can read notations of a music peace and recreate the music. So notations can completely address the communication needs for that domain or subject. However, they are not meant for extending beyond their domain; and are thus incapable of expressing any other thought or emotion or message. In chess, “!” is used to describe an astonishing move. That’s it. You can not express “After this more the opponent was really taken aback and started sweating and went into depression”. Chess notation is not meant to do that. That’s job of “Language”. Language is the method of human communication, either spoken or written, consisting of the use of words in a structured and conventional way.
In that sense, programming languages are not languages. They are merely notations meant for writing a program and converting it into executable. Words “script” or “code” are often used in computer programs. I feel those are more appropriate words. Anyways, we still call programming languages – be it C or C++ or VB or Java or .Net.
Here is my more deeper understanding. A language must evolve. It must adapt and adopt new words, new constructs and be relevant for the current need of communication. It must enable complete expression of thought/feelings. And we also need a “script” which can completely support the language. Sanskrit is supposed to be a rich language and Devnagari script is supposed to be complete and well-rounded. However it did not have the script or letters to express the pronunciation of words such as “water” or “match”. Devnagari script adopted or invented new characters to address that. वॉ in वॉटर and कॅ in कॅच are not part of original Devnagari script and were added when the need arose.
The same has happened and is happening to software programming. C was procedural, hence object-oriented languages came (C++, Java). They were not capable of addressing new Architecture, frameworks so new technologies (Web 2.0) emerged.
Some languages become popular among one particular community because they are good at the purpose the community is looking for. And it also shows how “evolved” these languages are, or how culturally relevant they are. For example, my mother tongue Marathi is really a rich and beautiful language! But it has not evolved or culturally fit with many new world objects, references. Do you simply adopt and embrace the established words or artificially create parallel words in your own language/script?
I recently read following awkward words in a Marathi article on Finance.
The Marathi words are really odd and tongue-twisters. Even for people who do not know either Marathi or English word, it is much easier to find and memorize English word because it is already commonplace. What’s the point in fabricating some far-fetched Marathi words? Just accept that your language has not evolved in this domain (Finance) and adopt what is a norm.
Thus Language also shows richness of culture in that specific domain. Marathi language, spoken by 75 million people stands at 19th most spoken language in the world. Hindi language spoken by 260 million people would be among top 5 or 7 in the world. Yet, both languages are very poor in terms of vocabulary for Medical Science, Advanced Finance and few other such subjects. It is better to learn them in English. Rather impossible to learn them in these languages.
English language has a prototype of words for many relations – “…in-law”. Father-in-law, mother-in-law, brother-in-law, daughter-in-law, on-in-law, sister-in-law etc. When I learnt the English words I thought how individualistic and narrow-minded these people would be. In Marathi (and all Indian languages) we have different words for each of these relations. In fact we also have unique words for complex relations such as “your son’s wife’s father” (व्याही) or “your wife’s sister’s husband” (साडू).
This doesn’t mean that we Indians had nothing significant to do and we kept on inventing words for such odd relations. It only means that our family structure was so rich and close-knitted that there was need to have unique names for all such relations and identify and respect them separately. “In-laws”, in comparison, looked to me like a “catch all” exception! Shows the cultural bankruptcy of English family system.
The point is, it is nobody’s mandate to keep the language fresh and relevant (even if it is made mandate of someone or some department, it won’t happen). It can happen only through constant participation and contribution from the entire community; the need for adaptation and sense of belonging!
I no longer do “coding”, but the things I learnt from programming are immensely useful even today. It taught me to look at the world through a different lens!
P.S: There were couple of occasions when I remembered programming principles again – (1) while watching a movie and (2) while discussing a Marketing concept and a key Social issue in India. Will try to write about them in a separate blog some other day.
P.P.S.: Just read this wonderful quote; one more learning!
“We build our computer (systems) the way we build our cities: over time, without a plan, on top of ruins.” – EllenUllman