Sunday, December 23, 2012

The idea of justice

This is not about the book. But it may have something from this one.

Newspapers are now filled with lines like "We want justice" or  "Justice delayed is justice denied". Why do we have this apparent lack of justice? One thing that comes to mind is the fact that justice is not what it used to be. The only kind of justice available now for law abiding citizens of the country is what can be called legal justice.

I feel justice is a sort of cultural thing. It is something that is obvious to people at all the times but capturing it in rules and guidelines detaches it from its cultural roots.  The good and the bad part of legal justice is that it is defined and written. Just like all computer systems are hack-able, so is legal justice because it is also a kind of "code". Code that runs on computer has finite set of symbols and it has no ambiguity, and still it is possible to hack it. The code of legal justice has further complications, it is subject to interpretation. In some sense best lawyers are  hackers of legal code. They are highly paid and celebrated, whereas their computer counterparts are looked at in totally different spirit.

I can think of only two ways for legal justice to be effective. One is to have the jury system. If 10-12 random people think something is a crime, it likely is. People are a very good competition to people. They can understand each other, their motives and can evolve with time, unlike rules which can be easily abused. Lots of criminals would have been behind the bars if we have random people deciding their fate and not a set of rules, subject to interpretation of a small set of professionals. People can understand why witness turn hostile or why you don't get evidence. The law that only punishes criminals if there are witnesses and evidence,  is the logical/primary reason for criminals to threaten witnesses and to hide evidence.

The second way could be rules which are defined using languages that computers can understand. The benefit of such an approach is that anyone sitting in their home can input the related facts and see the outcome of the trial. We don't need any trial. Someone can write a crime generator and enumerate all possible crimes and their punishments. Basically instead of getting hacked in the court, which is a super slow process and sensitive because someones life is at stake, if we have a system which can be hacked any time by anyone, we end up with a better system. Call it open source justice if you will.

Justice is either a logical thing encoded in rules or something complex which perhaps only people can understand. In case it is first, it is logical to make it "people free" i.e. define it in a language computers can understand because they are so much better at this. If not, then let people run the show i.e let's have jury to decide stuff not judges. I just don't understand the rationale of the current system which seems to prevent the very thing it is supposed to provide..i.e justice.

By going to streets people might get some justice now, but what these exceptions tell us is that something is fundamentally wrong with the system itself. A short term focus will bring justice but it would be nothing more than revenge. But if we could fix the system itself, it can prevent injustice in the first place. I would prefer a better system than ever watching the replay of this story again.

Sometimes the middle path doesn't leads anywhere, you got to choose.

Tuesday, December 18, 2012

Cost of Vote

2011-2012 budget for India = Rs 14,90,925 crores
Total number of voters (as per 2009 elections) = 71.4 crores

Per voter this year budget = Rs 20,881
Since we vote every five years, the cost of vote comes out to be around
Rs 1,04,406.

Strangely, poverty line in India is defined at Rs 28 per day, which gives Rs 51,100 as total expenditure for a poor person for five years. If poor people could sell their vote at market price, they would be twice as richer ;) 

Making pizza at home

First, accept it is difficult. That will make your life easy when things go wrong.
Second, read this http://www.varasanos.com/PizzaRecipe.htm. Multiple times.

Lets start with some motivation.

Day 0: Sarson Ka Saag over Maize Pizza

Day 1: Simple toppings

Day 2: Egg Cheese and other stuff



Problem number one is the yeast activation. I had never dealt with it and without thermometer it was hard to find if the water is hot enough or not. Well they say the temperature should be 115 degrees Fahrenheit.  Our body temperature is about 99 degrees. If it feels warm, it is close enough. Put yeast in water along with some sugar and/or some flour. Leave it for about 10-15 minutes. If you see some bubble in the liquid, you are all set.

Problem number two is making the dough. Actually you don't need to make the dough. It is more like the mixture for making "pakodaas" just a little less wet. I don't think even the dough matters much because my latest pizza was maida(60%)+maize flour(40%), with "sarson ka saag" topping. Anyways, have some maida (at least 50%) because it sticks together and gives "enclosure" for yeast to work. Maize flour hardly sticks together and I wasn't really hoping things to turn out well.  It makes me think, may be maida is probably not a good choice for home made pizza. Regular wheat flour and even may be with a bit of dalia or sooji would probably give better results. Anyway, first add the yeast mixture and keep rotating it with a spoon or spatula. Add water if you find it difficult to mix and rotate, but don't make it a liquid paste. What we are looking for is something in-between. It should be possible to rotate spatula, but with effort. This shouldn't take more that 4-5 minutes. Leave it for may be 30 minutes. If it rises, that is good, if it doesn't, doesn't matters. Cut the dough if you want to call it, it will actually be some sticky stuff. You should be able to almost pour it from one bowl to another, except it will take couple of minutes at the speed it pours. It shouldn't have shape of its own as chappati dough has, it will easily spread. I kept these pieces in cling-film. Put them in refrigerator for may be 24 hours or more and then they would be ready to use.

As I described in details in the previous paragraph, the dough is very hard to handle because it is so soft. We don't need any rolling pin. Put lots of flour on the baking tray and then transfer this mass from the cling-film to the tray. Change sides to make sure it is completely covered with flour, so that it doesn't sticks your hands. Now is the time to spread it. Don't try too hard, you will tear it. What you are looking for is may be at max 3-4 mm thick layer, uneven of-course.

While we are doing all this, make sure microwave(oven) is using convection at 250 degree Celsius. That is 482 degree Fahrenheit.   My microwave doesn't go beyond 250, if yours does, please set it at maximum. At this point, all we need to do it put the pizza into the microwave and relax for 7-8 minutes.    At this point take the pizza out and switch sides and cook for another 5 minutes. The optional step here is to lightly spray olive oil/butter on both sides of the pizza. This will keep the crust soft. What you have at this point is a nice cooked pizza base. Get it out, put the toppings and cheese and put it back. No side change this time. The quicker you put the toppings, the best it is for pizza. Cook it for another 6-8 minutes and you will hopefully have a nice pizza. This extra cooking also helps in getting a nice crust below which makes it easy to hold pizza slices.

UPDATE:  May be you should ignore the cooking time information I gave. It will vary with quantity of dough. Instead, one can decide the side changing time depending upon when the pizza starts to rise. Once it starts rising, give it may be couple of minutes to cook and then change side. The important thing here is if the lower side has become crisp or not. If it is too crisp, just add the toppings right away but if not, you could cook it for another few minutes after changing side.


Thursday, December 13, 2012

On FDI in retail

It can't be good for the farmers.
As long as farmers don't have the ability to say no to a bad deal, they will never make more money. Two things are required for that to happen: 1) They have enough to eat and 2) They have place to securely store food until they find a good buyer. Since FDI doesn't ensures either of these, all we are talking about is who will make money from the farmers, not if farmers will make money or not.

It might be good for the consumers in the short run.
Any new retailer needs to find customers and one of the ways is to price below its competitors. But it is not the only way. So in the short run, we can expect prices of some of the things to come down.

What about the %age?
All I said above was with reference to 100% FDI in retail. When the percentage is below 100%, the real beneficiaries would be be companies with which the foreign companies need to create joint ventures. These are the current organised retail ventures from India. If it is 49%, Indian companies get to control the joint venture, if it is 51% foreign companies get control. The percentage ensures that whatever "good" is going to happen with FDI, almost 50% of that goes to owners of the Indian retail ventures.

So, forget about farmers or small shopkeepers or consumers, the deal with FDI is to ensure current owners of Indian retail companies make money, who will otherwise collapse if foreign companies were to directly compete with them.  And who pays for that -- us and who decides for that - "our" government.

