Undefined Behavior of Dangling Pointer Economy

“Educate and inform the whole mass of the people… They are the only sure reliance for the preservation of our liberty.”

Thomas Jefferson

Introduction

Everyone (well, almost everyone) knows that functional programming is (theoretically) the way to go about doing programming, right? Right. Well, let’s see … With due respect to the functional paradigm, there are aspects of that fancy OO paradigm that are kindof convenient, such as encapsulation, design power, better mapping to the real world, to name a few. But that’s not what we are after here, so we’ll conveniently disregard those aspects for the sake of staying focused on the topic. The main superior aspect of functional programming over imperative programming is in absence of data sharing. One can always get predictable results because there is no (well, in theory) cached state, ruling those pesky side effects out. The obstacles of functional programming in real world, however, are significant and they surface as soon as performance is observed when scaling comes into the picture. Sharing nothing implies copying everything. In other words, there are no pointers and similar dangerous constructs passed around between parts of your program. If you want to send a chunk of data somewhere else, be it to another function or another thread, you copy it and pass it on. Now think 10 gigabyte movie. Copying the thing is a pretty major task. Or think 1 megabyte worth of data in a time-critical real-time scenario. Once you have to do things like that, you are rapidly thrown back into the real world limits, realizing the goodness of pointers (and/or references, for C++ afficionados). But those, as we know, are tricky on a different front, because now you share memory between remote parts of the program. Obviously, an additional concern enters the picture now – how to synchronize the access to the shared portions so that all parts of the program have consistent view of memory. In a decent size program, nowadays typically running multiple threads of execution, synchronizing becomes anything but trivial. For better or worse – you can not get away with copying everything, so you better learn how to make do with pointers, references, deadlocks, livelocks, dreadlocks … Like it or not, in real world you will eventually, directly or indirectly, end up using pointers (references, anything works as long as you only pass around the location, not the whole content) and dealing with side effects. There is a great deal of goodness in functional programming paradigm, but most real world requirements, in order to perform in an acceptable manner, mandate data sharing and side effects.

OK, now that we have that pesky functional/imperative part straightened out, let’s get back to the main topic. What was it I was going to talk about?

Oh, yes – the economy, that nightmare that keeps me awake at night. Boy, oh boy, are we in a mess. I thought nightmare was over in the 90-ies when communism fell apart. Well, as it turns out, I was wrong, together with some few billion fellow human beings. Be that as it may, us humans feel much better once we understand things, so here comes an explanation from a computer programmer for the computer programming population.

First Things First (Or: What is Money)

Money. What is it? The Dark Side of the Moon album song? Paper bills in your wallet? Change in your pocket? Web page interface to your bank account? Credit card plastic? Or is it the magnetic band doing the magic? Do you really know? You deal with it daily and it is essential to your existence, so you should. If you don’t have it, things tend to get rough and tough. Recently, it has become fashionable to ask for bailouts. But where does the money come from? Never mind that, just hand out some dough. Given what we are witnessing, one can’t but wonder how many people really understand what exactly is money. I’d argue, about the same (or lower) percentage of folks that call themselves computer programmers and understand what a pointer is. Mainstream media does not make things better at all – quite the contrary. In the realm of politicians, the percentage is probably even lower – those folks have come up with their own rules of what money is. So what exactly is money? And who the heck makes the thing and, more importantly – who and how gets those freshly printed bills? Well, it used to be paper bills, but nowadays it’s not even paper anymore – it’s a database record somewhere (odds are, created and manipulated with – good grief – COBOL code). You see, it is kind of blurry, this whole process and it is blurry for a purpose. Namely if you are a hard working, law abiding citizen of what is called a civilized country, chances are you pay taxes (I hope you’re not reading this from a prison). Well, it is the value produced by your hard work that is being sliced and diced by the people who neither work nor produce any value. In fact, with honorable exceptions, most of them have never held a productive job in their whole life. They specialize in the business of redistributing what you’ve made and charge a hefty fee for the “service”. No, wait, scratch that. The rules have changed – as of recently they redistribute also what you will make. And your children, and your children’s children. Which makes you and your descendants, for all intents and purposes – slaves. But, wait – slavery does not exist anymore, we are taught. Bingo – that’s why all this money hodge-podge has to be blurry and processed into nice consumer-friendly confection.

