March 2009


Money is a fundamental building block of a modern economy, it is a means for people to exchange fractions of their daily efforts and knowledge without having to resort to bartering.
Imagine if a programmer tried to directly exchange 20 minutes of his programming time for five potatoes and a steak – it just wouldn’t work, and the consequence in such an economy would be that professions and activities other than those needed to fulfill our most basic needs would not be possible, we would basically have to go back to being farmers, hunters, builders and gatherers.

Money is what allows me to exchange fractions of my time and knowledge as a software developer for food, shelter, entertainment and many other things without having to barter, it is what enables me to live in a reasonably nice home filled with electronic gadgets, rather than live in a clay hut.
It is safe to say, that the more complex and interdependent our economy is, the more important money as a stable means of exchange becomes. A stable value of money means that we have the information to make informed decisions and trades in our daily lives, money is not only a means of interchange, money flows are also signals giving us information on how to spend our time, what trade-offs are worthwhile.

Stability is where we have a problem today – in the last year the pound, dollar, euro, yen and many other world currencies have gyrated heavily, for instance the pound has dropped some 30% against the dollar and euro.

Imagine an engineer building a bridge requiring a part that is exactly 200 millimeters in length, but due to the fluctuations in the meaning of what a millimeter actually is, the part might be 10% too big or too small. Would the engineer be able to order a drill from a drill manufacturer with any confidence of getting what he needs? The answer is an emphatic “no”.

Now think of what impact the exact same phenomena has on something infinitely more complex such as the international economy – it is quick to see how currency fluctuations and pure currency manipulation by governments and central banks can wreak havoc on our economy.
A 10-20% fluctuation in what the value of a “dollar” means can be the difference between a buoyant economy and economical meltdown with mass unemployment.
Make no mistake about it: this is exactly what we are seeing at the moment – mass manipulation of currencies and the lack of a basis of their value has created massive malinvestment in the last 5-6 years, something we are paying the price for now.

What is a dollar? What does it buy you today? What did it buy you 20 years ago? What will it buy you 20 years from now? I’m guessing to the last question the answer is: “I don’t know, but probably a lot less than now”. That is hardly stable money.
How many dollars are in circulation today? How many dollars will be in circulation in 10 years? Who knows. That is hardly stable money.

Gold is stable money, not because gold is magical, it is subject to supply and demand like any commodity. It is stable because one ounce of gold is absolute, it will always be one ounce of gold, just like one millimeter will always be one millimeter. Gold is also a commodity with an anchor, it’s supply and yearly production is relatively well known and cannot be easily manipulated by governments for the sake of short term gain and political expedience.

Stable money in todays complex economy is more important than ever – mass unemployment is a relatively new occurence, whereas in past centuries someone who lost their job always had the chance of going back to “eating what they could grow”, working the land, that is hardly a feasible option today for a programmer or marketing executive living in London, New York or Tokyo. Stable money is the life blood of a healthy, functioning economy, something even seemingly unlikely people such as Marx and Lenin realized (Lenin took Russia back to a gold standard in 1921 after years of hyperinflation wreaking havoc on the Russian economy, and probably enabling the communists to gain power in the first place).

People tend to blame markets for being prone to manias, short sightedness and overreactions. I do not dispute any of it, but compared to politicians in the last year, the market is a shining light of long sightedness:
policy during the crisis seems to have been mostly driven by tomorrows wished for headlines, and the last days market gyrations. Oh, and don’t forget cronyism – it is interesting Goldman Sachs has been one of the greatest benefactors of most bailouts, when the US treasury is filled with ex Goldmanites (no, it’s not a “conspiracy”, just good old cronyism, “I’ll scratch my friends back this time..”).

UK inflation rose to 3.2% from 3% between January and February. Most people seem genuinely chocked.

So, a 30% depreciation of the currency compared to most other currencies, a close to zero percent interest rate, and a money printing press running hot, and people are chocked that inflation is increasing?
What is up with these political and economic spin doctors? Where is the great chock that 1+1 still equals 2, that an apple dropped will still fall to the ground?