If government is so keep on interests of farmers,  they should probably open up FDI in farming and not in retail. Same rules, 49% of the companies owned by farmers who do the farming and 51% control for foreign companies which can create storage facilities or in general figure our how to make money with the farmers and not from the farmers.

Saturday, December 01, 2012

India Against Corruption

If we were to assume that corruption is caused by corruption, one time end of corruption ensures no further corruption. I guess many people justify their own corruption because they have to deal with other corrupt people. Lets call this assumption number 1. Actually this is less of assumption and more of rational behavior any economist would stand by.

Lets further assume that there was a point in time in human history when corruption didn't exist and we will call it assumption number 2 and similarly not of assumption number 2 is assumption number 3, which to put it in words say that their was no point in human history when corruption didn't exist.

If we assume 1 and 3, it is pointless to fight against corruption. History is against us and logic says it will continue to exist because it exists now.

If we assume 1 and 2, then we have a contradiction. If 1 was to be true and 2 is true, then corruption shouldn't exists today because at some point it didn't exist.  But as we know, it does exist and hence 2 is wrong.

We can postulate here that their is something about non-corrupt societies that causes corruption. Specifically,  not just corruption begets corruption (assumption 1), non-corruption begets corruption too. And if that were to be true, fighting against corruption is futile because that in itself lays the foundation of corruption.


Wednesday, November 21, 2012

hi4hi Muffler Privacy


100% Privacy!

hi4hi muffler doesn't uses the internet connection and hence it neither collects nor transmits any information outside of your device. The only information that goes out of your device is the SMS to the caller telling when your phone will come out of silent mode and that is a feature.


I will talk a bit about the permissions that hi4hi muffler uses and why.

The following permission are used to detect the caller and send sms. Sending sms can be disabled from the settings, in which case the app will ignore missed calls.

SEND_SMS & READ_PHONE_STATE
These are needed to know the number of the caller and send SMS when your phone is on silent mode.

The permissions below are all used for generating notifications. Notifications can be disabled from the settings. 

RECEIVE_SMS
This is to check if received SMS is from hi4hi muffler. It can be avoided but the alternative will cost battery life.

READ_CONTACTS
This is required to show the name of the contact instead of the number.

READ_SMS & WRITE_SMS
These are needed to delete the auto-sms from the hi4hi muffler app to keep your messaging history non polluted.

Enjoy!

hi4hi Muffler v2.0

This one was quick ;)
Added ability to read auto-sms sent by other muffler users. These messages are read and converted into notifications which show up exactly when the earlier called user switches OFF the silent mode. Moreover these notification are clickable and on click will dial the earlier called user.

Receiver

  1. Launch Muffler. 
  2. Choose timeout.
  3. Done
If Caller calls Receiver when Receiver is on silent mode, he gets a sms with the time at which Receiver will come out of silent mode.
  
Caller
  1. Calls Receiver
  2. If Receiver is on silent mode, he gets a text message with time at which Receiver will come out of silent mode.
  3. At this point Caller doesn't even need to look at this sms. Muffler will read the message and create a notification which will show up exactly when Receiver comes out of silent mode. 
  4. Caller looks at the notification and clicks it to call the Receiver.
  5. Done

Monday, November 19, 2012

Muffler from hi4hi

My first Android App.  I often forget to change back to normal mode once I switch on the silent mode, usually during movies or meetings. This app allows me to choose a timeout of 10 minutes, 30 minutes and 1-2-3 hours after which the silent mode will be automatically disabled. It also sends an SMS to the missed callers with time at which my phone will come out of silent mode. This way they know when would be good time to call me back. It is possible to disable sending sms completely or to just sent it for people in your address book.



Install Muffler from android app store if you too forget switching back to normal mode. You can also search android app store for "hi4hi muffler".

Update  Added ability to create notification based on muffler smses. Basically if you call someone whose phone is on silent, the app will read the auto sms and create a notification which will show up exactly at the time that persons phone comes out of silent mode. Instead of you waiting, the app waits on your behalf and lets you know that now is the time. Moreover, the notification can be clicked to directly dial without going back to address book or call records.

Privacy  explained.


Monday, November 05, 2012

Stopping begging mafia

Begging mafia operate by kidnapping children and forcing them to beg. They give food to these children and take away the earnings. The ethical dilemma is that if you give money - you are supporting the business and if you don't children are going to starve.

One way to get out of this would be the use of food-coupons which expire. The begging mafia works because money intended for food or education can be used for anything. If we give food coupons to beggars they can buy food and only food with those coupons. If these coupons don't expire, they will become some sort of currency which can then be exchanged for money. By making them expire we insure that they are used for the purpose they are intended for. The expiry could be as small as today and as large as may be a week. We don't even need to print these coupons. It can be easily managed by a mobile app that gives you a number which you can write on a piece of paper and give to anyone you want. The person can give it to anyone who accepts this coupon, who can check if it is valid using his mobile, may be by calling or by sending sms. May be you can get these number before hand so that you can write them down/take a printout and just "activate" them when you give it to someone.

Saturday, October 13, 2012

Reliance GSM data plans


  • The default plan charges Rs 10 per MB upto 50MB and Rs 1 per MB after the 50MB limit. 
  • The other plan is Rs 99 for 2.5GB per month. 

Basically reliance sells bandwidth at following rates:

  • Rs  10.00  per MB 
  • Rs    1.00  per MB 
  • Rs    0.04  per MB 
The default plan costs 250 times the cheapest plan. That is best use of behavioral economics I have ever seen. 

Saturday, October 06, 2012

People Futures

I don't know if the title does justice to what I am about to say. The other two I considered were "Investing in people" and "Partial Slavery".  "FDI in people" was another contender. I am not going to talk about future of people in the sense we usually do, but instead the "future" here refers to ones used in financial markets.

Labor doesn't have a future. Again I mean in the financial sense of the term to avoid any Marxist connotation. The question is what if it did? Let's say any person could sell upto "49%" stake in himself subject to investment. Just to simplify implementation, lets say income tax of the person will be used by government to pay dividends to the "share holders" and in case of death of the person, they automatically get assets of the person (bank balance, property, etc) in proportion to their shares. Further assume that these shares are traded on a stock market so that other people/corporations can trade them.

Now that we have defined the model, lets try to see if it helps us in any ways.

Obviously anyone who made investment in Amitabh Bachchan or Sachin Tendulkar or Shah Rukh Khan would be making tons of money. In theory at least some investments could be handsome.

Consider education. Let's say the retirement fund of a teacher is exclusively or at least heavily influenced by the future income tax of the students he teaches. May be even his salary. Does this gives a teacher an incentive to educate the children to best of his abilities?

Consider education again. Does an industry benefits by investing in students which will be part of its labor force tomorrow? May be industry doesn't realizes this, someone else with money does.

Consider sports other than cricket in India. If their is any possibility of someone winning a medal in Olympics and possibly signing up for brand endorsements, would someone invest in players of these games?

I don't know what would this all really mean. But I do know that people are the future of any possible future we have. May be if that future is invest-able,  some people might invest in it. If nothing else, it gives us some measure of "human capital" vs "other capital" so that at least we are clear on what we as a generation believe is the "future".  May be this brings some reality (funny that speculation is what I propose as real?)  to the over simplified model of people as commodity.

Thursday, October 04, 2012

Simple solution for unemployment

There is lot of literature on the subject with many ifs and buts.  Most of it points to stimulus to revive the economy. Because I am not an economist, I don't have much say on their effectiveness.

But I do have a very simple solution to the problem.  Declare Friday as a holiday