It would be way too ambitious to attempt the complete money theory presentation here (especially by a monetary non-expert like myself). For that, see resources at the end of this article. Suffice it to say that real (no, not what we call ‘money’ today – that’s not real) money has the very same nature as the bread you put on your table or the gas you pump in your car. Money is a market entity like any other, except that it has some particularly convenient features. It begins as a commodity that a critical mass of people desire. Because of its universally accepted value and practical advantages of standardizing the value measuring unit, it emerges as a universal medium of exchange on the market. Historically, when left to the forces of free market, the precious metals (gold and silver in most cases) usually emerge as money. For the sake of this article, let’s think of money as computer memory. Not in the sense of exchange medium – there is no market economy equivalent in a computer system – but in the sense of a commodity resource that every program needs in order to run.

Pointer Pattern

Now, programmers are a weird bunch, but even for us it would be awkward to walk around with bags full of golden coins in this day and age. Just like it is awkward to copy that 10 gig movie from the first paragraph. Just imagine pulling a cart of gold bullions to the real estate agent’s office to sign your home purchase agreement. To each his own – a colleague of mine, when presented with the dilemma, instantly wondered if the “exotic dancers” would have tin pots to collect the tips and whether the sound of the dropped coin would increase the appeal of the event. Be that as it may, to alleviate the practical complications (and do much more, as we shall see shortly), the banking profession emerges. These folks (they used to be goldsmiths initially) specialize in keeping people’s gold (or silver, sea shells, cigarettes – whatever the money of the time and place is). And when you deposit the gold in the warehouse, they give you a receipt for it. This piece of paper is what we would call money today – a certificate that you have certain amount of gold deposited with your banker. It is also an equivalent of the pointer as the computer programmers know them. So, initially, it is all nice and well – you bring in your gold (call your malloc/new) and get a receipt (non-null pointer) in return. The problems start (although not yet manifest) when your banker figures out he can make it nice and swell by copying pointers and selling them out to other people as loans, pretending to have more gold than physically exists in the vault. Mind you, clever bankers even came up with  a fancy name for this hoax – fractional reserve banking.

Undefined Behavior

Now, let’s get things straight – it is not as if the banker copies a pointer so now there are two copies of a pointer and it is clearly understood by all involved parties that these pointers are shared and point to the same thing. No, he actually makes it look to his customers as if those two pointers point to different chunks of memory (remember, memory == money), knowing full well that both customers may show up at the same time asking for their gold. Obviously, that’s when problems arise. This is known as “bank run” in real life. In virtual reality of the computer programming it can cause several different scenarios that have to do with locking and data sharing. But if one customer is ahead of the other and gets his pile of gold out of the vault, then what happens when the other customer attempts to get his pile is equivalent of the dreaded “undefined behavior”. The results, obviously, have all the necessary ingredients to make a disaster. As you can imagine, customers holding dangling pointers are not at all happy once they discover their pile is gone. Talking about undefined behavior – just look back through human history and you’ll find an abundance of examples.

Dangling Pointer Economy

OK, now we know what the bankers do. But how can they get away with such a fraudulent scheme? If I rent the same apartment in the same time slot to two different tenants, I’ll end up in trouble. Same thing for anything else sold to more than one recipient. Except for money, that is – with the Government’s blessing. Did you ever notice the fine print about “legal tender” on your money? As it turns out, Big Brother has a monopoly on money. There are, of course, anti-monopoly laws, but those apply only to mere mortals and ordinary goods. Modern money is too easy to be made and too precious source of government’s power to be limited in such a way. So, when a prospect of a bank run shows up on the horizon, government quickly injects some cash into the banks. We’ve all become accustomed to bailouts and numbed to numbers that don’t correlate with an individual reality (currently trillions). Governments are much like compiler writers – they can do things strictly forbidden to programmers behind the scene. Unlike most compiler writers, however, governments do not always fully understand what they do. What they have done to the money clearly proves that. Because, not only has the de facto criminal practice of fractional reserve banking been legalized, but the remaining requirement of the gold deposit (a.k.a. gold standard) has been gradually abandoned and gold confiscated. Again, details are beyond the scope of this article, but suffice it to say that no currency in the world today is backed by gold or any other commodity or anything of firm value. Modern advance of the computing machinery has turned even paper into a mere figure of speech. Yes, you’ve got it right – your money is a virtual construct backed by nothing but the whims of your elected representatives and their banker friends. Welcome to the Wonderful World of Fiat Money. And that is what brought us into this mess. Please, do not ask why do people believe and hope that the same people who have caused all this would be willing (and capable) of fixing it. Majority of people seem to be willing to outsource their thinking and believe in unlikely scenarios or have simply given up any hope that anything can be done. The reality, however, is that economy obeys a set of laws. These laws can be circumvented for short periods of time (‘short’ as in years or decades), much like the law of gravity can be circumvented temporarily by tossing rocks in the air. But eventually, the immutable law inevitably kicks-in, rocks start falling as the moment of landing and reckoning approaches. Telling people that rocks can fly does not change the reality – rocks don’t fly and they never will. But, I kid you not, there was this guy, Lord no less, that wrote

