Sunday, February 2, 2025

History and Development of Programming


In the beginning of the Information Age, computers were programmed by wiring instructions into the circuitry. One of various calculations was selected using switches or making connections to different logical units by wires.

The wiring of the switch boards became a thing of the past with the invention of vacuum tubes, and then the transistors.

Claude Shannon demonstrated the application of binary logic in computing to complete the software concept of modern computing.

Meanwhile, John Von Neumann’s concepts of shared-program technique and conditional control transfer, decoupled machine (hardware) from their execution (software), re-locatable code, and later subroutines and flow control.

Jaquard (1804, France) designed a loom that performed predefined tasks through feeding punched cards into a reading contraption
At first, programming was done by typing in 1's or 0's that were stored on different information carriers, like paper tapes, punched hole cards, later magnetic drums, and much later magnetic and optical discs.

The next development was to combine groups of instruction into so called words, and written in shorthand as opcodes (Hopper 1948). The opcode was translated by another program into zeroes and ones, which formed machine instructions. These formed the modern day machine languages.

Programming in initial crude languages generated a lot of what was called, "spaghetti code", which still exists today, but only in much larger projects. Subroutines were developed to avoid this pitfall by climbing up the abstraction level.

Then IBM created FORmula TRANslator (1952), which was much more intuitive for computation. Fortran programs were then translated to machine readable format. It was the first major programming language as we know today.

In the meantime hardware developments made live for programmers a lot easier. But programs still had to be rewritten for each type of processor.

All machine specific tasks were delegated to a common module called Operating System (OS). The first fully portable language, C, was developed. Now, programs could be written independent of the underlying hardware, using libraries to perform all machine specific instructions. SourceCode could be reused, only to be recompiled when it had to run on other machines.

After Portability, came the problem of Reusability, and Object Oriented Programming was introduced with the development of Smalltalk. GUI’s were created to expedite the creation of software.

References:
1. Introduction to Software History – http://www.thocp.net/software/software_reference/introduction

Communism vs Free Markets vs Capitalism



Economists sold us "Free Markets" over "Communism", 
but all we got was "Capitalism"! 




Programming at a More Abstract Level: A case for C++ in embedded systems

Programming at a More Abstract Level: A case for C++ in embedded systems

Programming at a More Abstract Level: A case for C++ in embedded systems

Most critics try to give the justification that when performance is at the premium, you must go down the level of abstraction. But rarely do they try to figure out, how much advantage is actually achieved by doing so.

A typical graph of optimization vs. effort would look like this –

Optimizations mostly happen at the algorithm level, no amount of machine code writing can account for such huge differences in performance. More often than not, stooping to lower levels of abstraction, only adds to the baggage to be carried through the rest of the product life cycle, and hinders important optimizations. It is only at the fag end of the optimization cycle, that removing abstraction is not offset by its negatives. Hence, it should be performed only when the whole software product is completed, decisions taken, and it’s fully ready for mass production – commercialization. They don’t start painting the car while the fittings and hammerings not yet done. The irony is that we start designing the color of the car when we don’t yet know what the car is going to be like; we start writing C & assembly code when the product’s not yet ready.

------------------------------------------------------------------------------------------------------------

"Abstraction is a process whereby we identify the important aspects of a phenomenon and ignore its details." -- [Ghezzi et al, 1991]

This is a review of only the performance impact of choosing C vs C++ language. Provided below is an analysis of the C++ code and its C translation –

(Thought the tone is pre-judgmental, the first 4 reason why C can be slightly faster, and methods for avoiding it, and the last 2 show why C++ can be faster)