How does this works? We first need to understand the reasons for unemployment.
  • Companies decide to reduce production and hence need less labor.
  • Companies don't need more people. So the students coming out of college don't get any jobs.
  • New methods of productions increase efficiency and require less people. 
Now lets assume government  declares Friday as a  holiday.

Good things that can happen:
  • Companies only have 4 days to produce whatever they were producing in five days. 
  • They need to employ more people (about 20%) to meet their weekly targets. 
  • They might need to invest more in infrastructure to ensure that they can have working space/ machines etc for 20% more people.
  • They might even decide to pay less per person from existing salaries, but they do need to invest in infrastructure and hire more people. Less paying jobs is infinitely more better than no job.
Bad things that can happen:
  • They might ask people to work more hours per day. But labor regulations and bonus for extra work might not have linear cost structure. 
  • They might reduce production further and increase prices. 
I can't completely predict what will happen, but if unemployment is caused by "excess labor", then this could be simple and cost effective way for governments to artificially reduce "excess labor" from the market. BTW instead of Friday, Monday will work too. Or if possible to enforce, 20% less working hours per week per person would also yield the same result. Actually government doesn't even needs to implement it, just declare it. Assuming 40 working hours per person, government can just announce that every 2.5% increase in unemployment will result in 1 hour less working hours per week. I am sure companies will optimize everything to find out what gives them optimal results. Who knows within a decade or two we will all work couple of hours a week ;)


Wednesday, October 03, 2012

Opportunity for github

Sell maintenance for open source projects. It could be a yearly payment or per problem based.

  • They know the people who contribute
  • They also know which areas they contribute 
  • They can easily know who downloads
  • Pay developers for fixing the bugs or adding features.

Products

What is the total cost of a car?

  • Price tag on car 
  • Fuel efficiency (subject to driving conditions) * Cost of fuel * Total distance  
  • Maintenance Intervals * Average Maintenance Cost 
  • Insurance Costs  
  • If on debt, payable interest. 
What you finally pay for owning a car is much more than the price tag. I don't know of a single portal for cars which compares this total cost. I don't even know if this data is public. 

Product Equivalence 
Cars do compete with cars, but then they do complete with motor cycles and buses and autos. So competition for car could be a good combination of motor cycle (short distance), bus (little longer) and train (much longer).  

Conditional Products 
Car insurance is needed only if you have a car and so is car maintenance. Given that most car manufacturers in India only provide maintenance  through their own car dealers, the market is monopolistic. Most spare parts are produced only by the car manufacturers and retailed only through car dealers. The point essentially was conditional products skew the free market. Samsung refrigerators need water purifier that can only be purchased from Samsung. This is where I feel we need some law that forces manufacturers to make sure that the price of all parts put together in the car is not more than the car itself. Or at least this information is public so that we can calculate the expected maintenance cost. May be I should add repairability section also.

Returnability or Repeatability
The margin on small diamonds are over 50%. So you can buy it for $1000, but when you go back to sell it, it will only fetch $500. The value of car drops by 10% as you sign the check.  We only look at "a" sale in free market, but not the second sale of the same product or third. Basically what happens to product price over lifetime, given nothing major happens in the economy. No one seems to talk about this in economics. The question really is about extent of damage that can be caused by asymmetric information in free markets. If manufacturer is forced to define "Product Lifetime" then in a free market, manufacturers should be ready to take the product back given the percentage of "Product Lifetime" used by you.  

Rentability 
Technically a house is worth some function of rent it can fetch at max to be a reasonable investment. A taxi is worth it if "total cost" + labor (driver salary) < total profit. May be some taxi service can use cars parked in office all day and give people rent.  But that apart, many things are not rentable at all. Obviously this is not applicable to food. But if something is rentable, it gives some idea of its time value, which can then be used to calculate its total value, given the life time of the product. 

Product Lifetime
Mobile phones typically last 2-3 years unless stolen. TV and refrigerators can work for 10+ years unless new technologies make them obsolete. Software has much shorter lifetime. Laptops again hardly go beyond 3. Vegetables at edible probably for a week or so, even though the production cycle takes months. Cereals last longer. Movies have few weeks at max to get even. Cars run for 5+ years easily. The reason I am talking about product lifetimes is because they are useful when talking about rentability (above). They give a better idea of the utility of the product because you can divide this number by days or months or years and see if that is good enough for your budget. This also comes into picture if you need to resale it.  

Tuesday, October 02, 2012

Demand Supply Curve

We have two ways of looking at how prices impact demand. In case of price increase for a product,

  • People consume less of the product.
  • Number of people consuming that product goes down.
When rental prices go up, people just can't rent room for less hours. They become homeless. You can't buy half an apple from the market. Or have half the education, by attending few classes. You can't buy half a car or smaller seat in a bus for less price. 

I guess their is a big problem as well as a big opportunity here. How can we make most price changes impact only people consuming less instead of some people not consuming stuff at all. If nothing else, half an education is so much better than no education at all. 

Most measures of economy use money to represent growth. But may be if we start looking at units of things, the units that can be purchased and not abstract infinitely divided units, we will start making a better sense of how economy is doing. Are these units getting cheaper or costly because people can only buy them in units. 

The demand supply curve hides this important information from us. May be we should split it up.  Or may be other way is to make everything purchasable by making it infinitely dividable. That brings up whole new circus that I will explore in another post.

One way to do that is by sharing. We share the same roads, bridges, power plants, dams, hotel rooms, restaurants. Renting is also a form of sharing. May be people can share jobs. Instead of firing people, you make them work less and pay less. 15% less hours per day = 15% less pay = 100% employment which is better than 15% unemployment. People who work in shifts can share the same house - you sleep when I work and then I work when you sleep. May be schools for poor children where they can work half of the time to pay for their own education. 

Monday, October 01, 2012

Meaningful Currency

What does $1 means? And what is 1 rupee?  Currency in inherently meaningless unless compared with either other currencies or goods they can buy. What if we use a measure of currency which is inherently meaningful. Here are few examples:

What if prices of food products were written in "cost of meal for a poor child"? So the cost of one zinger burger at KFC would be around 15 "meals for a poor child".

What if price of car was written in "cost of safe drinking water per person". May be we have car that costs safe drinking water for 10K humans.

May be we could do the same for stock markets. Or put it in balance sheets for a company.

May be we could tell people their salary in cost of primary education for a child.

May be that will make us more human. May be it would be nice to live in less abstract world.

Sunday, September 30, 2012

On poverty and hunger

The biggest confusion around poverty and hunger is they are treated as social problems. No one had bad breadth until someone invented mouthwash. No one was poor, before money was invented. If we think about them from economic perspective, they are easily solvable problems. I don't think we today don't have means to feed everyone on the planet. The problem is it is not profitable to do so. And why is it not profitable? Labor is cheap. Hence doesn't have money to buy stuff. It is a vicious cycle.

The perfect competition if it ever existed in capitalistic society, it existed in labor markets. Everyone who owns any means of productions, knows that it is not always  profitable to produce more to make more money. You need to produce only as much as is necessary to maximize profits. The problem with labor is, that too much of labor is essentially too cheap. The only way to survive is to work more, save more if possible and charge as less as possible. 

So the solution is very simple. All that labor needs to do is reduce its supply, to get better wages. Now the question is how does labor reduces its supply. Lets just take automobile industry as an example. Let all workers of automobile industry create a new company, lets call it India Automobiles Worker Association. This company provides labor to all automobile companies. Now if this company feels that prices of things have gone up but their "salaries" or whatever terms of contract they had with the automobile companies are not working out, instead of stopping work or protesting, they can simply stop sending 10% or some number of workers less to one or more factories, effectively creating "shortage of labor".  The assumption is that the money from 90% of the workers is enough to feed the whole 100% in the short term. Technically this should cause increase in wages for workers and then the rest can start working. Just like companies stop production to stop prices from falling, all we need is some workers stop work to stop wages from falling. It is a perfectly capitalistic mindset at play. 