I am starting to loose all hope in humanity knowing that most countries are run by what is most akin to a bunch of retarded politbureau bureaucrat chimps with the foresight of gold fish. And I still think that might be offending the foresight of gold fish and the intelligence of retarted chimps everywhere.

I spent my Friday doing quite a bit of performance benchmarking, and some of the observations where quite eye-opening.

The basic test was retrieving 50 different objects with 2 related collections per object (1-to-many mapping with Hibernate) 1000 times. I did four different tests:

  • With Hibernate, no caching: test took 192 seconds.
  • With Hibernate, EHCache enabled as 2nd level and query cache: 60 seconds.
  • Direct access to EHCache, only use Hibernate on a cache miss: 20 seconds.
  • Direct access to EHCache, only use Hibernate on cache miss, only open a Hibernate session when required: 1 second.

It has to be noted that my initial results with Hibernate and EHCache as a Hibernate cache was even worse – there are a few gotchas in there, among them being applying the Caching annotations on both class and collection relationship level, and enabling the query cache properly.

But still, the best case is a factor of 60 better than the best case with Hibernate caching, and almost 200 times better than no caching at all!

It’s quite obvious from these numbers that caching can improve performance tremendously, even in the “worst” case with caching.
However there are a few take-aways from this apart from that simple observation – it would seem that Hibernates use of second level and query caching is highly inefficient compared to just hitting a cache explicitly yourself, why this is, I do not know.
Secondly, there seems to be a major overhead in just opening and closing Hibernate Sessions (as per the Open Session in View/transaction per request pattern).

The fact that in-memory operations are quicker than a relational database is hardly a surprise, but even when Hibernate is not supposed to do any queries, it seems to slow things down, which to me is a surprise (indicates to me it’s doing things internally it shouldn’t, or doing things it should very inefficiently).

The Open Session in View pattern is extremely convenient and productive to use for developers – but I think my findings make a pretty good case for someting akin to a “lazy initialized Open Session in View” – where you would have a “transaction context” of sorts around a request-response, but only actually initialize it IF you have cache misses OR need to write to the database.
Spring and Hibernate most certainly do not do anything like this in their implementations of the OSIV pattern, I found they will happily get a db connection for each request regardless of whether it is actually needed or not.

Finally, I should add that the Open Session in View pattern and these findings should not be a problem for 99% of web apps/sites, but at the moment I am working on one of those diverging high traffic, high volume sites where this might become an issue..

While everyone has been afraid of the deflation boogie man, US consumer prices actually rose by 0.4% in February which means official inflation stands at 4.7% year on year (that’s not even accounting for all the massaging the numbers get).

That won’t stop the Federal Reserve, who are planning to print a mind boggling 1.25 trillion(!) dollars to purchase assets. Gold rose by $50 dollar an ounce in late trading today, out of which $35 was in less than 15 minutes!

Take cover, the inflation bomb is coming. An inflationary holocaust is really coming..

I have spent a fair amount of time recently learning both Cocoa programming for the Mac, as well as iPhone development.

When getting started with iPhone development, I found my time spent with Cocoa very useful, as it follows the same patterns and shares some API’s. But perhaps more surprisingly, I found that when I was doing iPhone development, a lot of grey areas/areas of confusion in Cocoa all of a sudden fell in place when I was addressing the same things on the iPhone!

I think the case here is the benefit of restrictions – the iPhone is a limited platform compared to the full Mac OS, a phone cannot be as complex as a desktop OS because it just wouldn’t work with the limited screen real estate and means of input. That means that there is less to learn for the iPhone than there is for full blown Cocoa development on the Mac, but learning the limited scale iPhone means that you won’t get distracted by the complexity around you, hence you will learn quicker.

mugabe-brown
Even the pro Mugabe newspaper The Zimbabwe Guardian is ridiculing British monetary policy:

The difference is that Britain, unlike Zimbabwe, is using the same measures without biting economic sanctions; which suggests that they are in a deeper hole than Zimbabwe was, or is.

You may dress it up in fancy terms like “Quantitative Easing”, but in practice it is no different from the monetary policies used by Mugabe’s regime.