Credit expansion performs the miracle … of turning stone into bread

John Maynard Keynes (Paper of the British Experts, 8 April 1943)

with a straight face, all in an “expert” publication (no, not a religious one). Needless to say, politicians did not miss to take advantage of this spiritual opportunity to turn economy into esoterically mystical art. So, here we are, 60+ years down the road, witnessing the futile attempts to turn stones into bread. The politicians, in cahoots with bankers and mainstream lobotomized economic thought, plotted the whole thing. What makes you think they’d want (or know how) to fix it? There is nothing government or anyone else can do. All attempts are doomed to fail, while making things worse. It’s only a matter of time and sometimes it may take a while, but eventually fail they will. Just like that rock will inevitably hit the ground.

Conclusion

So – we’re in a pickle. What’s one to do? Well, be careful with your pointers, my fellow programmers. Is there a way to fix the current mess? Sure – truly free market with gold standard would be a good start. Free is a relative word nowadays, but what I mean is – free in all segments of the economy, including financial. Free market has never existed in the history of human kind and what is nowadays being called free market and blamed for the current troubles is nothing of sorts. For starters, truly free market is irreconcilable with existence of central banking so those should go first. Again, space is limited for detailed elaboration on that, but there are plenty of resources out there.

Now, I’ll stand on the shoulders of giants and quote some smart people here. If you think this does not concern you, think again:

No one can find a safe way out for himself if society is sweeping towards destruction. Therefore everyone, in his own interests, must thrust himself vigorously into the intellectual battle. None can stand aside with unconcern; the interests of everyone hang on the result.

Ludwig von Mises, Socialism [1922]

The trifling economy of paper, as a cheaper medium, or its convenience for transmission, weighs nothing in opposition to the advantages of the precious metals… it is liable to be abused, has been, is, and forever will be abused, in every country in which it is permitted.

–Thomas Jefferson to John W. Eppes, [1813]

More Jefferson on money and banking can be found here.

And, last but not least, here’s my favorite:

Whenever destroyers appear among men, they start by destroying money, for money is men’s protection and the base of a moral existence. Destroyers seize gold and leave to its owners a counterfeit pile of paper. This kills all objective standards and delivers men into the arbitrary power of an arbitrary setter of values. Gold was an objective value, an equivalent of wealth produced. Paper is a mortgage on wealth that does not exist, backed by a gun aimed at those who are expected to produce it. Paper is a check drawn by legal looters upon an account which is not theirs: upon the virtue of the victims. Watch for the day when it bounces, marked, ‘Account overdrawn.’

Ayn Rand, Atlas Shrugged [1957]

Literature:

Ludwig von Mises, The Theory of Money and Credit [1912]

Jesús Huerta de Soto, Money, Bank Credit, and Economic Cycles

Jörg Guido Hülsmann:

Ayn Rand, Capitalism: The Unknown Ideal

2 Responses to “Undefined Behavior of Dangling Pointer Economy”

  1. POCO C++ Libraries Blog » Bool Shift: Undefined Behavior of Dangling Pointer Economy Says:

    […] How does functional programming, pointers and memory relate to this mess we call economy? Check out at Bool Shift. […]

  2. Undefined Behavior of Dangling Pointer Economy | No Brainer Profits Says:

    […] View original here: Undefined Behavior of Dangling Pointer Economy […]

Leave a reply to POCO C++ Libraries Blog » Bool Shift: Undefined Behavior of Dangling Pointer Economy Cancel reply