All we need is corporations of labor, which can manage their own supply to get best price for themselves. Sometimes our own good is based on good of others. If traders can have unions, industries can have unions, why can't labor have unions. Why should labor union be restricted to a factory. If labor is treated as a commodity, then why can't labor organize into bigger and bigger units and manage their own supply to compete with rest of the economy. Why should labor be employed? Why can't you buy labor from a company in number of hours of work you need and it should be totally up to that company to send whichever person they think would fit the bill. 

According to me, assuming interdependence, labor corporations owned by labor which divides its income among all the owners irrespective of if they are employed or not and manages its own supply to maximize income for all its owners are the best solutions to decreasing poverty and hunger in the world.   These labor corporations can merge to make bigger corporations or divide if it is not possible to align interest of everybody, just like regular corporations. They can sign deals with food suppliers or schools and ensure food and education for themselves by operating as one, instead of fighting among themselves. Just like greed of individual can be good for all (capitalism), greed of all can be good for each one of them (communism).  But all doesn't need to be all, just the economic group for which it really makes sense. I call it capitalistic communism.

Less jobs is actually a nice thing. It only means our engineering is advance enough that we don't need everyone to work. Which means people can work less and have more time for themselves. The problem is how we interpret and deal with it. Free people can be asset as well as a burden, depending upon how we look at them. Free people can educate themselves, work on socially significant problem, not addressed by the free market. But our economy punishes people without jobs. US unemployment rate is 15%. If everyone works 15% less and takes home 15% less pay, we can easily support 100% employment. We get the same result using labor corporation, giving 15% people life and opportunity to do something for the community. And by making it 20% voluntarily, you can get wages to increase and come to a point where community as a whole makes more money with 20% less people working or everyone working 20% less.  The idea of creating jobs is not sustainable. Less jobs is not something wrong with people, it is actually the measure of our technological advancement. If the businesses don't need more people, it is just a fact of life. When trades happen with millisecond frequency, when companies exist or die based on quarterly review, who cares about what happens in next 10, 20, 50 or 100 years. Businesses solve people problems. But people are produced by people who live. Educated people are produced by people who live and make enough money to send their children to school. Healthy people are produced by people who make enough to feed and have shelter and access to hospitals. It is hard to think 100 years down the line. You need to listen to you parents and their parents and read lots of history and books and think about future, not just yours, but future of your children and their children. Our notion of economy doesn't captures people and life and we will have to pay for it with people and life.