C++ Method Invocation All C++ methods when translated to C end up with an additional parameter. This might appear to be a big performance overhead. In reality however, the code in C will also have to access the common data structure via an array index or some other mechanism.
Object Construction Whenever an object is constructed, C++ will invoke the constructor. Sometimes this might be an addition overhead. This overhead can be reduced by defining the constructor inline. In most cases however, the constructor is actually replacing a routine that would have been used to initialize the data structures in a conventional C program.
If a program declares a lot of global objects, object construction can be a big overhead at program startup. C++ invokes constructors for all global objects before main() is called.
Object Destruction As you can see from the C code, whenever an object goes out of scope or is explicitly deleted, C++ invokes the destructor for the object. This overhead can be reduced by only defining destructors when they are really needed (i.e. some action is required when object is deleted). Inline destructors can also be used to reduce the overhead.
Static Access The C code above shows that static member functions and variables do not correspond to an instance of the object. Thus they are accessed without indirection of the object. This can be useful in defining methods which need C level function call conventions. One good use for static member functions is to implement interrupt service routines (ISRs). ISRs handlers typically need to be C type functions. In most implementations, C++ static functions can be directly used as ISR handlers.
Quicker Optimization The higher level of abstraction and modularity in C++, topped with the available of better standard libraries, speeds up the optimization phase, enabling more conceptual and algorithmic optimizations. For example, stl vector containers built from arrays will be regularly used for variable sized data in C++, as against linked lists in C.
Generic Programming Compile time Generic Programming provided by C++ avoids C function call overheads, created as a result of modularizing. (Note: Modularizing is essential, as you don’t want a single bulky function). Below is a typical example using C++ sort lib. vs C qsort lib., but all computational libraries fall under this.

Running Times





Data Type C (library) C (hand-coded) Numerical Recipes Ratio 1 C++ (C array) C++ (vector class) Ratio 2
int 5.90-5.92 1.54-1.65 1.46-1.50 3.7 1.12-1.16 1.11-1.14 5.3
short 9.03-9.03 1.73-1.80 1.58-1.59* 5.1 1.17-1.20 1.17-1.19 7.7
byte 7.87-7.89 0.98-1.02 0.98-1.00 7.9 0.70-0.73 0.70-0.73 11.0
float 7.08-7.10 2.38-2.50 2.48-2.55 2.9 1.96-2.02 1.97-2.02 3.6
double 16.42-16.45 2.70-2.93 2.72-2.83 5.8 2.28-2.35 2.28-2.37 7.1

• Numerical Recipes is the code from Numerical Recipes, a combination of multiple algorithms, aborting quick sort on data set less than 7, and performing linear sort.
• Ratio 1 is hand coded divided by the library routine
• Ratio 2 is C++ sort divided by C qsort

------------------------------------------------------------------------------------------------------------
If i were to say, i was satisfied at the level of interest shown by us, incl. me, to get an approval for a change in the language of implementation of our future projects, i would be definitely lying.
Not only does C++ score completely over C in terms of code size, effort spent, etc, it indirectly has advantages in performance.

Here are 2 samples of real life potential opportunities for optimization in our own OpenGL-ES project, using C++'s Generic Programming and STL tools.
1. In tests using textured objects, about 40% of the time is spent in a single module, which involves running a few reasonably coupled routines, each of which can be performed in a number of ways by the user. We are currently forced to write them independently, instead of compiler optimizable combinations, to avoid bloating the code. The solution was trivial using templates.
2. On an average about 5% of application time is spent on one of the standard data structure maintenance. We are forced to forfeit the use of highly optimized, industry-standard libs.
[Note: though not everybody in the team may know all of the language features, it permits use of special features in specific cases, with the bulk of the project being C programming.]

Thursday, September 15, 2011

BUG

Glitch, bug, deviation, defect, error, are all synonyms of failure. A glitch in function or a bug in working, causes deviation from expected behavior, resulting in defects in output, and an error in decision making, that causes failure to accomplish the task. These are are all products of human mistakes, which are inseparable from humanity. As long as they are humans performing, we cannot eradicate errors. Not being perfect is one thing, but not striding towards perfection, yet another. Not making those little progresses, completely inexcusable.

See any field or activity of human life, though humans always err, mistakes was never made the norm. Mistakes are not to be tolerated, and not just corrections but preventive measures were built in to counter them. These are ingrained into our lives right from the childhood. A doctor leaving his forceps in a patient's stomach is made to dearly pay for it. If a building collapses, the builder is sent to jail. If you supply faulty material, you completely compensate. These are ways human society has ingrained into us to disincentivize carelessness and build reliability.