What are the odds that we will have price controls, “windfall taxes” on “excessive profits” and penalties for “price gouging” at least in some areas once it backfires and prices spiral out of control?

I have worked in a number of large “corporate” environments over the years, and quite a few of them have had some unfortunate characteristics – characteristics that form the basis of Dilbert’s success and recognizability.

It is easy when you come across these things to blame clueless “Pointy Haired Bosses”, and sometimes it might be down to the managers, but I would venture a guess that most of the time it isn’t.

If you think about it, a lot of the time what seems like “clueless management” that is counterproductive, is actually completely rational from the point of view of the managers incentives.
If you look at what the corporate world often gives weight and prestige to when it comes to management, you’ll quickly find that there are two major factors: “headcount” and budget size.

If you look at CV’s of managers, you will often find them emphasizing how many people they managed, and how large their budget was, end of story. Why? Because prestige is meted out based on size of budget and headcount rather than results. In a lot of organizations you will find senior- and mid management being outright hostile to any suggestions to cut their headcounts or budgets, even if it means being more efficient and getting a better results.
A managers “fiefdom” and its value is simply measured by budget and headcount, hence the managers will strive to find ways to justify increased headcounts and budgets.

The size factor is only one of the screwed up incentives a lot of organizations have to live with, there are often many more. One of them is for instance some organizations obsession with “traceability” – the incentives given have the effect that it is better to be able to retrace the steps to failure, than to produce success.

A third example, and perhaps as insidious as any other is the tendency of most organizations of measuring inputs (like hours worked, tasks completed), rather than outputs and outcomes (results that said hours produced). You tend to get what you measure..

Take a few more of these sort of screwed up incentives and cultural traits in organizations, and you quickly get a compounding effect of unintended consequences – managers and employees will start behaving in ways that at a glance look completely mindless, clueless and counter intuitive, but if you look at their incentives, you’ll quickly realize that they are in fact acting in a completely rational way given their incentives.
The only problem is that their incentives are in no way aligned with the desired overall outcomes of the project or organization.

I have spent the last couple of evenings re-skinning an existing, rather large Wicket webapp to a completely different look and feel (so foreign to the previous one that you wouldn’t know it was the same thing unless you checked the content).

How long did it take me? About 6 hours effective time, out of which I spent 4-5 hours massaging the new html and css given to me into the right shape for me, removing excess parts, working out what should go where etc. Point of note: I am utterly and completely useless at html and css.

The actual Wicket time took about 1 hour and boiled down to inserting the wicket:id’s in the correct places.
How could it be so easy? Well, I had put thought into using lots of reusable Panel’s with as little “design” as possible in their markup, and the site as such had a single markup file for all the WebPage related markup, so all markup except the WebPage markup was pretty well insulated from look-and-feel, and as Wicket enforces real separation of design and code, it was just a case of putting the “main”, “nav” and “login” wicket:id attributes in the right places.

Could it have been achieved with Struts, Struts2, Spring MVC, JSF or other “View logic is a hodge-podge of markup and Java”-frameworks? Not a chance.

Even though I’ve been using, pushing and evangelizing Wicket now for two years, I’m quite amazed at how easily this task went..

One of the main causes for making the Great Depression into a depression rather than a recession was the rise of aggressive protectionism – the logic went that protecting your domestic businesses from outside competition would be good for the economy. Only problem was everyone else followed suit, resulting in a drastic drop in world trade, and as a consequence an even worse situation for domestic businesses as their export markets evaporated.

Politicians think they have learned their lesson now (with the exception of Obama’s temporary “Buy American”-stimulus clause), but not quite:
Today we are seeing protectionism of another, even more shortsighted kind – the competitive debasement of currencies the world over. The logic goes that a weaker currency will increase your competitiveness in the world markets, thus raising the exports of domestic businesses. Only problem is, yet again, everyone else (even the Swiss and Japanese!) is playing the same game, resulting in a debasement race to the bottom through low interest rates and expansion of the money supply.
The predictable end result will eventually be increasing commodities prices, followed by increases in the price of just about everything else (except your pay package), enter raging inflation.

Ain’t it grand when the lunatics are running the asylum?

Next Page »