BTW we have another solution if we do away with the concept of human dignity (which is anyway gone, just don't realize it) to legalize slavery. Slave is an asset and the owner ensures that he/she is alive for being of any use to him. It won't solve the poverty problem because technically slave has zero money, but it does solve the hunger problem by being of value to at least one person in the economy.


Saturday, September 29, 2012

The imperfection of perfect competition

The conditions for perfect competition seem impossible to achieve. 
  • Many firms 
    • This is in conflict with economy of scale. If their are too many firms, the economy of scale will never happen. In fact the best economy of scale happens when we have a monopoly.  What that means is that the prices are not lowest possible.
  • Little barrier to entry 
    • Many industries have big barriers to entry. Be it money, time, patents. Only handful of industries participate in natural resource extraction, because barrier to entry is very high. Phrama requires years of research. Telecommunications need huge investments in infrastructure. It is sort of illogical to try to get into a business which is not defensible.  
  • Homogeneous products
    • Marketing and advertising have only one function, create differentiation.  
  • Complete Information 
    • This is in conflict with "many firms". It is not possible to have complete information about infinite firms. This is also in conflict with division of labor. If everyone needs to know everything about what he needs from another, he might as well build it himself. 
Perfect competition looks like a myth which only exists in theoretical models, except may be for unskilled labor. There are many. No barrier to entry, by default everyone is an unskilled laborer. They have nothing to differentiate by definition and because the only information required is do they have functioning limbs, it is easy to see by inspection.

Wednesday, September 26, 2012

Economic Equilibrium Without Perfect Competition

I propose here a very simple solution to the problem of achieving and keeping economy in equilibrium. It can easily be called capitalistic communism. It doesn't requires ANY changes to way democratic capitalism currently works. It works within the constraints of the capitalism. No state ownership of capital assets is necessary. No redistribution of capital assets is required. The crux of the proposition is that not just greed of one person is good for all (capitalistic principle), sometimes greed of set of people is good for each one in that set (communism). To deal with impossibility of defining what is preferred by all based on individual preferences, I propose partition of the set based on these preferences. These partitions are dynamic in the sense that individuals might shift from one set to another as their preferences change. The prices are decided by the relative economic power of these sets of individuals and their interdependence on each other for their own welfare.

Consumer Corporation
The goal of a consumer corporation is demand aggregation and taking collective decisions on behalf of its members. Because of its size, it can negotiate better prices (Groupon) or create new alternatives for handling that demand (Kickstarter). It could be based on location (where) or time (when) or products (what) or kind of consumers (who) or any combination of them.  The consumer corporation causes discrete fluctuations in demand, making prices stick for a longer time. A small increase in price might cause large swing in demand, making the company unable to survive. Home loans can be negotiated. School bus can be arranged without asking schools to have one. May be not everyone needs to have a washing machine. The economy of scale can happen at demand side of the equation too and not just at the supply side. Examples could be people living in an apartment or whose children study in same school or owners of mobile phones or customers of Airtel. The only real power of consumer corporation is that it can cause significant change in demand that can be used to keep prices stable.

Labor Corporation
The goal of labor corporation is skill aggregation and taking collective decisions on behalf of its members. It is different from employee union because union is restricted to a company. Labor corporation can span multiple companies, multiple skill sets, multiple regions, etc or may be a small subset of labor in a company. Basically any organisation of labor that increases its collective bargain power. This make labor as a product or service which can only be purchased from Labor Corporations. Labor corporation can for example decide to reduce the supply of labor to the market if it can bump up the wages to a point that increase in wages makes up or increases the total income of the labor corporation. It also acts as an insurance agent against unemployment. We don't need any specific labor laws because labor corporation can handle that as part of price of its product, the labor and kind of contract it signs with the company. The same kind of competition that exists between normal corporations can exist in labor corporations. Such corporations can arrange education/training to convert "one kind of labor" to "another kind of labor" if that is what will maximize the total income of the labor corporation. It can even help fund education of children which will ultimately join these corporations. Their main purpose is to fiddle with "labor supply" to keep wages relevant. Because all that the employer gets is labor, it can be effectively shared. Everyone works but may be only once a week and half a day or at multiple companies. Companies don't own the person, just labor time and that time can come from multiple persons. The core job of labor corporation is keeping labor prices relevant by controlling the supply of labor to maximize returns for corporation as a whole.

What we get because of this arrangement is three kind of organizations. Capital, Consumer and Labor. All of them depend of each other to make the economy work. Without Labor consumers don't gets the product they want and Capital is wasted. Without capital, labor don't get jobs and consumers don't get any products. Without consumers capital is wasted and labor don't get jobs.  You could even call it economic cold war. Note that the core assumption here is interdependence. Any set that achieves interdependence from the rest is essentially not part of the economy anymore as it can survive on it own.

What we get because of this is balance or equilibrium in the economy in spite of perfect competition, because each set needs the other two to achieve survival. Even monopoly can be made to work if consumer and labor also make a monopoly. They make is easy to study economy because instead of 7 billion participants, we can may be talk about 7 million or 7 thousand or may be even 7 consumer or labor corporations with different labor power or buying requirements. They can be broken up if they are not in the interest of its occupants, creating more diversity or combined to fetch more benefits. Labor and consumer corporation can be a single entity with same members. In this special case, they operate with the same premise that other corporations exist, namely profit.

Somehow both these "concepts" are handled by government. All consumers and all labor somehow depends on government to interfere to make life work for them. Sadly governments are too busy preparing for the next elections. This dependence on government is artificial, not required. People can organize as labor and/or as consumers and work/consume at their own terms without government intervention. Political systems organizes people according to political buckets (religion, region, ideology, gender, age) to create power delegated to government. The same can be done via economic buckets to create buckets of economic and labor power and solve the economic problems or at least giving them a fair chance. May be Adam Smith was actually right. We don't need governments and its intervention. Just like capitalism creates pockets of capital power, we just need similar organization of labor and consumers to keep the economy in balance.

It is very simple to create, given the communication systems that connect people instantly across the globe. We don't need to change government or create new policies or anything else. Capitalism itself provides the solution to the economic problems we face today. All we need is greedy employees and greedy consumers, using the inverse principal - good for "my corporation" is good for me, reducing competition among themselves to counter the increasing power of producers. And that probably is the best way for "communism" to exist side by side with "capitalism" without needing any violence or revolution.

May be we have been evaluating the best of the two approaches for a long time. The answer probably is both. 

Monday, September 24, 2012

Capitalism - The missing piece

Capitalism always reminds me of Darwin's theory of natural selection. Companies that don't make profit, die. Nothing emotional about it, that is supposed to be good for the economy and people. What about labor, specifically unemployed labor? If we assume the capitalism's answer is "they die",  capitalism starts to make complete sense. Death of poor unemployed labor lowers the labor supply, results in better wages for those alive.  That could be the capitalistic way of creating equilibrium. In countries without any welfare policies, with no access to land to cultivate or forests to hunt, the only choice capitalism leaves for unemployed labor is death and for a good reason. It creates equilibrium and better wages.

I understand the horror of what I said above, but if you accept it for a moment, you will see the beauty of capitalistic equilibrium equation. Nothing else is required. It will be a well functioning system, killing or producing people in relation to demand is all that it asks for, to be in perpetual balance. The more people are rendered useless because they contribute negatively to the equation of maximization of profit, more people need to die to maintain the economic balance. I guess that is what Atlas Shrugged was all about. Using the term "division of labor"  somehow presumes that their exists labor opportunity for everyone. Unemployment is logically absurd if capitalism is about division of labor.

The problem then is not that government is doing less, the problem is government is meddling around too much in this laissez faire economy. Left to its own design, it would solve the unemployment, poverty and other stupid social problems faced by society.  The invisible hand does seem to believe in removal of poor as a way of removal of poverty. Except for the issues of the morality of killing people and the biological problem of 16-21 years of waiting period before those born can be made into labor, the capitalism indeed works as described.

Of course this is not at all true. It is just a commentary on a mental walk on the roads of capitalism with "poor die" goggles. The good part is, it makes sense. The bad part is it is horrible. The reality on the other hand doesn't makes sense and is horrible too.

 Here is an alternative way of achieving Economic Equilibrium which doesn't requires killing poor.       

Tuesday, September 18, 2012

Louis Kelso - The Binary Economics

In one of my over the whiskey discussions, we explored the idea of consumers investing in the stock of the companies from whom they buy products.  The basic idea was that if company is making profit from me, it will probably reflect in the stock price of the company some day. Google search for any precedence lead me to Louis Kelso and his theory of binary economics. He was the inventor of the ESOP.

I don't think I buy the whole argument, but the intentions feel solid. The core premise is that any increase in production should happen with equivalent increase in purchasing power for the economy to function properly. This I think is a gem of a observation.

Consider an economy in perfect equilibrium. Lets say someone invents a new thing and everyone wants it. This would require people to buy less of the other stuff so that they can buy this new thing. Which means less prices for everything else to save money for the new product. The introduction of new thing causes prices of rest of things to be recalculated so that economy is in balance again. What is required here is that either magically everyone has enough money to buy the new thing or price of everything else is "adjusted" so that everyone has enough money for the new thing. That is not what usually happens. Multiple things can happen at this point. Some people might reduce the use of other things to save for the new thing. Some might use their savings. Some take debt. Some don't care. Unlikely, but some may increase prices to get more margins. And some may invent new ways to reduce costs to get more margins. If most people reduce the use of things, demand goes down, some other people make less money. That would be a start of slowdown. If most people use their savings, the cost of money goes up, interest rates are increased. This might cause defaults, as wages were untouched. This might make some businesses suffer, whose margins are less than the interest rates. What we really need here is a perfect kind of transformation. Some people save, some use the savings, some take debt and somehow everything cancels out, without impacting money supply or margins for existing businesses. The point is economy doesn't seems to tend towards equilibrium, when moved away from it.

If some of the people make most of the money then most of the people will not have much money. Compound it with money makes money, you end up with lots and lots of poor than you started with. The end result would be decrease in market size. Some of the people just can't afford some of the things anymore.  This can be offset by technological advancements to decrease the cost of production but only up to a point. All businesses need consumers, but if businesses are run for maximization of profit alone, they may end up destroying the very thing namely consumer which is the main source of profit. One way to make things affordable in short term is debt, but sooner or later the things will collapse if consumer cannot even pay the debt. Seems like this is true even for countries. Historically, the only way to deal with such situation (inability to pay debt) was handled using slavery.  So maybe that is really the end goal of obsession with money.

The funny thing is I heard one gentleman saying he is looking forward to depression because he knows how he can make money from it.  That I think is very sad state of affairs. If the only way to deal with correction of the economy is depression, then something is fundamentally wrong about the system. We use vote to decide who will run the country. We might as well start killing each other to show who is more powerful. That would be absurd, except that is how I think we deal with financial systems.

One of the ways to deal with this could be use of communication on the demand side of things. What Groupon did was something which was not possible for long time. Unknown buyers joining to bargain product prices. Kickstarter is doing the same, except for funding new products. What should I call it - consumer union?  Just like labor unions used to stop work and cause financial loss to company, may be consumer unions can stop purchasing the products of the company to bring it to halt. That is what Gandhi did to British clothes. This was not possible earlier because consumers never knew each other because of physical distances. It was not possible to discuss, but given the communication systems of today, this is very likely.

If the consumers own the company stock, we still have a fair arrangement, except it is much cleaner.  The margins flow back to the consumer automatically.  This could even be used by governments when they give natural resources to companies. The current best practice is auction. What if government could use half of the money from auction to buy the stock of the company to which it is selling the contract for natural resource like coal mine. What it does is that it insulates government from any bad deal it got while selling the resource. If the company got less, its stock price will not rise much. If the company got more, its profits will reflect in its stock prices, giving more value to the government. 

Friday, September 14, 2012

Thoughts on traffic jams

One of my favorite joke of all times is carry bread while driving, you never know when you will find (traffic) jam. We have all crossed intersections. I am talking specifically about the no traffic lights, no traffic police kind. Sometimes they are so smooth that we don't even notice. But sometimes when everyone wants to go first, no one ends up moving. For a long time my take would oscillate between two point of views:
  • People don't have driving sense (They don't know what they are doing) 
  • People are mean (They are doing with intention)