Everyone was accountable for their deliberate actions, as well as held responsible for their preventable errors, with few notable exceptions. In olden days, only the kings had such exemption. In modern days, they are a full breed, called software engineers. Whatever they do, they can get away with it, in the name of intrinsic fallibility of human nature. If such errors were to be tolerated, would a driver be let go for blinking for only few seconds on the highway. Or, such leeway made available to manufacturers of faulty clothes that fall apart on day one. Or a pilot be excused for reporting late and delaying air traffic while he was having a nap. This is not even a lethal mistake, but only a monetary one. If they are all made to pay for their mistakes, software engineers are let free. Tolerance to a bug, is the first step in enduring and encouraging mistakes, and the foundation for rampant unreliability.

Tuesday, April 29, 2008

Multi Level Marketing pyramids; beware!

Wikipedia (as of Apr 29, 2008) has interesting articles showing clear contracts between legal & sustainable
multi-level marketing schemes and illegal pyramid schemes.

In short, pyramid schemes just transfer money from large section of participants to a small group of top ones.

MLM schemes on an average sell you the products at retail price minus the advertising costs. All else in it is pyramid.

Federal Trade Commission, US, advises that multi-level marketing organizations with greater incentives for recruitment than product sales are to be viewed skeptically.

Since many are still falling prey to these, esp. in the "free" market world, we owe it to spread this info and forewarn others.

Keywords: ACN Inc., Agel (MLM company), Alticor, Amsoil, Amway, BioPerformance, Cobra Group, Deutsche Vermögensberatung, Equinox International, Excel Communications, Forever Living Products, Freelife, Fuel Freedom International, Fund America, Inc., Herbalife, Holiday Magic (Company dissolved in 1974), Juice Plus, Kleeneze, Mannatech, Mary Kay, Mini IQ, Monavie, National Safety Associates, Neways, Nu Skin Enterprises, Omegatrend, Oriflame, Pre-Paid Legal Services, Inc., Primerica, Quixtar, Shaklee Corporation, Stream Energy, Sunrider International, Tahitian Noni International, USANA Health Sciences, World Financial Group, XanGo

Friday, January 11, 2008

Most Disorders Are Learned

There are people. They are all different from each other - physically different, levels of intelligence, aptitude, behavioral style, etc. Here, using myself as an example and analyzing deeply, I intend to explain, how many behaviors that we term as abnormalities, are learned, and not genetic.

Multi-personality Disorder:
Many times I plan for something, but do otherwise. At that moment, I'm not in control of myself, and don't realize what I am doing. Sometimes I have experiences, I consider as best forgotten, and put them behind myself. Has a different personality of mine overtaken me at that moment? No.
It is like what i do when i cross the road. I decide whether to cross or not - either-or. Never do i take a middle path of crossing patiently, if a vehicle is approaching. Is this what should be done? yes. You can't stay on the road obstructing it. You have to either cross, or wait. There is no partial solution. So also in behavior. Either i do it, or wait for others to do.
When i make a decision, i follow it. I don't reevaluate my decision at every stage. I put any other options behind me. I drop them or try to drop them from my conscious mind. This is just normal behavior.

Dyslexia:
I am Clumsy, uncoordinated, poor at ball or team sports, and prone to motion-sickness.
I have difficulty putting thoughts into word, with severe communication handicap.
Despite a lot of rereads, there is little comprehension. Also, possesses strong sense of justice, and strives for perfection. These are all typical strong symptoms of dyslexia across various function areas.
Can it be attributed to any reason other than dyslexia? yes.
I never played ball or team sports in my childhood life. I was an extreme introvert, always in my den, and rarely interacted with people, resulting in later life difficulties in communication. At the same time, i'm pretty good at spellings due to a devoted & focussed primary school teachers.
I'm also exceptionally good at Maths.
These are complete coincidental skills that i learned in my childhood. Any Learning happens best in Childhood. Anything learned in that period, you are strong at, and learnings missed out during that period are difficult to catch again. This is the single largest reason for learning difficulties of people in particular areas. It is not something baby is born with, rather acquired since.