Lately I have been thinking may be something else it as play here. And that something is "lack of information".  What I mean by that is that we only know what is "going on" for a distance of 20-30 meters in light traffic and may be next 3-5 meters in bumper to bumper traffic. That is all we know. That is all the information that we have at our disposal to judge "driving behavior" of other people. This is too less to be correct. 

Here is a simple hypothetical test case. Stand at any intersection and wait for other to stop before you cross the intersection. Ensure that it is always possible for the others to cross without bothering about you. My understanding is that you can wait for hours without getting to cross. And I guess the reason is the other drivers just get few seconds to "see" you waiting. They don't know how long you have been waiting. And if later you try to cross the intersection, I am sure you will still get honks, people trying to squeeze in, so that they can cross first. Hopefully you will cross without being cussed, but nevertheless being judged as not having driving sense and being mean. As social animals, we learn correct behavior by imitating what we see.  But if what we "see" is skewed, we will judge that skewed behavior to be correct. At least that is what I feel what I have been doing for most of my driving life.

If somehow it was possible to communicate and let everyone see the correct facts, may be the way we react and judge would change. One of things that comes to mind is a simple "wait counter" installed above the car which counts the time you have been waiting and displays it for others to see.  Not that this would magically cause deadlocks to go away, but at least everyone will know if what they and others are doing is fair or not.  At least instead of always learning people are mean or people don't have driving sense, we will possibly learn most people are not mean and most people have driving sense or vice-a-verse.

It gives people a fair chance to be fair.

Monday, August 20, 2012

Monday, August 06, 2012

For SUV

Actually it makes sense for high ground clearance vehicles.

Because some speed breakers break more than just speed. 

Wednesday, July 04, 2012

Half life of money


 Every time someone makes a payment of  Rs 100 using credit or debit card, depending upon his bank, the vendor will be charged somewhere between 2% to 4%. As people do transactions the amount of money available in the market decreases because part of that money is kept by the bank. The plot below shows the number of transaction it takes to reduce "public" money from Rs 100 to Rs 50 at different transaction charges or think of it as time it takes bank to make half the public money its own.













At 2% it takes about 35 transactions and at 4% it takes around 16.  At 10% it only takes 6 transactions to reduce it to Rs 50. The cashless economy taxes its users and that tax is payable to the bank. Good thing is at least in India RBI has now reduced this to maximum of 1% but for online transactions only. 


Making money on loans takes time, 10% over one year. But when transactions are taxed, the amount of money made by the banks is not dependent on time, it is just based on how fast the money moves around in the market. Fast moving money is probably a sign of good economy, but because of the tax, the faster it moves, faster it dries up. The half life of money could be few months to few years. I don't know the numbers, but it seems plausible that banks can make much more than 10% a year, if number of such transactions is say greater than 4 for 3% rate.  

Tuesday, July 03, 2012

Communicating discounts

10% off is 9/10 of the price.
20% off is 4/5 of the price.

50% off is 1/2 of the price.
66% off is 1/3 of the price.
75% off is 1/4 of the price.
80% off is 1/5 of the price.
90% off is 1/10 of the price.
95% off is 1/20 of the price.

It makes sense to switch to 1/n mode if offering more than 50% off.

Friday, June 29, 2012

On Simplicity and Complexity

Simplicity is highly abused term. It is now synonymous with good and consequently complexity now stands for bad.  Making such a statement is usually complex. It needs time, understanding of the subject.  But often, it is very easy to judge simplicity and complexity. If you understood it is simple, if you don't it is complex. The relative frame becomes the "person" not the problem/solution space. What takes real thinking is judging if something is "appropriate".  It comes only after you understand the problem and the solution so well that you can judge if the solution is appropriate. 

What makes something simple or complex?

Lets talk physics for a while. Earth is the center of the universe and sun revolves around the earth. That is simple. Every child thinks that unless told by teachers or parents. Problem is, simplicity doesn't helps when you are sailing oceans or launching a satellite. Consider motion. Classical mechanics is simple. It is still heavily used.  Relativity is a bit complex, just add the observer and how he observes to the equation. That is necessary if you are dealing with small particles, moving close to speed of light. There is nothing wrong with classical mechanics, it is simple and appropriate for lot of things. 

Solutions are simple or complex, depending upon the levels of abstraction used in understanding the problems. We won't be able to build any building if we start at atomic level. Recipes at atomic level will be useless. The unified theory of everything is obviously simple in terms of its constructs but becomes very complex to deal with high level problems. So in some sense complexity arises from simplicity - simplicity of abstractions. It can come from complexity of abstractions too, but that is obvious. Take a look at nginx module architecture. It is simple. Call all modules to find  if someone will handle this request and then let it handle it. Problem is writing the handler.  Nginix modules need to do everything themselves and cannot uses code from other modules because the architecture encourages isolation. So we have chunked encoding implemented in basic http module, file upload module, the upstream module, etc. I guess the same needs to be done for compression, caching, etc. Simple architecture, complex modules.

The opposite is also true. Complexity also leads to simplicity. Understanding complexity needs lots of thinking. Finding out how things are working, why are things the way they are. What are the assumptions. This knowledge is at the heart of seeing simple way of doing the same things. Good needs bad to differentiate. Simplicity doesn't occurs in isolation. It needs complexity as a yard stick.

When Einstein said "Everything should be made as simple as possible", he also added, "but not simpler".  The question is not simple solution vs complex solution, but appropriate level of simplicity or appropriate level of complexity or put appropriately - finding the appropriate solution. 

Wednesday, June 27, 2012

Of Money and Banks

Looking back, I seem to have too much to say about these topics.
In chronological order..

This one talks about how money is an abstraction for human interdependence and how it has properties that are different from properties of human interdependence. 
http://chakpak.blogspot.in/2010/03/reinventing-money.html

It is a mixed bag about unethical banking practices like loan switching charges and floating rate of interest (as if fixed one was better) and how we should move away from loans and only allow investments.
http://chakpak.blogspot.in/2010/08/home-loan-switching-charges-floating.html

http://chakpak.blogspot.in/2010/08/interest.html

Read this one. What if money expired ? Is choice enough in capitalism?
http://chakpak.blogspot.in/2010/09/if-money-expired-people-had-choice.html

Banks should be open to failures for their own good.
http://chakpak.blogspot.in/2010/10/banks-can-only-collapse.html

http://chakpak.blogspot.in/2011/04/price-retailer-margin.html

If you are employed, you will love this one. 
http://chakpak.blogspot.in/2012/01/loan-or-subscription.html

More detailed analysis of frequency of choice - the missing piece in capitalism. 

Tuesday, June 19, 2012

Be Original

Cut: Copy-Paste

UPDATE: May be this is not so clear after all. The idea was the use the sentence which is completely opposite of "being original" which is "cut-copy-paste" and use the same words to convey its opposite. If I was to code, this would appear as

Cut (Copy-Paste)

Essentially cut (stop) doing copy-paste if you want to be original.

Wednesday, June 13, 2012

Where is money?

It is not in the banks.
Not in your wallet.
Definitely not in the stock markets.

Take out the piece of paper you call money from your wallet and you will find this written.
"I promise to pay the bearer the sum of X rupees" - Governor RBI.

If money was money, you already have it and then why is Governor of RBI promising you to "pay it"? Well it turns out what it means is that in normal circumstances people will trust these pieces of paper, but even if they don't, I promise I will pay you something of value worth these pieces of paper.

Money is the promise we make to each other and the only species which honors promises is humans. You are money. Your wife, your kids, your parents, your neighbors, people in your office, people on the road, the shopkeepers, the drivers, the plumber ...

EVERYONE is money and NOT EVERYTHING.

Things don't have value, people see value in things. This is simple stuff, one less indirection. The billions of dollars/rupees (pick your currency) is paper in the hands of few individuals or corporations, is nothing if the rest of world doesn't honors their promise to be of value to those who have this paper with them. I have no idea what RBI Governor will give to such a guy whose money no one accepts.

It is people who produce something valuable and it is other people who appreciate that value and pay for it. Money is not what you have in the bank, wallet or in stocks, the value of that piece of paper is in the people around you and their willingness to do something of value for you for that piece of paper. The value of money is in the people. Anything that stops other people from producing value, is decreasing the value of that paper you hold so dear. And many times what is stopping people is that they don't have that paper with them. Richest companies in the world are mostly monopolies (Oil and Gas, Infrastructure, Public Sector). The next richest are banks. Somehow capitalism fails to bring efficiency in banking even with private sector. Everyone of them seems to be making money. Give 5% interest for deposits and charge 15% for giving loans. Stupid regulations.

People seem to trust money more than they trust in people and paradoxically, trust in money is nothing but trust in people.  

Monday, May 14, 2012

Alternative Implementation of Call Center

Most call centers needs sophisticated call management software to distribute calls among the call center workers. Asterix and openpbx are few open source alternatives.  Basically the core design in based on proxy/middleware architecture. I am sure this is expensive.

An alternative way to implement the same functionality would be to use say smartphone based apps. Instead of putting your switching logic on the server, the same can be accomplished via the client. The idea is instead of pushing logic into the IVR or call proxy, use the internet connection and the computing power of the smart phone and your normal webserver (in your favorite langauge) handle the logic aspect of the call and then just make the app call the right number for the job. The approach has multiple benefits.
  • Use phone to store the answers to most stupid questions asked like name of the customer, address of the customer, even phone number of the customer, his choice of language and customer specific ids like account number or customer identification number or may be the receipt number etc. No need to waste time. 
  • Even if the stored information is insufficient, you could let the customer enter it on his mobile device instead of doing it over the IVR.
  • Customer can talk to the same guy he talked to earlier and save time. This helps the customer by skipping the context and generates faster response time.
  • No need to buy a special number. Just expose a web API which tells the phone app which number to call based on the information stored in the phone. Put whatever logic you need to put into that web API like .... if customer has called 5 times and the issue is not yet resolved, automatically route the call to the manager. The numbers could be regular mobile numbers or desk phone numbers of the employees. 
  • Very easy for the customer to give feedback. You have complete power of the webapp at your disposal. 
  • Very easy to implement say a work queue....customer simply presses a button and says call me back. Why wait.
Most "customers" already have smartphones and the ones that don't have are going to have them in next few years. By using the internet connection on phones and their computing power, it is possible to build much better customer management solution at fraction of the cost by offloading the "logic" to the app and webapi and use usual phone number to do the actual talking. Somehow we are still stuck in pushing logic into the phone line. 

Thursday, May 03, 2012

Life doesn't teaches us much

Contrary to popular beliefs, I think that life doesn't teaches us much. If it was true, we would have become very much like each other. We are, but then we are not.

I think after a point life simply reinforces what we already know.  

Sunday, April 15, 2012

Patents - Necessary Evil

The deal with patents is fairly simple. Innovate, file patent, get exclusive rights for some period of time on your invention and make money from your invention. Now the problems.

  • Too many patents being filed
  • Too many generic patents 
  • Patent Troll
  • Defensive patents 
In simple terms the problem is uncertainty. I have developed this cool technology and I have no clue if someone already has a patent on it. File stupid patents, because if you don't someone else will and that is a threat. Oops someone sued me, how much do I need to pay to settle this apart from the lawyer fees. Patents add huge variance to predicting costs/profits in business. 

The fix is simple enough - bring certainty and sanity to the patent ecosystem. 

Time is money

The exclusive rights to use your invention is nothing but a way to make money. And the simplest way to fix this is to base exclusiveness on money and not on time. What this means is that at the time of filing patents, you need to put a monetary value on it which tells the worth of the patent. The cost of filing patent would be based on this monetary value (call it patent tax).  This has two important repercussions.
  • Patent Troll is controlled because a finite value is attached to patent. Irrespective of how patents are "sold" to others for use, total payout cannot exceed the declared value of the patent. 
  • Stupid patents are avoided because you need to attach monetary value which will be taxed. Unless you are sure that patent is worth that value, you probably don't want to waste money on it.
I guess what I am talking about is making patents a market where patents can be purchased/used to  make life  better on planet by figuring out a way to attach monetary value to patents instead of finding it out through expensive court battles. This makes the process efficient and reduces uncertainty and provide value to both the inventor and the user of the technology. The idea as I understood was always to reward the inventor and never to prevent others from using it. Preventing other from using it is just a way to reward the inventor, but not the only way.  If we can find alternative ways for ensuring the same, we can perhaps bring some sanity to the system so that both the inventor and society as a whole can benefit from the invention at reasonable costs, predictably. 

Friday, April 13, 2012

Ford Mantra

I have been driving Ford for eight years now. I like the car, but spare parts are stupidly expensive. I wanted to get the windscreen changed, but thought against it when I was told the price. Rs 9000. Compare that to windscreen cost of Skoda Rapid - Rs 3600. Now that is hell lot of difference.

What does that tells us about Ford Business Model? Sell cheap cars. Make money on spare parts and services. Which again brings me to the old dilemma of choice in capitalism - namely you don't have a choice after you make a choice.

I think some rule like cost of all parts put together in the car cannot be more than the price of car would probably help bringing some sanity to the system. If everyone needs to go through this experience to learn it then Ford surely has a very bright future. I think the statement, "You can fool some of the people some of the time, all people some of the time, some people all the time but not all people all the time" is missing a crucial component. The component is people have finite life times. Then the game starts all over again. If new generations don't listen to the old generation, the cycling of fooling can run indefinitely because people continue to be replaced by new people.  

Fundamentally this is all about frequency of choice.

Sunday, April 08, 2012

Two Favorite Patterns in C

The first one is for error handling.