Autism:
I never feel too attached to people. I never feel having to do anything for others' feelings. Is this Autism a problem? I feel No. It is a purely rational behavior by motivated people.

So most abnormalities or disorders are acquired behavior, rather than based on hereditary.

Thursday, March 1, 2007

Tool IT

It is not just Science and Technology, but the Tools that empower Modern Man.

I woke up one fine day, to the redness of the sky. The sun was not yet up, but I dragged myself out of bed. It was going to be long and tiring day ahead, just like any other day. My workplace is a good 10km from my residence. I had to hurry to meet the 10o clock deadline. I had already been twice late in the month. Once more late, and I would not be left with enough leaves to visit my village during Holi next month. It takes 2-weeks for a visit, and I had been saving up for it without taking an off even during illness during the last 6-months. I just couldn’t afford to waste it now. One more month, and the New Year would start, with new leaves allocated.

Due to the moonless night, I couldn’t figure out the time, and now I see the sun rising along the horizon. I skipped my breakfast, as hurried to work, as I had no horse, and it took around 2 hours to cover the 10km distance on foot. By the time I reached office I was already panting. Then I finally got down to hand copy a thousand prints of my article for the coming edition of our magazine.

No, this is not the description of the world today, thanks to our ancestors who had the hindsight to build upon existing technologies and left us a wide pool of tools we make use of. This is the description of the days gone by, the era that was and the era that still could’ve been. Now we have automobiles to travel, a watch to track time, and trains and even planes to make visits to hometown on the weekends, and printing machines to make copies.

Our ancestors left us a strong legacy of highly potent tools built with advanced technology. They learnt science, made advances in technology and innovated new equipment to solve old problems. Tools are the culmination of all their work. Tools are the reason why modern man achieves much more than his ancestors. Common man today covers much more distances in his life than navigators like Columbus could ever do. He enjoys so much of technological luxuries which Newton or Edison did not. Take away the tools and he would be no different from his ancestors. Have you witnessed the fright of a man left unarmed in a jungle. He would simply panic in front of a wolf. Provide him a gun and some armor, and he would hunt tigers and lions.

It is not just Science and Technology, but the Tools that empower Modern Man. Tools also make his life easier and more productive. It differentiates his era from the pre-historic. In his short lives, he accomplishes much more today than his ancestors. Tools give him the means to execute without actually toiling for it.

The more you employ tools,
The easier your life is, and
The more competent you are.

While Tools empower those who command them, they hinder those who don’t. They increase the level of competition to such great extents that those devoid of tools simply perish. Only fools, not even fools, attempt to race against motorbikes. But when it comes to software development we do exactly this. We manually code, debug and test. Agreed, that tools might not have developed enough to write good software on their own, but they have developed enough to aid many phases of software development. Conceding that you might already be using an IDE and a debugger, but there are much more advances than these. And the generic logic holds even in software - the more you employ tools, the easier your life is, and the more competent you are.

For writing code, besides the well adopted IDEs, there are a huge number of predefined libraries and frameworks. There are advances in programming languages with newer constructs to ease your lives. There are a number of reasons to dump C and use C++, and no counter-reason that cannot be avoided. I’ll leave those for another article. Plenty of tools have already flood the market for reviewing code and finding bugs, that employing people to do it is a waste of effort. Automated build environments have come up to do the testing as well.

The adoption of these ready made systems is quite low in the industry. It can be said that only because of a highly fractured software industry is such incompetence being sustained. As was seen in all mature industries in their transition periods, when a few players adopt new tools and become more competent, all other minnows are wiped out. When a farmer brings in a tractor for ploughing, manual ploughing in the neighbourhood no longer remains economical. When Babur invaded India with his highly equipped army, all fragmented states fell like a pack of cards. It is yet to be seen which software players pioneer the adoption of the advances in Tools and Technology and consolidate the market.