#define IfTrue(x, level, format, ... )          \
if (!(x)) {                                    \
   LOG(level, format, ##__VA_ARGS__)          \
     goto OnError;                              \
 }


This is the simplest way of simulating try/catch in c. Yeah it uses goto and is a bad programming practice and what not, but it makes c code beautiful and understandable. Take a look at the code below for creating a server connection below. These code samples are from cacheismo.

connection_t  connectionServerCreate(u_int16_t port, char* ipAddress, connectionHandler_t* handler) {
connectionImpl_t* pC = ALLOCATE_1(connectionImpl_t);
IfTrue(pC, ERR, "Error allocating memory");
pC->fd = socket(AF_INET, SOCK_STREAM, 0);
IfTrue(pC->fd > 0, ERR, "Error creating new socket");
{
         int flags = fcntl(pC->fd, F_GETFL, 0);
         IfTrue(fcntl(pC->fd, F_SETFL, flags | O_NONBLOCK) == 0,
    ERR, "Error setting non blocking");
}
memset((char*) &pC->address, 0, sizeof(pC->address));
pC->address.sin_family        = AF_INET;
pC->address.sin_addr.s_addr   = INADDR_ANY;
pC->address.sin_port          = htons(port);
if (ipAddress) {
pC->address.sin_addr.s_addr  = inet_addr(ipAddress);
}
IfTrue(bind(pC->fd, (struct sockaddr *) &pC->address,sizeof(pC->address)) == 0,  ERR, "Error binding");
IfTrue(listen(pC->fd, DEFAULT_BACKLOG) == 0,  ERR, "Error listening");
pC->isServer = 1;
pC->CH = handler;
goto OnSuccess;
OnError:
if (pC) {
connectionClose(pC);
pC = 0;
}
OnSuccess:
return pC;
}

It is a linear code. This avoids multiple exist points and repetitive error handling code. Less nesting of "if" blocks makes it easy to follow the code. Error handling/cleanup happens in the end and is common for all possible errors in the function, which also means less code.

The second pattern I use often is opaque objects.

typedef void* chunkpool_t;


chunkpool_t  chunkpoolCreate(u_int32_t maxSizeInPages);
void         chunkpoolDelete(chunkpool_t chunkpool);
void*        chunkpoolMalloc(chunkpool_t chunkpool, u_int32_t size);
void         chunkpoolFree(chunkpool_t  chunkpool, void* pointer);

Almost every type is opaque. What does it accomplishes? Freedom. Freedom to change the implementation of the objects because rest of the code only uses functions to access the object and doesn't knows how object is actually implemented.  This also forces me to think hard about what should be the minimal interface for accessing this object because it is painful to keep writing new methods.  I use this for almost all objects except objects whose only job is to be containers of data and no functionality.

I do use function pointers when they make sense, but that would be a topic for another post. Writing high performance software is fun, but making sure it is easy to code and easy to change makes the journey pleasant.

Friday, April 06, 2012

The Debt Of Humanity

We are all in debt. I don't mean the financial debt, your home loan and stuff like that. I mean the debt of humanity.  What were our chances of surviving if we were born million years ago. Death during labor, infections, lack of food, shelter. Instead of fighting with each other, we choose to live together and developed a language to talk. Rest is history. We have taken the concept of being together from few families to villages, towns, cities, nations and now we are almost at the edge of time when all of humanity is considered one big family. And the reason is simple - nations also fight and don't know how to live together.
No matter how much we feel for our country, the truth is that vaccines that saved us were invented by someone else, the languages that we speak and which runs multi billion dollar BPO industry is not ours. Bangalore is silicon valley of India but computers and programming languages and the OS we use etc were not invented here.
We are so much deeply connected today than we were yesterday but our ability to see these connections has diminished over time. I am not talking about facebook friends, but those who work at facebook to make it possible. Those who work at google to make search simpler, democratize the mobile OS. I am talking about the people who make our cars and those who make sure you get the petrol/diesel at the station. The ones who run the refineries and the ones who dig oil out of wells and the ones who build the pipelines. The ones who build the roads and those who build the equipment to build the roads. The ones who invest their lifetimes researching life saving drugs, the ones who ensure we have electricity at our homes. The list is endless.
Everyone on the planet is in some ways making life easier for the rest of us. They realize it or not is debatable. We realize it or not is also debatable. But I do feel that we would have never been here without the rest of us. 

The Best

We know what is the best (product/service/decision/policy/whatever). Actually we knew the best all our lives. Sony makes best TV's. Ferrari is the fastest car, iphone is the best phone, land and gold are the best investments, and so on.

At some point in the past, the best TV was theater, their was no fastest car,  but fastest horses, their was no phone. People with more gold were probably robbed and people with more land ended by killing each other to get more land.


Beware of the future. Best is yet to come.

Saturday, March 17, 2012

Frequency of Choice

I have talked about this earlier also, but the topic is so close to my heart that I wanted to have a dedicated post.

As far as I understand it, the crux of capitalism is choice. In economics the word choice is substituted by market. What is market? Market is where consumers exercise choice. If consumers don't have a choice it is not a market. The assumption is capitalism thrives on competition.  Competition creates choice. Consumers will choose the best products at lowest prices forcing companies to innovate and reduce prices. The best will survive.

This is all true and then not quite true. Two main problems:

  • Most people don't like to think. Even  if they can, the complexity of world is sufficiently high that figuring out what is best for them is close to impossible. Eventually it is either brands or price because they make the decision simple. 
  • Frequency of choice. Since this is all I want to talk about, I will use the next paragraph.
We are good at stuff we do often, the old practice makes the man perfect thing. We buy petrol, vegetables, groceries, etc almost every day. Prices changes are felt, drop in quality is noticed. But then their are things that we don't do often. Things like joining new job, getting married, buying car or home, taking a loan, choosing college, getting home painted, buying TV or refrigerator or AC, casting our vote, choosing a laptop or OS, choosing email client, signing up on a social network, etc.  Many of these choices are irreversible or if not irreversible then choosing the alter our choice is very expensive.  This is where capitalism fails miserably because it is no longer about choosing from alternatives but the choice of altering our choice. For products with short life spans like vegetables or toothpaste altering a choice is not expensive. Vegetables will last few days, toothpaste few weeks and you can choose better product next time, but with products that last years or decades or in some cases lifetimes, it is the altering of choice which is required not choice among products. 

Specifics:
 
Consider home loan business in India. Floating rates have been around for long time now.  What do they float on is unknown and once you take the loan you realize that the "unknown" is whim of the Bank. Usually your floating home loan interest rate will increase by 20%-40% within few months of taking the loan and now their is no choice.  Well their is a choice to switch to other home loan, but only if you pay 2%-4% of your home loan value as switching charges.  This is as monopolistic as it gets and we call it capitalism, the mecca of markets and choice.  Even banks don't know if they are giving a good/bad interest rate to the customer, then how can customer decide if he is getting a good deal and that deal is good enough for the next 20 years. No one can. The only way I can know if I getting a good deal is if I can switch my home loan any moment I desire to switch. That is what will make it a market.

The same happens when switching a job (notice period), casting a vote (5 years gap), buying a car (10% value drop when it get out of the showroom) and at many other places. In computers, the advent of SAAS based companies have started filling this gap by providing monthly choice to the customers to continue to use them which once was a difficult choice of finding the best product. Amazon EC2 gives choice to use machines by hour and OS by hour. I think governments which call themselves followers of capitalism have missed a point.  It is not the choice alone that matters, it is the frequency of the choice that is at the core of efficient markets.  

Tuesday, March 06, 2012

Threadpool and the task queue

Every architecture makes way for threadpool and a task queue.  Multiple thread wait on the queue always ready to pick up the next task and execute them. Once implemented, the next task is tuning it. How many threads? What is the size of the queue? Blocking queue or throws error on full? Retry handler?

Before you start worrying about this ask a simple question. How much time does it takes to execute the task? If it is not at least couple of orders of magnitude greater than time it takes to do context switch, don't bother about the threadpool/queue, just execute it right there, on your current thread.

Here is why?
  • Task queue has a lock. More threads and more often it is accessed, more contention, more time to submit the task. Extra context switch just to acquire the lock. Basically you are doing serialization before getting to parallelism here. More threads + more tasks => more time per insert. Think of it like talking to a customer care executive(CCE). You do lots of IO using IVR and finally reach the CCE and the guy instead of answering your questions connects you to another guy and you need to explain the problem once again. That is pretty much how context switch works. If you need to talk for 10-20 minutes, it might be worth it, but if all it takes is few seconds of conversation, it just wastes time.   
  • Once the task is submitted, it need to wakeup some thread. That is context switch, costs time.
  • By the time this new thread wakes up because of lock and time elapsed most of the variable it needs are out of cache...more time. Read lock semantics for JVM. 
  • How do you do error handling from the task? Extra code, extra states.
You can avoid all this by executing the task inline....normal function call. It will run faster.  It is easy to write/debug. The assumption here is that the task really takes short time to execute and it mostly cpu intensive. Webserver using threadpool is understandable. Single request might need to do file IO, access some locked resources, possibly make multiple database queries. These are kind of things that make sense in threadpool...things that are complex enough to be simplified by using  a new/dedicated "thread of execution".  For other things, function call is the most efficient.