Bigger On The Insidehttp://blog.chewxy.com
Straight from my brain, mostly unfiltered.Wed, 11 Mar 2015 22:52:34 +0000en-UShourly1http://wordpress.org/?v=4.1.1Just Fairhttp://blog.chewxy.com/2015/03/11/just-fair/
http://blog.chewxy.com/2015/03/11/just-fair/#commentsTue, 10 Mar 2015 17:50:25 +0000http://blog.chewxy.com/?p=2746Continue reading →]]>Preamble: I have not blogged in a while. I have quite a few things to say, and have started at least 7 blog posts but never found the steam to complete them. Last Friday, I was having a rather interesting conversation with my colleagues, and that was cut short by a prior dinner arrangement. Having left the conversation topic unended, I decided that it’s a good point to jump off and continue blogging.

I lean slightly left towards Marxism, and I made it clear what it is that appeals to me. What appeals to me about Marxism is that it is most sci-fi in nature. “From each according to his ability, to each according to his need” is probably one of the most Star Trek-esque thing you can say. Indeed, I dream about a future where society functions like this, and I am actively working towards making such a change in society.

Of course there are other bits of Marxism that are I think outdated – the concept of class warfare, and proleteriats needing to seize control of Das Kapital[1] is in my opinion, a very 19th century view. I do however, note a similarity between today’s society and the society that Marx lived in, one on the verge of a technological revolution[2]. Just as I note that the philosophy of Marx’s time was that people find meaning of life through work, we are similarly in a period where the same has happened. Think of how you would introduce yourself to other people – it’s your name, followed by what you do.

And there we were, seated at the table. Me, J and P were discussing my Marxist leanings. J posited a very interesting question, which I have paraphrased to omit the amount of obscenities that are wont to come about around groups of male humans speaking:

Imagine if there were two students, A and B. A is super hardworking, and does all the work during the semester. A even does extra work to understand the subject deeply. B on the other hand is a party animal, preferring to skip classes and not study, and would rather spend his time partying.

Then comes exam time. Obviously A does better than B. But here’s the twist. The lecturer for whatever reason, approaches A and proposes that A averages out his grade with B.

Putting aside obvious flaws with the analogy (which I will expand on in the later part of this post), I answered with an affirmative – that I would indeed be okay to average out the grades.

After cries of indignation and disbelief, and logical reasonings why my decision is abnormal, I laid out an alternative view:

Imagine if there were two students, A and B. Both A and B are extremely interested in the subject, and are motivated enough to study hard for the knowledge.

B however, has a string of rotten luck and poor health, which causes her to skip classes and study time as B has to go to the hospital quite a bit.

Come exam time, and the teacher makes the same offer. Would you average out your grades if you were A?

Both scenarios are the same, mechanically speaking, even if the motivations are different. Both J and P said that they would at least think about averaging the grades. Incidentally, during the dinner I adjourned to, I posited the both situations and the guests at the dinner too had similar responses as J and P – that it would not be fair (and that they would not agree to average grades in the first scenario and that they would consider in the second scenario).

This harks to a concepts of justice, equity and fairness – concepts not commonly seen in academic economic literature[3].

Definitions

But to further discuss this issue, let’s first define the concepts of justice, equity and fairness in the context that I wish to discuss. The main context is that the concepts are to be discussed in terms of distribution of resources, which economics is mainly concerned about.

Justice is the idea that the distribution of resources is done in such a way that the receiver deserves the goods received. This makes it an extremely prickly subject, because justice means different things to different people, and it comprises a wide range of ethics and philosophies, as I shall try to paint in broad strokes here. To religious nutbags, the words of the deity in question is just. If the deity says to allocate resources in a certain manner, it is just. Anything else is unjust and blasphemous. To capitalists[4], it’s only just that people get what they work for. Any other way of gaining resources is unjust. To legal theorists like John Rawls, justice is a form of fairness[5].

Equity and equality refers to the idea that all participants within a transaction should be treated the same (or similarly), without a party being unfairly preferenced. Of the three concepts, this is the simplest concept. There is a subtle difference in the terms equality and equity. In recent years, equality has taken to mean equality of opportunity – it means that all people participating within a certain social situation should be afforded the same opportunity. For the sake of this article, we’ll call this equity. Equality is concerned with the distribution of resource, not the distribution of opportunity[6]. If everyone had an equal share of the goods, then equality is achieved. Note that an equal share does not mean that it is fair, and by extension, just.

Fairness is a concept that is related to both the concepts above. Usually when discussing economic concepts, fairness is not well defined. It’s quite hard indeed to define fairness. For the sake of simplicity, let’s say that fairness is defined as the prospensity to avert inequity and maximize justice. And I believe that this is innate in all humans (and chimps too). Given a game like the Dictator Game, it’s been shown in multiple experiments, across all cultures, that people playing the role of the dictator tend to split the earnings evenly (I believe a 50-50 split is the most common split). It’s still one of the most interesting game theory experiments to be run on the ideas of altruism and reciprocity and fairness.

Fairness, in my opinion, is a complex value[7] that has components in justice and equality. Obviously it has components in other values like reciprocity, compassion and debtedness, but for the sake of simplicity in this article, we’ll just say it’s comprised of justice and equality. We spend a lot of time thinking things in life are either fair or unfair, creating the red line and the dotted borders above. However, if we think depeer, there are other quadrants which can be filled, as I will explain in an example below.

Coincidentally, in the field of psychology, fairness can also be defined in three components – sameness, deservedness and need. The definitions of which sound pretty close to the three concepts I have defined above. However, since I have no expertise in psychology, I shall say no further.

Back to last Friday. What J and P and my dinner guests felt for the first situation was that it was unjust to average the grades in the first scenario above, while it’s at least just to average the grades in the second scenario. It is equal, for sure, but it’s clear that most people feel that in Situation 1, the averaging of grades would be unjust (Student A does NOT deserve it), but it is unarguable that it is equal. Likewise with Situation 2, where it’s somewhat just (student A may deserve it), and equal.

The talk of justice opens up all sorts of cans of worms. But the one I want to talk about is the arbitrator problem.

The Arbitrator Problem

The arbitrator problem can be illustrated with a third scenario:

A, B and C are students in a class. A is the aforementioned party dude in the class in Scenario 1. B is the aforementioned hardworking one in both Scenarios. And C is the aforementioned ill-lucked one.

You play the role of the teacher. Do you average marks between A and B? or B and C? or C and A? Or between all three?

In this scenario, the teacher/lecturer is playing the judge – the arbitrator who will solve the problem of justice and equality. The problem is then the system is reliant upon the arbitrator to make good judgment calls. You’d be lucky if in a situation the arbiter is Superman. But even Superman can fail. In a very clear cut scenario like the one above, it’s easy to make good judgment calls. If A is the nephew of the teacher, and the teacher decides to average the grades for the benefit of A, we can clearly see that it’s unjust. We call this corruption in real life. Real life isn’t clear cut like the above. Real life is murky, with twists and turns.

Which brings me to the main objection of the whole analogy to begin with. There exists an arbitrator in all of the scenarios above. It’s clearly meant to be the analogue of the government (or dictator), where the students are the citizenry of the country. The scenarios above are very shallow analogues of central governments (the teachers) distributing resources (grades) to the people (students). Except, reality doesn’t work like that. There has been experiments on central government directly distributing resources, but none has worked well so far. The problem with this analogy is that it ignores the fact that the citizenry interact amongst themselves.

Of course there will come a day when the hypothetical optimal distributor viable – say a super computer who knows everyone’s indifference and utility curves over a basket of every possible item – I’d be willing to let such a computer distrubute resources and forego the marketplace dynamics if such a supercomputer were possible. But that’s a story for another day, probably one involving star dates.

Games

Let’s say we accept that the only form of information transfer is between the teacher and each student. How would a situation like the scenarios be represented as a game?

It turns out there is indeed a game theory experiment that is similar to the scenarios above – the Public Goods Game. The main difference between the scenarios above (let’s call it the Averaged Grades Game) and the Public Goods Game is that the Averaged Grades Game requires work as an input and some other form of utility as a reward.

This is a important distinction. Firstly, I believe the concept of justice can only be measured if the player has to work (i.e. put through some minor discomfort) for it, and some form of equality has to be factored in as well. The usual design tricks of giving participants some initializing tokens that can be exchanged for money does not fully capture the injustice that is felt if real work were done. A variant of the Public Goods Game where the initial play money is “earned” (or with different levels of “income”) approximates this. Having work unit fuzzies the connection between how much is invested and how much is returned.

Secondly, the Averaged Grades Game has no multiplier (or, has a multiplier set to 1). Again, this is a distinct difference. It’s been shown that without a multiplier, the Public Goods Game doesn’t work. I believe it will work for the Averaged Grades Game, because information is leaked to the player through the averaged grade, as opposed to told to the player.

Thirdly, the rewards the participants get is solely through the “exam results”. In the Public Goods Game, the rewards the players get is the sum of what they kept for themselves, and the the multiplied returns from the public pool.

Lastly the analogue for the Public Goods Game is a public good, which may or may not feature in a participant’s preference set. Whereas in analogue for the Averaged Grades Game is the results of an exam, of which preference for is a strictly increasing monotonic function[8].

Description

Here’s a more formal description of the Averaged Grades Game:

Players are given a task to solve puzzles, where a puzzle is a work unit. The more puzzles players can solve, the more reward (a monetary unit) the player earns. However, at the end of the game, all the players’ rewards are pooled together, and the averaged reward is returned to the player. The player is told at the end of the round, how much he/she has earned, and what he/she will be getting.

Variations can include a surprise rounds of not averaging the results, announced only after the round has ended. The amount of leaked information can also be used to test for justice. For example, at the end of every round, the proportion of students who score more than 50% is broadcast (this will make those who have done extra work feel “vengeful” and “punish” those who haven’t pulled their weight).

Equilibria

Depending on how the game is framed, there may be two Nash equilibria. The first Nash equilibrium of this game is the same as the Public Goods Game – zero work units will be expended. Not contributing any work is the only move a player can make in which other players’ decisions will not make the player worse off. However, just like real life experiments with the Public Goods Game, I expect reality to not converge towards 0. Instead, I believe it will converge on a level that is just above 0.

The second Nash equilibrium is the maximum work units being produced. This would happen if the game were expressed as a modified Public Goods Game where the players only get rewarded after contributing to the pool, and don’t get to keep their initial tokens. I don’t see this happening in real life situations either. People tend to punish, and feel guilt, especially with successive rounds.

Simulations

Given that I don’t have access to a behavioural economics lab, I decided I would replace human participants with some silicon ones, so I wrote some simulations[9], simulating a few things:

Each student has some baseline “intelligence”[10] that does not change.

Each student puts in work. The amount of work put in is a function of the intrinsic motivation of the student[11].

Results are a function of both intelligence and work

After each round, the student receives both a score, and an averaged score

The student chooses to make adjustments on the work put in for his/her next exam

The adjustment is subject to two other factors: motivation, and locus of identity of the student

The key metric we’d be looking at is the trend of the averaged scores over time, as well as the effort put in by each student over time. Here are the results of a hundred runs. Here’s the code in 200 lines of Python (skip to results and discussions):

Results

And here’s the result:

100 runs of Average Results over time, overlaid with each other

Here we note that as expected the average result does indeed drop after an initial spike. This is how it looks like when it’s smoothed and averaged across all the runs:

We’d also have to consider the distribution of scores for each time period. To do that, I have plotted a box plot of the scores of a particular run (Run 47).

Discussion

The simulation is obviously a very very very simple simulation. If you hadn’t understood the code, here’s a general gist of what it does: The study period is drawn from a normal distribution with a mean and standard deviation that is the same for everyone in the first period. When the second period starts, the motivations of the students affect the mean of which the study period is drawn from. The locus of identity of the student affects the standard deviation from which the study period is drawn.

The exam scores are a linear function of the study period and intelligence (of which is only a small component), and noise drawn from a normal distribution with constant mean and standard deviation across all time periods.

It should hence be clear why the average scores converge around the mean of the initial study period. This is a reasonable assumption. Nobody goes to university with a goal of not putting a single ounce of effort into studying.

Another part of the code that I don’t particularly like is the amount of clamp() that is used. This was necessary to clamp down on extreme values, but it may turn out that I don’t quite have a feel for drawing from normal distributions, so instead of tweaking the starting mean and standard deviations, I decided to just cheat by using clamp().

If anyone is willing to make a better program, please, do by all means fork the code and write me your results. I am keen to know.

On Socialism and Equality and Equity

I had mentioned briefly that I would say yes to the first scenario – that I would be willing to average my grades with the scumbag who doesn’t study. Furthermore, I too mentioned that the classroom example is a poor analogue for a central authority distributing resources to the public. Saying this appears to make me go from Oliver Queen to Lonnie Machin.

The issue is one of semantics. I’m not saying the government has no role in distributing resources, but rather, I think the government has a role as a player in the same game. In fact, I would say the government is an entity that it charged with the moral role of ensuring equity amongst other players by using the rules of the game.

What this means is that things like affirmative actions, specifically quota-based ones, are in my opinion, not good, while things like universal living wage is a good thing. The difference between them is universal minimum wage plays by the rules of the game – transactions, etc – while things like affirmative action justly creates equal opportunity by making providing unequal distribution.

Consider a scenario where a university has places for 100 students. Let’s say the university has a 20% quota for peoples of [your choice of disadvantaged demographic]. It just happens that there are 120 students who are equally qualified to enter. Out of that 120 students, 20 of them are from [your choice of disadvantaged demographic] families, so they’re instantly accepted. This means that only 80% of the others would be accepted. While the intention is noble and just (I fully agree with equal opportunity), it is not difficult to reframe the statistics in such a way that it’s unfair. Observe:

100% of students of [insert disadvantaged demographic] gets accepted to the university, while 80% of the students of higher socioeconomics status gets accepted. Does that mean that if I’m a [insert disadvantaged demographic] student, I can still get into this university without good grades?

I grew up in a country where racial quota plays a role in everything, from education to buying houses. I can tell you from first hand experience it is not fun. Even when you logically convince yourself that it’s for the betterment of society, one can’t help but feel that there is some level of unfairness at play. Obviously there is no just basis for having racial quotas, but even if the quotas were based on socioeconomic status (which I feel is most just), I’m quite sure that the feelings will remain.

And yes, I am aware in the the reframing above, I am also conflating entrances from quota with entrances from ability. It doesn’t mean that if a person is accepted as part of a disadvantaged group, the person does not have the ability to be accepted if they’re not part of the disadvantaged group.

Quota-based affirmative action almost always guarantees that a proportion of people of higher skills will not be accepted. That’s rather the whole point of quota-based affirmative actions: There exists a group that is disadvantaged in some way, and do not have the same opportunity as someone who is not in the disadvantaged group. Chances are high that the main opportunity gap is one of skill. That is to say the average skill of the disadvantaged group that is lower than the non-disadvantaged group, mainly due to pre-existing life conditions. If both groups are of the same average skill, then the opportunity gap must lie elsewhere. If the opportunity gap lies elsewhere, a quota based system will not help.

Another issue is that the disadvantaged demographic definition is subject to the arbitrator problem. Someone has to decide that X, Y, Z features are features of the disadvantaged demographic. There is a distinction of feature quality too. For example, socialeconomic status is a much better feature than say, race or ethnicity. One is easily defined and verified, the other is too fuzzy – everyone knows about the ridiculous one drop rules, for example.

This in part is why I am more in favour of softer affirmative action (such as targeted advertising[12]). Or even things like universal living wage all sound like fairly good ideas to me. These are actions in which an arbitrator does not have absolute power. Yes, I am aware that the free market is flawed, and needs to be somewhat reigned in (by said arbitrator/government/state), but the power is not as absolute as in enforcing quotas. I have digressed too much though. I may actually spend another blog post writing about that.

And Yet…

And yet, if you recall earlier in the blog post, I said I would be willing to average the grades with the scumbag who doesn’t study. Considering it as a solely one-off event, I would likely say no. However, when the situation was posited to me, I instantly started thinking about other variations in which the ill-scoring student was subject to other conditions[13]. It is from this thinking that a sense of fairness rooted in higher weightage of equality which prompted me to say yes.

Further Work

This is just a brain dump that arose from Friday Night Drinks at work. However I have a feeling that this is actually a good econs experiment that can be carried out. If anyone would like to carry it out, please do, and also keep me informed. I’d be delighted to read your papers[14].

TL;DR

Congratulations for making it so far through my ramblings. I’m not sure what you gained from it. My views on political systems is abysmal and pessimistic at best, so please don’t follow what I say.

I posited a situation, based on a popular story online. I then defined the concepts of justice, equality and fairness. From there, I digressed slightly to a problem with using a classroom setting as an analogy for government, and tried to define the classroom interaction as a game. I pointed out the similarities with a already known game, and then discussed the possible equilibrium states. I then continued with a simple simulation of the game, and discuss the results. I then end with a rant on socialism and equality and equity.

Also, I tried to hide multiple Justice League related puns and/or references. I think I failed in that aspect.

Reading Material

If you’re interested in this topic, here are some reading material on the topic:

Gary Bolton and Alex Ockenfels’ A Theory of Equity, Reciprocity and Competition

Erns Fehr and Klaus Schmidt’s A Theory of Fairness, Competition, and Cooperation

[1] by that I mean, means of production. I think this is a very good pun ↩

[2] Das Kapital was published just as the dust of the Industrial Revolution was settling. Its observations of course, were made by Marx DURING what we call now the Industrial Revolution ↩

[3] OK, I lied. There is an entire field of economics dedicated to this topic – it’s just very new – about fewer than 20 years. Matthew Rabin invented a whole new way of looking at utility based on fairness as a preference in the utility curve. Fehr and Schmidt came up with ways to encode guilt and compassion when looking at games. The past 10 years have been pretty much replicating experiments across cultures, with not much new or groundbreaking ↩

[4] meant in the broadest sense of the word, i.e. if you are Ayn Rand ↩

[14] HAH! As if anyone would be inspired by this blog post enough to write a paper… ↩

[15] It’s a book. A very hard and dry book to get through. I didn’t bother finishing it – just skimmed through ↩

]]>http://blog.chewxy.com/2015/03/11/just-fair/feed/0Naming Things (They’re All Named Lucy)http://blog.chewxy.com/2014/09/28/naming-things/
http://blog.chewxy.com/2014/09/28/naming-things/#commentsSun, 28 Sep 2014 11:56:21 +0000http://blog.chewxy.com/?p=2682Continue reading →]]>Have you had an experience you couldn’t quite put to words? Or understood some things that cannot be described well, and everything you tried to describe it in feel like poor analogies of it? Or that you even have to resort to using analogies to begin with?

And then someone mentions a word that sounds familiar, and suddenly, the connection makes sense. It made sense for the word to mean the experience/series-of-events/phenomena that you had experienced/understood.

Earlier this afternoon I had that experience. I had experienced something that is really difficult to describe, and put to words. I took a lot of notes about it, but I wasn’t able to accurately or satisfactorily explain it with words. What the experience was and the topics it surrounded is not of much importance, nor is it profound because I spent the rest of the afternoon obssessing about the fact there are no names to describe exactly what I had experienced.

In fact, the whole meta-ness about names makes even writing this blog post a little difficult, but I hope I am able to express what I mean quite clearly.

Given that names are pretty important, there are a lot of problems with names.

The Problem With Names

To talk about names clearly and unambiguously, some definitions are in order. Magritte’s Treachery of Images would be best used to illustrate my case of what a name is. A name, by my definition for the purpose of this blog post, is simply a reference. Just as the painting of the pipe is referring to the “idea” of a pipe (such ideas may be concrete or abstract, but I am getting ahead of myself), a name simply refers to something else. What this “something” is, can be concrete (keys, car, house), of it can be abstract (Einstein’s Mass Energy equivalence).

Both nouns and verbs are names, for different things. Nouns are typically names for real-life objects and abstract ideas, while verbs are names for actions and activities. For this part, I’m going to mainly concentrate on using nouns as an example, but you can easily extrapolate my arguments for verbs.

Ambiguity, Part I

The first problem with names is this: The thing that the name refers to is ambiguous in most situatons.

Arguably, (in-situ) context helps. For example, if I were in a completely empty room with you with a pipe in the middle of the room, if you mentioned “pipe” or “the pipe”, it would occur to me that it refers to the pipe in the room. Otherwise, a “pipe” simply refers to the my idea of what a pipe is, which could be any one of these:

And that brings to conclusion part I of Ambiguity – a name can refer to a lot of very different things.

Ambiguity – Part II

Even if we add a lot of context to a piece of communication (for example, you may refer to smoking certain herbs that activate the cannabinoid receptors in the brain[1]), the name could still be highly ambiguous.

Imagine if you will, you encountered a tribe, C whose language has no name for the word “pipe”. But yet they clearly do have a device they smoke pot out of. Imagine this tribe has to regularly build and dispose of such pipes on the fly, as such they have no need to give it a name (let’s say they use apples to make the pipes). They have a name for apples, and despite using apples as pipes, they have no words for a pipe. They instead, call it by either what it is (an apple), or by its function (i.e. “giver of smoke” or “smoke gift” [2])

The key idea is that people of Tribe C knows what it is, but have no specific name for it.

If on your first contact with tribe C, you pointed out that the thing they use to smoke out of is not only called an apple, it’s also called a pipe, they may not recognize it as a distinct noun. Afterall, it is in their culture to consume the pipe after combustion[3], and they never needed a name for it because it’s a throwaway thing.

Even so, there has to be a shared understanding of what a “pipe” refers to. If you were making first contact with the tribe, and showed them your pipe, and called it a “pipe”, they may think that only that is a pipe.

This exactly is the problem that artificial intelligence faces – a “pipe” does not only refer to one thing. It refers to a set of things that share certain features with each other (the basic pipe is simple: 1 hole for the herb, 1 hole for the smoke to get out of, and optionally one carb). It’s the idea, or concept of a pipe that is shared.

A “pipe” can essentially mean any of these and more:

Here we see Google outperforming humans. I’d never have expected some of these to be pipes (mainly due to the sheer stupidity of using lightbulbs or drink cans seemed a bit extreme to me)

The above ambiguity can of course be cleared up further, using deictic demonstratives like this or that; or definite articles like the. But not all languages have them.

My Issues With Naming

Often when I am explaining things, I will slip into jargon. Friends have often told me that I’m always arguing semantics. And this is exactly the problem I have with naming things.

Most things are poorly defined. To the point that at the beginning of each discussion I have, I tend to actually lay out the definitions clearly and unambiguously (which, try as I can, isn’t as easily achievable as it seems). This makes me sound rather pedantic and nitpicky.

It also makes me look rather inconsistent. The definition of things change from discussion to discussion – sometimes the scope of definition is wider, and sometimes it is narrower, depending on the context of the discussion. And yet, they share the same name.

One of the most interesting development in computer science is content addressable storage. Every file has a unique hash to it (made from the contents of the file obviously), and the file’s name is its hash, which is its contents. If the file changes, a copy is made with a new hash. For all intents and purposes (barring strange collisions), the hash is the content, and the hash is the name of the file.

This of course, cannot work in real life. There is no hashing function in real life that can describe an action, or even an object. And it would be laborious if we were to call everything by the contents of the object (content can be features of the object, or even the action of the object). But let’s imagine it can. Instead of a hash, the name of a thing in the real world is called by its features and properties. This leads to one of two possibilities: Nounless languages, and verbless languages[4].

A nounless language would be quite hard to imagine. But apparently they do exist. The Salishan group of languages are apparently nounless (it’s a debatable feature), as are the language of Riau in Indonesia. In those languages, a duck is “one that exhibits duck like behaviour”. Think off it as duck-typing of human languages.

A verbless language is even harder to imagine. I don’t think there are any in real life. But let’s imagine how some of the language would occur. Instead of saying “I eat food”, you’d probably say something along the lines of “I mouth food”.

What To Do About Naming

To be honest, I don’t think there is a good solution at all. Creating a language that is precise and unambiguous is nearly impossible. Programming languages come closest to being precise and unambiguous, but communicating in code would be a nightmare.

Everything I wrote so far can actually be applied to programming languages. Nounless languages are essentially functional languages (well, kind of. The analogy breaks down upon a lot of further thought). Verbless languages are essentially object oriented programming languages. But these are mere analogies. There things that are yet to be named, that we do not know of.

TL;DR – Names are a pain in the ass, especially when you think about it. Now, tell me what you think

“You know, small. JavaScript. Lisp. Small, stuff… Not big,” he faltered as he struggled with the rest of his sentence.

That led to a series of discussions about what a small language is. We eventually enumerated a list of languages which we knew and could classify. Languages which we mutually agree are small are listed in small fonts; languages which we mutually agree are large are listed in large fonts:

C

Scheme

Lua

Python

Go

JavaScript

Haskell

Java

C#

Comparing Keywords

So what exactly is a “small language”, and why do people clamour for it? One metric discussed is the number of reserved keywords a language has. We quickly (and I must add, roughly) looked up and tabulated the results:

Okay, so C doesn’t fit into the (limited) picture of what a small language is. It’s also obvious that there are non-functional reserved words in JavaScript which I have included (i.e. the stupid weird shit known as future reserved words). The Haskell keywords wiki itself counts certain operators and lexemes as keywords (like comments).

A big problem with using keyword count is clearly that it’s not really representative of the language, though it is indicative of what we’re looking for. C# and Java have a large number of keywords (the word “enterprise” and “bureaucracy” also comes to mind when these two languages are mentioned), and are often thought of as large languages.

The use of keywords count also shed some light on the question of “what is a small language”. For such a short phrase, it’s surprisingly ambiguous. What could a small language mean? Is it small in terms of its built in functions? Is it small in terms of the standard library that comes with the language? These two do not seem to be likely what people are most often talking about when it comes to small languages. A small grammar could conceivably be what people mean when they talk about “small languages”.

So I thought to myself: why not compare grammars?

Comparing Grammars

Fortunately most programming languages have a well-defined grammar and they can be usually be expressed in (Extended) Backus-Naur Form. And fortunately too, most language specifications actually do specify the grammars of the language in some vague EBNF-like form.

So the solution is to count the number of production rules in the official language specifications. I’m going to ignore C# (because if there are 79 keywords, imagine how long the EBNF is going to be – Here’s where to find the C# 4.0 EBNF), and Java (the Java 8 specification has 17 pages worth of EBNFs.)

Some grammar specifications were embedded in long web pages, which I have extracted. Most of these grammars are not proper EBNF, but they resemble closely enough in the sense they follow this pattern Production Rule [separator] Nonterminals (some language spec has terminals in them). I also transformed all the grammars so that 1 line contained 1 production rule. Counting the number of production rules is simply counting the lines in a file.

So there you have it. A comparison of grammars based on how many rules there are. These are the “lightweight” languages. Needless to say C# and Java will have a lot more rules.

Caveat

As always (in most of my blog posts I have one of these), there is a caveat. For each language there can be multiple EBNFs – it depends on how you want to specify your grammar. The EBNFs I used are mostly official grammars from the language specifications themselves (some like C are printed on dead tree paper, so I’m not going to type that out, so I shortcutted and used someone else’s).

Perhaps another way to think of “small languages” is what kind of parser could be built for those languages. If a LL(1) parser could be built for the grammar, that implies it’s a simple grammar, and that means it’s a small language (yes, I am aware that I am conflating the concepts of simplicity with size). That pretty much also means that in the list above, only Python could be parsed (and even so it does with a lot of crutches).

Small Languages, A Conclusion

I can definitely see the appeal of small languages. A small grammar implies a smaller cognitive load. This leaves more space for the structure of the program that you’re writing itself. Of course small languages can be complex too – I often had to look up where to put the * during the course of whatever little C programming I have done (can’t remember the spiral rule for the life of me).

I think this also highlights how important the stdlib of a language is. Out of these languages, I love and use Go and Python the most simply because they have fantastic stdlibs. Small core, but great stdlibs, that’s what I look for in a language.

But surely this is not the only appeal of small languages? Tell me why you like small languages below.

[2] I only extracted a portion, since ECMA also specifies the JSON grammar, which is what I consider to be outside the programming language, as well as the regex grammar ↩

]]>http://blog.chewxy.com/2014/09/03/small-languages/feed/9The Dinner Party Around the Worldhttp://blog.chewxy.com/2014/07/30/the-dinner-party-around-the-world/
http://blog.chewxy.com/2014/07/30/the-dinner-party-around-the-world/#commentsWed, 30 Jul 2014 00:37:37 +0000http://blog.chewxy.com/?p=2605Continue reading →]]>TL;DR Last saturday I held a dinner party at my house. This is the recap, with the recipes.

For the last 3-4 months, I had been thinking a lot about holding a dinner party. I had been playing with several ideas in my head. And you know how ideas are like – they are screaming to come out of one’s head and into reality. So last month I decided to send out invites to 6 people, for a dinner party around the world.

For the dinner party I knew there had to be a theme. I originally started with the theme of “Layers”, but as time went on, I convinced myself that the theme would be too subtle. So I changed it to “Travelling Around Planet Earth”. But I still was very enamoured with the idea of layers in my dinner party. So I made a compromise. By the time the invites were sent out, the dinner party was called “A Trip Around Planet Earth”, with the theme of “Layers”

The Initial Plan

The initial plan was to serve different courses of meals that correspond to different continents of Planet Earth. The menu on the invite was this:

The Menu

Apéritif and Amuse-bouche*

Entrée: A Garden Salad

Main Course: Chilli con Carne and Corn Bread

Dénouement: A Glass of Milk

Dessert: A Secret (for now)

Digestif: Coffee

* Tentative, depending on availability on the day itself.

Not very useful information. But of course by the time I had sent out the invite, I had a very solid idea of what I had wanted to do. My invitees on the other hand, didn’t expect much.

There were a few things I had in mind that were vital in this dinner party. Each course (save the amuse-bouche) corresponded to a continent, and the food would correspond to foods found in that continent. I had to make my guests feel as though as they had been transported to those places. The amuse-bouche was to be the launchpad for the imaginative journey that were to begin.

I am a big believer that we eat with ALL our senses. That meant everything needed to be controlled, from the music in the background, to the scent in the air, to the ambient temperatures. Thankfully it was winter, so it was easier to control the latter with heaters.

Amuse-bouche: Lemongrass Prawn with Carrot and Ginger “Caviar”

The amuse-bouche was a last minute idea. My original plan didn’t actually include an amuse-bouche nor an apéritif. However, upon tallying up the the dishes I had, it didn’t feel balanced. So I added the amuse-bouche just before I had sent out the invites. Hence the asterisk – in case I wasn’t able to come up with an idea, I’d not have an amuse-bouche.

Nonetheless, I did come up with an idea for the amuse-bouche. Many years ago, I had lamented anonymously on a gastronomy forum that there weren’t many particularly interesting uses of popping candy in a savoury dish. The problem was that popping candy reacts to water. So the choices of things that work with popping candy was limited.

I was very insistent on using popping candy as an ingredient in the amuse-bouche because as the first dish, it would signal the tone of the dishes that would come. I wanted it to be magical. I wanted my guests to get excited and find that child-like wonder when encountering this dish.

I had always figured that popping candy works well with highly intense flavours because when the candy pops, it sends extra gases into one’s nose retronasally.

Hence the idea was to have a highly fragrant dish that would have its flavours accentuated by the popping candy popping in the mouth. Lemongrass immediately came to mind – it is exteremly fragrant, and it works well with a number of things. I have had successes matching lemongrass with carrots and ginger in the past, so I thought why not do something with carrots and ginger – the flavours go very well together.

But how to present carrots and ginger in a nice single-serve? My thoughts immediately jumped to fancy hors d’oeuvres that I’ve had. A lot of them featured fish roe. So why not make carrots and ginger into a “caviar”[1]? I have a spherification kit, and so I jumped to it.

Lastly the dish needed something to carry it. I jumped into the typical solution of scallops. But on the day itself, we couldn’t find scallops, and had to settle for some dodgy looking prawns.

To figure out the optimum amount of popping candy, my partner and I did a large amounts of tests – and we settled on the solution literally minutes before my guests arrived. The solution was to place 2-3 pieces of popping candy at the top of the spoon so that the candy goes in last, and creates the popping effect with the rest of the dish in the mouth.

Recipe

Playing It Out in Real Life

To start things off, the music in the background was Hedwig’s Theme from the Harry Potter’s OST, which I had always associated with magic and wonderment. I had also considered When You Wish Upon A Star, but I decided that lyrics were too confusing. The main point was to impart a magical moment as if my guests had entered a different world.

And so we started. I had the reaction I was looking for. My guests were doubtful at the dish in the beginning, but when the popping started, everyone visibly got a lot more animated. I’m quite glad to see that popping candy still holds some magical effect over people.

As for the flavours, it worked quite as expected – it was the ginger that was accentuated though, with the lemongrass forming a background hum in the mouth. One of my guests actually thought the piece of fried ginger. There was a obvious textural layering from the flesh of the prawn to the pop of the “caviar” to the crunch of the popping candy. There too were layers of flavour difference – the salty prawn followed by spiciness and sharpness from the “caviar” and finally a burst of sweetness from the popping candy.

After an initial round, I showed my guests how the dish and flavour was built, layer by layer, and then they helped themselves to future buildings of the dish. This interactivity was unplanned, and I liked it, so I decided to follow up with a guide on how to build the dish after each dish was presented.

Entrée: A Garden Salad

For a number of years now I had wanted to re-create Heston Blumenthal’s Garden Salad, but never had the opportunity. I had made the salad before, but never had the opportunity or need to dress it up. This was my chance at it.

With the sauce gribiche, it was the perfect first location – Europe – to land in. To me the dish really did embody everything European – classic French recipe, emboldened by mediterranean flavours. The acidity in the dish would make it a good entrée, preparing the audience’s palate for the upcoming dish, which was bolder.

In my original plan, I had wanted to make olive oil gummy worms to bury in the soil, and edible baby potato rocks. I then considered the psychology of my guests – a couple of them are quite squirmish, and won’t touch anything “weird” – and realized that had I put those in, I’d be teetering a very fine line between an enjoyable night and an awkward night.

Recipe

Playing It Out in Real Life

The music was changed to Mozart’s Concerto No. 21. When I think of Europe as a whole, I have a romantic image of classical musicians ruling the courts of the day, and I wanted to impart that. The intended scent of the meal was geosmin, to impart a ground-like/earthy/mossy smell as the guests dug into the salad. That didn’t turn out because I couldn’t acquire geosmin oil in Australia. I tried soaking cucumber in water and spraying it into the air but that didn’t do much.

I think the surprise was when the dish was brought out. Many comments were about how much of a shame it would be to dig into the dish. I think the acidity of the dish surprised my guests, as they didn’t expect it from a white-looking sauce.

This dish was layers in the sense that it was literally built in layers. The dehydrated olives and roasted pecans worked together to give the dish a meaty taste that cuts away the acidity. The vegetables were blanched and were deep green, but yet still were hard enough to be slightly crunchy. There was a good variety of texture in the dish, and I quote one of my guests, “it’s growing on me”.

Main Course: Chilli con Carne with Corn Bread

I’ve made this chilli con carne many many times. I feel like it’s one of the best dishes I have made. I also didn’t have many opportunities to cook this, since the minimum amount of people this recipe works for is 8, and it’s quite hard to scale the recipe down[2].

Another consideration I had in mind when designing the menu was that almost all the food had to be cooked before hand. I had held a number of dinner parties in the past to know that I don’t want to be in the kitchen when my guests are in the dining room. A food that is cooked for the masses would be great.

Chilli con carne was chosen because it would also form part of the narrative – leaving the Old World (Europe) and entering the Americas. And really, I DO think that there isn’t a better dish to represent BOTH Americas. The dish was invented in the United States, but clearly with influences from down south.

Corn bread was also chosen because it pretty much originated from there. My corn bread was a little different from most. You see, I love mozarella cheese with my chilli con carne. It’s just fantastic. So when making my corn bread, I stuffed a bocconcini ball into the middle just before baking. This led to an eruption of cheese as it bakes.

Recipe

Playing It Out in Real Life

The music I had chosen was Con Mi Guaguanco (from Dexter’s OST). I didn’t have much exposure to South American music, so I hooked on to the closest thing I knew – OST from Dexter, which featured a lot of Cuban-esque music without lyrics. The playlist eventually steered into creepy Dexter music, which led to some hilarious comments about serial killers and Hannibal.

I had originally wanted to heat up the room as we entered this phase of the dinner party. Nature was plotting against me. It turned out if I used multiple heaters, the circuit breaker would trip. So that plan was abandoned. The scent was smoke (from burning some bamboo sticks in the kitchen).

The crowning glory of this dish was when one of my guests leaned in and told me “I know where you’re going with this dish, Chewxy”. I probed a bit further and he told me that the dish, with its smokiness, Jack Daniels sweetness and hot chilli evoked emotions of what America was. In particular, he said, it evoked images of cowboys. Mission accomplished. I was happy.

The dish itself tasted good. The beans, when they finally break open in the mouth, tasted of colas. There were many layers to the flavours of this dish – starting from the immediate hit of chilli, then the acidity of the tomatoes, and followed by the bittersweetness of the JD. It is then completed with a smoky aftertaste. I liked it quite a lot, though my partner found it more bitter than bittersweet. The majority of the comments about the dish was that it was kinda mild. I had actually decided to tone down the heat of the dish because I knew one of my guests didn’t do well with spicy food.

Dénouement: A Glass Of Milk

I had expected the heat to get the better of my guests, so I designed this dish as a conclusion of sorts to the main course. Of course, from the Americas, specifically the United States, the next destination can only be something really cold – outer space.

The theme was travelling around Planet Earth, as well as layers. The dish had to satisfy both themes AND be functional enough to conclude the main course. The answer was to cool the palate, making outer space an obvious choice (the other choice was antarctica, but eh, it’s hard to make penguins). We know that milk cools the mouth really well after spicy food because capsaicin dissolves in fats. Other things that evokes emotion of cooling are cucumbers and melons – cold fruits and vegetables.

So why not a cucumber flavoured milk? But what of the layers? Cucumber flavoured milk is all that, but it’s just a single layer. Then I put two and two together.

Mention milk in outer space, and you’ll almost immediately get “Aunt Beru’s Blue Milk” as a response. Indeed, that’s kinda the line of thought. Aunt Beru’s blue milk is highly associative with outer space adventures (Star Wars for those who didn’t get the reference). And the best part is, nobody knows what Aunt Beru’s blue milk tasted like, and so I was free to imagine how it would taste like.

What if Aunt Beru’s Blue Milk had changing flavours? One minute it was cucumber, and the next minute it would taste like bubblegum, or hamburgers, or something.

Playing It Out in Real Life

For this portion of the meal, the music was changed to the Binary Sunset theme from the Star Wars: Episode IV OST. In my mind, that’s one of the most powerful music I have associated with outer space and adventure and magic [3]. I also opened the windows and doors to air the house to cool everything down, though that didn’t have much of an effect.

I think the best part of the meal for me was when one of my guest expressed surprise when the flavours changed. This dish had been nearly a failure. I had originally wanted to impart the flavours of my favourite sandwich – a cucumber sandwich – the layers would be: cucumber, butter, toast. However, a series of mishaps happened and I had only the cucumber portion set out. A last minute change was instead of fancier (and weirder) flavours like hamburger, or roast pork, I’d go with cucumber, followed by melon. And even that was a bit of a failure. I had accidentally left the rind of the melon into the milk to infuse, and it made the milk a little bitter. The last stuff up was I messed up my ratios, and instead of the cucumber infused milk being the denser milk, it turned out to be the less dense milk.

Which was why I was absolutely delighted when my guests slowly, one by one realized that the blue milk had changed flavours. I loved the magic. It was amazing to watch as their eyes widen and realized it went from one green flavour to another. Of course in retrospect, the more drastic the flavours were, the better the effect would have been.

Dessert: Thai Sticky Rice with Mango (Khao Niao Ma Muang)

The dessert came next. And it had to top the magic from the previous dish. One of the best things to do would be to disguise a dish as another dish. And this dish in fact is also one that I’ve been dying to do – it’s Thai sticky rice with mango, except the plan was to make it look like a fried egg on rice.

Fried egg on white rice is amazing, especially if you pour a small amount of soy sauce on the egg. That was the concept I had in mind – the egg white would be made of coconut milk, the yolk made out of mango, and the soy sauce would actually be a gula Melaka syrup or caramel.

This dish also ties together a locale – Australasia. And also, it fits the layers theme – in more than one way. The perceptive layering was my main objective – I wanted my guests to perceive this dish as one thing, and realize it’s another.

It was the last proper dish, and had to set a memory. Unfortunately it didn’t go so well.

Recipe

Playing It Out in Real Life

If I had to do it again, I’d play Only For Love from The Banquet, a 2006 Chinese movie. There is a haunting beauty and sadness about that piece. But I had too, a rule about music without lyrics. Add to that the hustle of actually having to cook the “egg whites” for each dish individually, I didn’t actually manage to change the music that was playing.

Encouraged by the success of the amuse bouche, I tried to get my guests to make their own “egg yolks”. That didn’t go too well. When the ugly secrets are revealed, the magic is lost. There wasn’t as much magic or amazement when I completed the dish.

The dish itself too had some problems. It was under salted (salting the dish was part of the theatrics originally), and the mango wasn’t very sweet (I had been on a no-sugar diet for months before this, and I had thought it was very sweet).

Nonetheless, I think the reaction to the dish was still one of general (albeit muted) surprise – I think my guests had some difficulties wrapping their heads around the idea of coconut milk that was solid when it was hot, but liquid when cooled.

It was a very muted affair, my dessert. The recipe above has been updated with additional salt and sugar. Indeed, the backup cake was much better than this dish.

Digestif: Coffee and Dates

And so we enter the last parts of the dinner party. The plan was to serve them a glass of cold-dripped coffee, and dates. It would be the Africa portion of the night – the last continent we had yet to touch. The original coffee I had planned to serve was an Ethiopian Yirgacheffe. But a week before the dinner party, I stumbled onto some Colombian Geisha, which were rare beans with immense amounts of flavour.

Here’s how the cold drip tower I hacked up looked like (this was taken from a practice run I was doing a few days before the dinner party):

For me, I really loved the Geisha. It was a complex coffee, and bursting with flavours. And the best part was after eating a date, and taking a sip of the coffee again, the taste completely changes. The dates definitely do complement the coffee.

There wasn’t really any more changes to the environment because this is a wind-down course. We wound down over good tasty coffee and eventually moved on to Baileys on the rocks to wash everything down.

Notes: * indicates the ideal choice from my point of view. † indicates that it was poorly executed on during the dinner party (when paired with *, it means it wasn’t done at all).

The Aftermath

As with all dinner parties, it’s the social interaction that was most interesting. I had went into this dinner party expecting an exchange of ideas – afterall, my guests comprise of a digital advertising account manager, an adops expert , a marketing manager, a web developer, and a googler. Almost all of us had attempted a startup at one point or another. There was bound to be some interesting things that go on.

After the dinner party, we sat down and caught up with each others’ latest news. It was interesting. I had expected the night to be rather mind expanding, but it didn’t really turn out that way. It ended up mostly being a catchup of things that happened in our lives. I was okay with the way it turned out though, because it was actually rather fun. There were a lot of things to be shared and I definitely enjoyed myself. I hope my guests did too.

Key Learnings

Things I learned from running this dinner party:

Do as little cooking as possible during the duration of the dinner party

For complex dishes, starting 2 days ahead of time is NOT ENOUGH

Perform more dry runs

Don’t prepare food when intoxicated – math skills are impaired and you’d most likely get the ratios wrong.

Don’t reveal the secret of the magic too early – if the audience knows the secret, the magic is lost.

I’ll never run a restaurant.

I’ll definitely host another dinner party (been hosting them fairly often since 2011 anyway)

I’ll probably include more alcohol in future dinner parties

[1] At around the same time the idea formed, I found Erin’s blogpost which solidified the idea ↩

[2] Scaling recipes can be quite difficult. I tend to use a weighted percentage-weight scaling for recipes ↩

[3] the others are Also Spracht Zarathustra, the Alien main theme and the Star Trek opening themes, but this one is most obvious ↩

]]>http://blog.chewxy.com/2014/07/30/the-dinner-party-around-the-world/feed/0Alternate Names For TV Showshttp://blog.chewxy.com/2014/06/23/alternate-names-for-tv-shows/
http://blog.chewxy.com/2014/06/23/alternate-names-for-tv-shows/#commentsMon, 23 Jun 2014 10:55:46 +0000http://blog.chewxy.com/?p=2524Continue reading →]]>Earlier this afternoon I mentioned to my partner that we should watch an episode of The Adventure of WASP Girl in the Land of Systemically Biased Sampled Population. Which was of course, Orange is the New Black. She got what show that was immediately though, but I don’t think most people would get it. I then recalled a time when my housemate couldn’t find House of Cards on my home media server because I had named the folder “Derps of Capitol Hill”.

So here’s a list of funny names for TV shows I had over the years:

Show Name

Nickname

Arrow

drop :: Int -> [a] -> [a]

Arrow

Woe is Laurel

Castle

Beckett, Beckett, Beckett

Castle

Caskett

Hannibal

Best Cooking Show on TV

House of Cards

Derps of Capitol Hill

Marvel’s Agents of SHIELD

Agents of Nothing

Orange is the New Black

The Adventures of WASP Girl in the Land of Systemically Biased Sampled Population

Person of Interest

Adventures of Batman and Brother Eye in a Post-Snowden World

Young Justice

Not The Teen Titans

]]>http://blog.chewxy.com/2014/06/23/alternate-names-for-tv-shows/feed/0The Nanjing Taxihttp://blog.chewxy.com/2014/05/30/the-nanjing-taxi/
http://blog.chewxy.com/2014/05/30/the-nanjing-taxi/#commentsThu, 29 May 2014 17:02:46 +0000http://blog.chewxy.com/?p=2396Continue reading →]]>I recently visited China (my writeup was in three parts: Part I, Part II, Part III). An incident of particular note was in a taxi in Nanjing. Picture this: The driver is on the left side of the vehicle. On left edge of the windshield, a Samsung Galaxy Note sits on windscreen mount, connected to the cigar lighter on his right. The cigarette lighter also powers another smaller feature phone which sits on top of his dashboard. Next to the air conditioner vent of the front panel, a walkie talkie sits on its cradle.

We were on a fairly long journey (about 20km ish), and the driver was talking to us, trying to upsell us his services for the whole day. We talked about the local sights, the museums and what nots. Then CRRSSSHHH, an incoming message from the walkie talkie – it was something traffic related. The driver pressed the transmit button on the walkie-talkie, acknowledging the message. Then came a different TCHSSHH sound. A woman’s voice came into hearing. She asked about lunch. The driver leaned forwards, picked up the feature phone, and pressed a button and talked into it, explaining that he was with passengers and his general direction. Upon finishing that conversation, he continued our conversation, picking up from where he left off.

This continued to happen throughout the journey – the driver would be switching between different modes of verbal communications – real life, push to talk, walkie talkie and even his mobile phone. The driver was dealing with 4 different networks at the same time (walkie talkie – some kind of trunked system, since most of it were traffic related; the push-to-talk feature phone – which I assume to be some kind of PTT powered by cellular tech; mobile phone – full duplex radio; and talking with the passengers of the car). That sparked an idea.

Here’s a bit more background. I had developed an interest in trunked radio networks and half-duplex communications when my way-more-accomplished-than-me partner was working as an E&E engineer for the telecomms industry[1]. So I had some good ideas on how CB and trunk radio networks worked.

At the same time I was having a bit of trouble with the VPN the previous night. The solution was simple – I ended up rolling my own VPN on AWS, swapping elastic IPs for the EC2 instance every few hours and updating encryption key everyday. In short, it was a mess.

So the idea was born: what if you could have an ad-hoc (read: P2P) chat network that was private (read: encrypted), and you could juggle different networks at the same time? After a few rounds of refinement of the idea, I started working on the prototype application that night.

How It Got Here

Why P2P

The idea that the program had to be P2P was there since the earliest idea. You see, the way the Internet is structured isn’t quite like the way radio waves work. Radio waves work by broadcasting. A message is sent from the source, and anyone who can receive the radio wave will be able to receive the message. Of course there are stuff like encryption, legally distributed frequencies, and similar things in play to ensure that not everyone gets the message.

The Internet doesn’t work like this. The Internet works by having valid connections between two endpoints. Yes, there are connectionless protocols (IP is one such protocol as is UDP), but they don’t work like radio. A radio transmitter can continuously transmitting even if there were no receivers. Heck, pulsars are nature’s own radio transmitters – they’re essentially transmitting to nobody. UDP comes closest to radio, and is high level enough that I am able to quickly read up and roughly understand it.

I could of course simulate a broadcast system. I had written a number of chat applications before (one of my finest was basically a MUD, but with Second-Life-esque twist to it – this was in the late 90s/early 00s). Most of the chat applications I have ever implemented relied on the fact that there is a need for a server and client. A broadcast system would be easy to simulate with a server and client. I didn’t want that, however. It meant that if I were to productize this idea, it’d be a lot of work for me. I was on holiday and didn’t want to deal with that.

The obvious solution was then a P2P system. Indeed, VOIP systems like Skype use a special form of P2P (with supernodes and all that). I thought I could deal with P2P. In fact, the simplest chat systems are almost always P2P. Of course the simple chat examples that float out there on the Internet almost always only worked with two participants. Add any more than that, and complexity grows (or one of the participant becomes a server).

I clearly didn’t want that either. But I wanted the system to be P2P and distributed – meaning no central server. In the early days of my startup, I wrote a Kademlia based deployment system[2] with Python and 0MQ so that we could deploy it onto AWS or any cloud based system and it would autoconfigure everything by itself. I am sorta familiar with DHTs. So I thought, why not make a DHT-based chat, and to keep the walkie-talkie idea around, turn the idea of client and server on its head?

Why Go

I considered three languages for this project: Python, Go and JavaScript. A day prior to my trip to China, I met with Sylvia and Damon of rtc.io. They are pretty cool people (with technical abilities that far outstrip mine). Normally, writing something like that in JavaScript will not even cross my mind, since you know, I’m pretty vocal about my dislike for JavaScript (and yet, I wrote a book on JavaScript!). But their project was pretty cool, so I thought I’d give it a hack.

Python was considered because it’s the language I like the second most (Go has taken over as my favourite language since a couple of years ago). Also I have been writing Python for close to 10 years already, so I’m exceedingly familiar with Python. Plus I had written a Kademlia-based system twice in Python. That was also a con, since I had implemented it in Python twice, I didn’t want to re-implementing it in Python again.

Ultimately, I chose Go because well, I had all the packages and documentation (thank you godoc). An internet related issue (aka my self-rolled VPN fucked up somewhere along the way) made me unable to access anything from rtc.io, so that was out of the window. I didn’t have some of the required python packages in my laptop (notably 0MQ), so it couldn’t work either.

Why Kademlia?

There were two main reasons for choosing Kademlia: 1. I am familiar with it – and given enough concentration I could write it in a hotel room without Internet access. 2. Broadcast over Kademlia is difficult. When I worked on my Kademlia based deployment system, I tried to make broadcast work. I felt I was close, and I wanted a challenge. After a few years of sitting at the back of my head, I think I figured out how to broadcast over Kademlia.

Broadcast on Kademlia is hard because it’s slow and it’s subject to the classic CAP-theorem-choose-two dilemma. A brute-force approach (also known as flooding) – i.e. going through every single node in the address book and sending a message will also take a long time. Any distributed method of broadcast will almost certainly yield replication. My idea was this: since the address space is partitioned already, instead of sending a message to each remote node individually, send a message to the top two nodes of each bucket (i.e. the closest two nodes to the current node). These two nodes are then individually responsible for sending the message out to their individual buckets. Minimal replication will occur, and is used to signal the end of a process.

Now, that didn’t turn out as expected. Once again, I feel it was close, but other design concerns came forwards and the broadcast-across-Kademlia thing had to take a step back.

There are also other DHT-based systems that could be used. In particular, I considered the use of the Pastry DHT, which would be a good fit for what I have originally had in mind, since broadcasting is a piece of cake[3]. However, I wasn’t too familiar with Pastry. I was far more familiar with Kademlia to be able to implement it without internet access.

On Chatrooms

One feature I knew I wanted was multiple channels[4]. This was indeed inspired by the taxi driver’s crazy ridiculously awesome way of handling multiple conversations at the same time.

The initial design was simple: Connect to a Kademlia network. When broadcasting, broadcast the channel ID along with the message. If the receiver has the channels on the listen list, then accept the message.

This works pretty much like radio. It also has the same flaws radio has: anyone with access to the channel ID will be able to listen in to communications. So the logical answer is encryption, right? Do advanced key-exchange behind the comms channel, and encrypt all messages. Only people with the correct public keys can decrypt the message and read it. Problem solved, right?

Not really. A typical person has about 30 people that are in constant communication. That means for each message, each client will have to attempt to decrypt 30 times. This would be a massive waste of computing power. My back-of-the-envelop calculations also informed me that it would take minutes for the message to propagate to a large-enough network. And this is with taking the best case scenarios of the fallacies of distributed computing in mind. In fact, the whole simulating-radio broadcast idea was terrible. Clearly not good enough.

I also tinkered around with subnets – the idea is that since the Kademlia network automatically rearranges nodes based on their last-contacted recency, channels would be mostly at the top of the buckets. The Kademlia network can hence be partitioned into subnets, and priority would be placed to transmit over the clique. That idea led somewhere but I didn’t have the time to fully implement it. I ended up being too lost in figuring out graph colouring algorithms for another project I had.

Yet another idea I had was multiple DHTs – a client can handle multiple DHTs. This turns out to be a silly idea. If a chatroom contains 5 participants, and only two are online, a third person would have to know either one of their IPs. The solution to this would be to have some sort of authenticating server, which I didn’t want to have. I wanted it entirely P2P.

As always in computing, the solution can be found in caching (leading to cache invalidation as one of two hard things in computer science. The other is naming things, and off-by-one errors). Instead of broadcasting the message across the entire network, the idea evolved into a chatroom like idea instead of a channel-like idea.

The idea for chatrooms is this: Everyone who’s allowed onto a chatroom is given a public key. Using the FIND_VALUE command of the network, the new node searches for machines within the network that has access to the chatroom. Upon success, the new node will contact the node with the same public key, and some sort of challenge question involving crypto is issued. If the new node passes the challenge, then the node with the public key shares information about the room’s participants to the new node.

This solves the problem of having to broadcast and propagate a message throughout an entire Kademlia network, and probably save a few computing cycles of different machines.

Audio??

I started off with this project with great deal of hope of actually simulating a trunked radio network on the Internet using P2P methods. I also like push-to-talk type of thing (half duplex systems in general) – in one of my Python 0MQ talks (this one is the closest to the one I actually gave), I demonstrated live how to build a push-to-talk system with 0MQ.

Unfortunately I spent more time than expected wrangling with PortAudio on OS X. I’ve never been good at writing multimedia software[5]. But I couldn’t quite figure out how to serialize the PortAudio chunks into []byte and get it to be playable at the receiving end. Also, I didn’t have enough resources to delve into the murky world of mp3 and AIFF binary formats. That, and UDP based communications were a hassle. In the end I settled with a text based system.

Maybe one day I’ll actually add the voice thing in.

Overview

So, how does the system work?

Start client

Start UDP listener for incoming chat messages

Bootstrap or connect to a Kademlia network

Start New Chatroom

Register on kademlia that the node is on the chatroom (so that other people can find the chatroom)

Request A Chatroom

Issue FIND_VALUE to Kademlia

Kademlia replies with a remote node that has the chatroom

Request permission to remote node for chatroom

Remote node issues a challenge

Reply challenge with encrypted digest

Remote node verifies encrypted message == challenge message

If verified, remote node sends chatroom information to requester

Accept chatroom information, send hello message to everyone

Once access is given to a chatroom, messages are sent and received freely

If I can summarize in a picture, this is how it’d look like:

The three blue nodes belong to a chatroom. The grey nodes are just part of the network which enables the finding of peers easier. The blue nodes can find one another via the network. Once they have found each other and performed the correct authentication, the picture now looks something like this:

The blue lines are communications outside the Kademlia network. They’re direct P2P connections with one another. Messages are sent directly to each other, bypassing the Kademlia network altogether. Note that the blue lines now form a complete subgraph. That’s what chatrooms essentially are: complete subgraphs. The Kademlia network exists merely to assist in building this complete subgraph.

The Project

Caveats

There are a few caveats. Since I’m not that great a programmer, please do not assume that because RSA is used, and key exchanges are done, it’s secure. In fact, you should treat it as far from secure. My knowledge in distributed systems and network programming and P2P stuff isn’t as great as say Henry Robinson, Peter Maymounkov or Beej. I probably made a lot of errors in my reasoning for a lot of things, and even more in my implementations.

I’ve only ever tested this in a local area network. In fact I would even go so far to say that it’d only work if there are no port forwarding or NAT type of thing happening. I have a multi-router set up at home. When my laptop is connected to the NAT’d router, nothing gets through. I’m quite sure there is something that can be done with regards to the greater internet (UDP hole punching, NAT handling and shit like that), but I haven’t yet implemented them. Perhaps one day.

My code isn’t the most beautiful either. Please forgive the ugliness of my code. I left in a lot of hacky stuff, like panic() everywhere, instead of properly handling the error. I’ll fix that one day. I often imagine myself going through my own code as a third person, and making remarks to my own code. If I were my own code reviewer, I’d have thrown this code back to myself to rewrite.

Using this application is cumbersome. I should probably find some way to make it easier. Currently it’s not even a proper CLI. It’s a super hacked up version of a CLI, with preset commands to connect, and introspect.

Afterthoughts and Lessons Learned

I decided to open source this because I couldn’t figure out a way to productize Nanjing Taxi. I mean, builidng a proper UI and feedback loop is probably quite easy. But to properly bring this to market requires a lot more work. I have to juggle quite a lot more things which requires a lot of my time – applying for jobs[6], working on eyemap.io, or even actually updating my books to the latest version.

It took me quite a while to get this onto a new github repo since I pretty much spent the last week and most of this week trying to salvage yet another drive failure (for the 2nd time in a 12 month span). I also had to fix some of the problems I had found.

I should also have probably used the net/rpc package instead of trying to recreate everything on a low level. Although, it was indeed quite fun to figure these things out on a lower level of abstraction than what I am used to.

I relearned a lot of things with regards to basic network programming – things that I had forgotten. I also learned a lot of new stuff. For example, one of the examples I tinkered with was with UDP multicasting. That didn’t work but I learned quite a bit about multicasting. I also finally got around to playing with PortAudio, but alas no result came of it.

Lastly I discovered that it wasn’t until Go 1.2 that newlines in OS X’s terminals were fixed when fmt.Scanf (or anything that dealt with os.Stdin) was used.

Conclusion

This was a little fun project I threw up in a couple of bored nights in Shanghai and Nanjing. I can see a lot of advantages to having a P2P chat system that is somewhat secure. Alas, I have no resources to properly productize this idea, so I’m releasing it to the open source world. It’s not the best code, nor is it the best system, but it’s a good learning point for me.

I hope you have fun with the project too.

[1] I think she’s more accomplished than I am, given that she’s now working for a certain search engine company while I have tried and failed at least 5 times with that same company, twice within the last 7 months ↩

[2] It was my second time writing a Kademlia based system. The first time I had help from none other than the late aaronsw himself. ↩

[3] Geddit? Pastry, piece of cake? If I have to explain the joke, it’s no longer funny ↩

[4] Also, am I mad or did Go once have something like channels over networking topology? I somewhat recall this because I was doing a lot of 0MQ stuff then ↩

The original story I had in mind repeated many more times. By the time I was writing the third repeat, it felt too repetitive, so I stuck with two repeats, and engineered a minor change to allow for the info dump to happen

The idea for the story originally came to me as I was developing an idea into a product. The idea needed years of compliance testing, and the only way to spring into market is to do 20 odd years of compliance testing in secret. Hence the fantasy of going back in time and starting earlier.

Also, who in the startup world haven’t dreamed of cramming 3 or 4 years worth of R&D into one year? I certainly have

The character’s name was Ellen, because in the original story, she faced gender discrimination when going back in time, which led her to go through a sex change, and changing her name to Alan.

Chekhov’s (particle) Gun and Deusex Ventures originally played a much larger part to the resolution of the story. Originally Deusex Ventures was going to be founded by a much older sex-changed Ellen, who will repeatedly save Ellen’s startup in the last minutes. Chekhov’s Gun would be used to get Ellen out of the Plott Device. These were the two plot devices which I was unable to properly use because it adds too much to the complexity of the story.

Jim Plott’s exposition of the possible future is actually the original story I had in mind

Simone’s entire purpose is to indicate that she is working on lampshading. Also, Simone became Simon in an early version of the story after Ross became Rose.

The original ending I wrote didn’t feature Ellen finding the Plott Device in her bag when she was leaving Rose’s house. It was left rather vague if she was actually hallucinating or not. Part of the original theme was the fallibility of human memory. That was too bleak for me, so I changed it

Why is “Dolphin” a safeword? That’s for me to know and for you to never find out

The Novikov self consistency principle was originally invoked for the story as well.

The original title was 2407 (hence the post slug). There were 24070 iterations of Ellen/Alan that created the McGuffin over the span of 60 years but only 2407 would remember their experiences in the Plott Device.

I also envisioned a number of scenes where red fish would be seen swimming behind the agents who were giving the info-dump to Ellen (geddit? Red herring)

The story originally came to me as I was cleaning the bathroom. I wondered if humans could have been an experiment gone wrong for a consciousness that arose from a network of bacteria. I mean, we know that amoebae are social creatures despite being single-celled organisms, farm for food. What if multicelullar life were a result of farming by other single cellular life?

In fact, I did reference Dictyostelium discoideum, the amoeba that were found to engage in “farming” activities – probably an anachronistic reference by Escher, but whatever pushes the story, I guess

The reason for the Network existing is because, well, individual bacterium do not have thought processes. I needed to give the bacteria a voice. Hence a vague description of a colony-wide Network. It’s to make it sound as if the species as a whole is one consciousness.

The way the Network communicated is the best approximation I could do with the way neurones communicate – by sending out pulses of electricity and neurotransmitters and retransmitting messages. I didn’t want to let on too much about chemical release, so I stuck with the vague word “energy”.

The original species of bacteria were Bacillus. That would have made sense, because the Bacillus genus is one of the oldest, stretching back to before multicellular organisms were there. But at the same time I wanted readers to be able to figure out on their own I was talking about bacteria. So Escherichia coli was chosen instead.

The cloning of Escher the Third was originally added to give a small The-Doctor’s-Daughter-esque twist about the time spent fighting the war. Originally the idea was to show that due to the clones having the same memories of events (but as you know, binary fission carries mutation as well), warping their perception that only a few years had past since, when in reality millions of years had past. That didn’t translate too well.

The “torus shaped” reference was originally there because I wanted to depict the bacteria as having a perception that has a built in understanding of homotopic equivalence – afterall, if you think about it, human beings are pretty much a donut: the two entrances are the mouth and the anus, and they’re connected. Two entrances with a connection between them makes a donut. The back story was the colony had originally cultivated a new kind of multicelular organism that was donut-shaped that eventually evolved into human beings.

I suck at describing binary fission

]]>http://blog.chewxy.com/2014/05/21/meta-for-the-last-two-posts/feed/0The Long Term Planhttp://blog.chewxy.com/2014/05/20/the-long-term-plan/
http://blog.chewxy.com/2014/05/20/the-long-term-plan/#commentsTue, 20 May 2014 01:31:37 +0000http://blog.chewxy.com/?p=2453Continue reading →]]>“Bugger that plan,” Escher spat into the ground. He looked at his troops, positioned around him in a circle.

“Have heart, grandfather. The long term plan, remember?” Escher the third looked up at his grandfather.

Overhead, clear liquid from the chemical weapons used by the enemy rained down in large droplets, threatening to dissolve any organic matter that it came into contact with. Already, a pool of the corrosive liquid is gathering and slowly but surely making its way to the group sitting under the boulder.

“How! How did it come to this! We lost millions of troops just today alone!” Feeling very distraught, Escher sank to the ground. His son and grandson went up to him.

“We knew this would happen. We prepared for this. Get up – father – you gotta lead us” Escher Junior pleaded.

“You know I’m not your father. You’re clones. We’re all clones. We’re nothing but clones. You may have came from me, but we’re all still clones!” Escher’s voice cracked. He was close to giving up the battle.

“Get up! This was planned! We expected this!”. The troops separately called for their leader to regain some confidence.

“No, we never planned for our food source to retaliate! We aped what the Dictyos did, and we went too far! This war has been going on for far too long!”

“Notify the Network, son. I don’t think father is a good leader anymore. We need to take action” Escher Junior gave his son an instruction.

Escher the third separated a small distance away from the group and calmed himself down. Concentrating, Escher sensed a pulse of energy surge from within him and dissipated outwards. Almost immediately, the rest of the group felt the surge of energy. In return, each member of the group surged some amount of energy from within themselves, forming a feedback loop of energies emitted outwards. Reluctantly, even Escher re-transmitted the energy. It would be difficult to overcome aeons of evolution and bioengineering.

This wave of energy would pulsate outwards, and every living creature would feel and react to it. But it’s only the Co-Ly who can interpret this wave as a message. It reads:

Squad leader lost motivation. Under heavy fire. Request instruction.

A few seconds later, Escher the third received his reply from the Network. Every member of the Co-Ly had received the message and have voted accordingly. Despite the increased chatter on the Network of late, the results were clear and the instructions directed to him. The Network had voted. He was the Chosen.

Upon receiving the message from the Network, Trey braced himself. The pain would come. He knew. He had experienced it before. But the sacrifice was necessary, for the survival of the Colony.

Just as the thought emanated from within him, so too did vibrations from the machines deep within Trey. He could feel the wire-like device within him unravel as his midsection bloated outwards. He could feel his body generating and consuming more energy as more skin cells were rapidly forming around the distended midsection.

Soon enough Trey had all but doubled in size lengthwise. It was as if there were two of him stuck together. Then came the split. With a sudden crack and a flash of pain, Trey was back to normal, save for an unsightly scar down his entire body. The new entity flopped around the ground for a bit and then stood up.

“Father”

“Welcome to the world, Escher the Fourth. We’ve got business to do”, Trey said.

“It’s no use! You’ll all end up like me” sneered Escher.

“Let’s face it. Our torus-shaped food source plan was a bust. It may have been a good idea a few years ago to breed something larger and more complex than ourselves as a food source and live on top of them. You all remember that don’t you? We agreed to this – the Network agreed to this plan.”

One by one, the group stirred. They had all received new instructions from the Network. Only Escher is ignoring the message.

“Now they are superior. All we have is our sheer numbers and cloning ability. But their genetic variety turns out to have provided them an advantage. We thought wrong. This wasn’t supposed to happen. They weren’t supposed to develop weapons. Let’s face it, men, we have lost this war.”

Almost no one heard his ramblings. The rest of the troops were preparing to follow their new leader, his son, as voted by the Network.

“OK men. Let’s prepare to move out from underneath this cowardly boulder. We’ll leave this old rambly here.” Escher Junior turned to his father. “Whether you survive is up to you, but we’re moving out,” he spat.

“You have my memories – ” Escher interjected, then looked at the rest of the troops. “You ALL have my memories. So you know this war cannot be won this way. We need a new way”

“Move out!” came the order from Escher Junior. In an orderly fashion, the troops moved out from under the shelter of the boulder.

Presently, a large droplet of clear liquid containing the chemical weapon fell onto the troop, Trey included. He immediately felt the pain – his skin was torn apart by the chemical weapon, its ionizing capabilities led to multiple perforations on Trey’s skin. The perforations caused an imbalance of pressure, and his innards exploded outwards, right into his father’s horrified face.

Very soon too, Escher Junior succumbed to the same fate. So did Escher the Fourth, and the rest of the troops who stood exposed. All this happened within view of Escher. The troops he once led, wiped out by one single use of a chemical weapon. And here he was, sheltered by a natural formation of the landscape.

“Oh well, I guess it’s time to go,” Escher muttered to himself, all alone, as he watched the pool of liquid roll towards him. He resigned to his fate.

***

The woman had just sprayed Lysol on her countertop. She looked at the bottle. “99% bacteria eliminated,” she thought. “I wonder if it does wipe out E.Coli,” she mused as she gave the countertop a wipe down. The thought left her mind as instantaneously as it had entered her mind as she went on with her day.

]]>http://blog.chewxy.com/2014/05/20/the-long-term-plan/feed/0A Fantastic Account of Wanting To Change The World Through Literary Deviceshttp://blog.chewxy.com/2014/05/15/2407/
http://blog.chewxy.com/2014/05/15/2407/#commentsThu, 15 May 2014 13:39:49 +0000http://blog.chewxy.com/?p=2407Continue reading →]]>Ellen McGuffin heaved a heavy sigh as she uncoupled the device from the battery and pocketed it in her lab coat. Wear a lab coat, it’ll make you look more professional and more people will buy into your story, she was told.

Fat lot of help that did, she thought to herself as she walked towards the exit of the garage. She turned her head to give the car one last look, switched off the lights and left the garage for the last time. It was a lovely evening – one worthy of stopping and taking in the sight. Ellen didn’t do that. Her mind was far too clouded by the incidents today. This was her sixteenth time in her attempt to raise funds for her invention, nay her sixteenth failure. She had succeded in closing a seed round a year ago, but tomorrow the burn chart comes to an end. There would be no more future for the device.

She retired to her bedroom – she had shared the house with the rest of her team. They had differing standards of tidiness, and she couldn’t stand the mess the boys had made in the living room, so she found herself more often than not cooped up in her bedroom. Ellen had been bracing this moment for some time now. For a couple months now she had been putting her resume out there, and attending interviews. She had always gotten the “we’ve decided to go with someone who is better suited than you” reply.

It wasn’t that she couldn’t fake her enthusiasm in her interviews. Oh she could do that, but underneath that veneer of confidence and enthusiasm, her interviewers always ferretted out that her interests laid elsewhere – her device. It had always confused her – she didn’t know what exactly the device would turn out to be, but always had this gut feeling that the McGuffin Device, as she had come to lovingly call it, was her true calling. She had many times in her life, gave up on the idea of inventing the device, and yet it always came back to haunt her, lingering at the back of her mind, taunting her for not inventing it.

Ellen played back the day’s event in her mind. She had welcomed the investors, explained how the device worked, and then showed them the working prototype. The response in her memory – one that she understands that is flawed at remembering things – were lukewarm at best. She racked her brain to see what she did wrong and couldn’t find any. Plus, even if she had did wrong, the device that she had invented should be impressive enough. It’d instantly reduce the carbon footprint of the world – given good enough marketing of course. She had even pitched the big picture ideas to the investors. Why couldn’t they see it?

She slouched back, her dead eyes starring at the poster above her desk. It said “A YEAR FROM NOW YOU MAY WISH YOU HAD STARTED TODAY” in an elegant typeface, – probably Gotham or Futura, her mind added. At this point, she really wished she had started earlier – technical and life management skills ranging from the algorithms that would be used in the control systems, to planning skills. Objectively however, she did learn those skills at a very young age. Her upper-middle class background ensured she had all the opportunities. Just as regret was setting in, her eyelids shut with the weight of her perceived failure, and she fell into deep somnolence.

“Ellen! Wake up!” She found herself shaken awake by her team mate. Groggily she sat up from her chair and looked around. Darren Checkhov came to view, looking concerned.

“You’ve got a guest. Wake up now”, Darren repeated.

“You ok? We were supposed to debrief after Deusex left. You just kinda stumbled into your room and fell asleep.”

“Yeah, I’m good. Who’s the guest?”, Ellen asked, rubbing her eyes.

“Dunno. Says he’s got an proposition for you.”

“Ugh, not tonight. Totally not in the mood for it.” Ellen stretched and exited the room and walked towards the living room. Her guest was seated on the sofa, talking – no, attempting to make small talk with the third member of the team, Simone. Simone wasn’t a good socializer, even though Ellen had pushed her to make some changes quite a few times. She noted that Simone was typing away on the keyboard while her guest, dressed in all black, was attempting a conversation, and made a mental note to address that to Simone later. Noticing Ellen approach, her guest rapidly stood up and extended a hand.

“Hi, Jim Plott” said her guest. Ellen took the hand and gave it a good firm handshake, a habit she had forced herself into a few years ago.

“Good to meet you Jim, what can I do for you?”

“Is there somewhere we can talk in private? I have got an interesting proposition for you, and – “, Jim paused and looked around. “the McGuffin Device” he continued after a visual scan found nothing.

“Oh, this?” Ellen removed the device from her lab coat pocket and held it up.

“Yeah. So, can we have a quick chat outside?”

“Sure, lemme check with the team to see if there are any outstanding work first. Simone’s working on the control and shading system for the LAMP stack, right? Darren?” She looked at Darren. He nodded at a oddly shaped plastic piece connected to some wires on the coffee table.

Once outside, Jim reached deep into his jacket pocket and removed a spherical object. It appears to be made of a number of segments and at what Ellen assumed to be the pole of the sphere was a button glowing white. It reminded her of a pumpkin bomb that the Green Goblin of the Spiderman series used as a weapon. That sparked a sense of dread and fear.

“Wait – ”

Jim pushed the button before Ellen could even finish uttering her protestations. A white light emanated from the spherical device and engulfed both Jim and Ellen. She opened her mouth to scream –

And woke up sitting on her bed. It was dark. She reached for her laptop on her bedside table and turned it on. Then she realized something wasn’t quite right. It wasn’t a Macbook Pro. Instead it was the no-brand netbook she had used prior to acquiring the Macbook Pro almost a year ago. She remembered acquiring a second hand Macbook Pro after she had secured her seed round of funding and her netbook died. Very soon however, her experiences had normalized into reality and she dismissed her prior experience as merely a dream.

The next morning, Ellen walked out to her daily team meeting. She was struck with an idea on how to make improvements to the current iteration of the McGuffin device. After some lengthy discussion, they agreed with the new ideas on how the device could be improved, though Ellen couldn’t shake the feeling that she had worked on this improvement before.

*** One Year Later ***

Ellen McGuffin heaved a heavy sigh as she uncoupled the device from the battery and pocketed it in her satchel. Don’t dress up. It’ll make you come across as genuine, and that you know your stuff, she was adviced.

Fat lot of help that did, she thought to herself as she walked towards the exit of the garage. She turned her head to give the car one last look, switched off the lights and left the garage for the last time. It was a lovely evening – one worthy of stopping and taking in the sight. Ellen didn’t do that. Her mind was far too clouded by the incidents today. This was her sixteenth time in her attempt to raise funds for her invention, nay her sixteenth failure. She had succeded in closing a seed round a year ago, but tomorrow the burn chart comes to an end. There would be no more future for the device.

She retired to her bedroom and played back the events of the day. She had welcomed the investors, explained how the device worked, and then showed them the working prototype. The response from her memory, were lukewarm at best. She racked her brain to see what she did wrong and couldn’t find any. Plus, even if she had did wrong, the device that she had invented should be impressive enough. Through several stroke-of-genius ideas, she had pretty much managed to squeeze at least three years worth of R&D into the device within the last year alone. Her effort, she knew, was impressive. Her invention was at least three years ahead of the cutting edge. But the investors were blind to it. Why couldn’t they see it?

She slouched back, her dead eyes starring at the poster above her desk. It said “A YEAR FROM NOW YOU MAY WISH YOU HAD STARTED TODAY” in an elegant typeface, – probably Gotham or Futura, her mind added. At this point, she really wished she had started earlier, but now was not the time for regrets. She needed to relax a little. She reached out into a hidden drawer in her desk and pulled out a small black pen-like device and shook it.

Good, she thought. It was still loaded. She pressed on the tapered top of the device and the plus-sign logo on the device lit up a blue-purple that reminded her of the special blue flowers that her ex-boyfriend Ross used to give her – they had broken up a few months ago because Ellen was quote too busy with her invention unquote. Fiddling with it, the logo turned green and she raised the device to her mouth and took a deep breath from it. She repeated this a few times, and soon enough, her eyelids were heavy, and her thoughts drifted. She fell asleep.

“Ellen! Wake up!” She found herself shaken awake by her team mate. Groggily she sat up from her chair and looked around. Darren Checkhov came to view, looking concerned. He was holding a cylinder of some sort – she recognized it as the firing pin that Checkhov was working on.

“You’ve got a guest. Wake up now”, Darren repeated.

“You ok? We were supposed to debrief after Deusex left. You just kinda stumbled into your room and fell asleep.”

“Yeah, I’m good. Who’s the guest?”, Ellen asked, rubbing her eyes.

“Dunno. Says she’s got an proposition for you.”

“Ugh, not tonight. Totally not in the mood for it.” Ellen stretched, pocketed the vaporizer and quickly exited the room and walked towards the living room. Her guest was seated on the sofa, talking – no, attempting to make small talk with the third member of the team, Simone. Simone was awkward with her conversation, and Ellen could see that she was racking her brains for common topics. Noticing Ellen approach, her guest rapidly stood up and extended a hand.

“Jess Plott, pleased to meet you”

“Good to meet you Jess too, what brings you here?”

“Is there somewhere we can talk in private? I have got an interesting proposition for you, and – “, Jess paused and looked around. “the McGuffin Device” she continued after a visual scan found nothing.

“What about it?” Ellen secretly hoped someone would make an offer and take the terrible invention that had caused her sleepless nights away.

“I represent a group that is interested in you and your device. Can we chat somewhere more private?”

Ellen looked at her team. They responded with quizzical looks.

“Look, we work as a team. What does your group want with the device?”

“Well, it concerns you privately”

“Ellen, we’re good here. I’ve got work to do on the barrell and Simone’s working on the magazine article” Darren piped in.

Once outside, Jess reached deep into her jacket pocket and removed a spherical object. It appears to be made of a number of segments and at what Ellen assumed to be the pole of the sphere was a button glowing white. It reminded her of a pumpkin bomb that the Green Goblin of the Spiderman series used as a weapon. That sparked a sense of dread and fear.

“Wait – ”

Jess pushed the button before Ellen could even finish uttering her protestations. A white light emanated from the spherical device and engulfed both Jess and Ellen. She opened her mouth and screamed.

The white light blurred Ellen’s vision. But soon it became clear that the white light was merely her eyes adjusting to the extremely bright location she was in. She couldn’t really tell where she was. It was as if the room – if it was a room – went on forever. The walls, floor and ceiling – if they were indeed those things – were all bright white. In front of her was a figure. It was however flckering. Amongst the flickers she caught sight of a familiar face – that of Jess Plott.

“Wh-where am I?” Ellen asked.

“Am I dead? Is this a consciousness continuum?” she asked again. The flickering figure in front of her was silent.

It was then she noticed that her body did not move according to the reflexive movements she had expected from her usual experience. She tried moving her arm, but despite her willing, she couldn’t even move her neck to look at her arm, and her arm definitely wasn’t raising to her face level as she had willed it to.

Stuck, a panic began to set in.

“What have you done to me!” Ellen screamed. It was a weird sensation, as her mouth hadn’t moved. But she could hear herself scream.

“You are in the Plott Device” said a voice that sounded like Jess Plott’s. Somewhere in the deepest parts of her memories, something began to stir. She began to remember the voices of Jim Plott. Then she remembered that the voice sounded like Jace Plott’s. And Jade Plott’s. And Jen Plott’s. And Jake Plott’s. And…

As the tidal waves of memory began crashing upon the shores of her mind, she began to be aware that she had be in fact in this situation before.

“Elevated levels of tetrahydrocannabinol detected in subject’s brain,” a disembodied voice boomed overhead. Instinctively Ellen tried to look up, but again her head wouldn’t move.

“She will remember now,” said the figure in front of her, with the combined voices of her memory.

“Ellen, you are in the Plott Device. It functions to move your life forward towards a goal”, said the figure.

“Forward? What goal? My life is in complete shambles. There is no returning from that!” Ellen yelled. Her frustration had been pent up over the number of years she had been working on her invention.

“You have a goal in life. The McGuffin Device.”

“Is this… a time machine?” Ellen asked.

“I’ve experienced this before, haven’t I?” she asked again.

“Yes. And you will experience it an infinite number of times. Until the day that your invention, the McGuffin, is widely accepted by the general population, you will experience this an infinite times more. The Plott Device ensures that you develop the McGuffin”

“Why me?”

“The McGuffin will be your legacy upon the world. It is through the McGuffin that the Plott Device can be built. Can be powered. You have changed the world. That you here indicates that you will achieve your goal. The Plott Device simply keeps you on track. In your less enlightened times, you call it your destiny”

“Which is why memory of the Plott Device is suppressed every time it happens. This time it is different. The cannabinoid levels in your brain is interfering with the memory capabilities of the Plott Device. You will remember, Ellen.”

“What is stopping me from stopping work on the McGuffin device? I really cannot handle this!”

“Nothing. Time can be rewritten. We shall simply disappear. The planet you know and love will simply burn.” the figure said in a rather matter-of-fact way.

“If you subscribe to the multi-universe theory, indeed, in some variations, you do stop working on the McGuffin. And in those scenarios, the world ends with you.”

The gravity of the words hit Ellen like a sack of bricks.

“You’re from the future, right? Why don’t you just give me the McGuffin?”

“Have you heard of the Bootstrap Paradox? The temporal continuum doesn’t allow it to happen. It does allow for leakages of ideas to happen, which is why you were able to perform several years’ worth of R&D into the last year”

“Search your memories. You will also recall ideas being placed throughout your entire life. Every living night of your life, you seem to have no dreams. You now know why.”

“Give me a hint then! If this is Groundhog Year for me, then tell me what will need to change in order to get the device invented”

“The McGuffin will not be invented for a long time more. Where you are in life when you were picked up, you will have a long time to go. You have a lot of personal flaws to clean up too. Your ego, your various complexes. Your insistence on being right. All these need to change.”

“However, Checkhov’s particle gun will play a very important role in the device in the future. As will the machinations of Deusex Ventures.”

“So we’ll get funding from Deusex?”

“No. Time is in flux and can be rewritten. Nothing is set in stone. It is your effort that matters”

“So is this a weed induced hallucination? You are telling me contradictory things”

“Cannabis does not work like this. You are in the Plott Device. Every time you enter the Plott Devices, the times and circumstances change. Which is why you’ve already met an infinite numbers of agents of Plott Device, who are all different versions of the same agent.”

The figure in front of Ellen suddenly stopped flickering and took the form of Jim Plott.

“One version of events happens like this. In ten years you completed development of the McGuffin through the repeat use of the Plott Device. You used the Plott Device to gain rapid market share by retroactively introducing features that your competitors are unable to add, keeping you ahead of the game. You also used the Plott Device to perform secret acceptance tests, so in ten years time you would have had over 60 years worth of trials and test to prove that it is not hazardous.”

“Oh cool”

“That version will likely not come to pass”, said the voice of Jess Plott. The figure now took her form.

“One version of events happens like this. You are removed from the Plott Device, and are later committed to the hospital for various mental health related issues, such as depression and schizophrenia. The McGuffin was never created by you, and the development is stalled for over fifty years.”

“That version will likely not come to pass”, said another voice, which Ellen recognized as Jeff Plott’s.

“One version of evens happens like this -”

“STOP! I WANT OUT! NOW! DOLPHIN! DOLPHIN!” Ellen shouted. All the information was getting to her head and she could feel her brain heat up.

The scenery changed. The white room immediately faded away. Ellen’s eyes quickly adjusted to the dim lights. She could hear music playing in the background, and the soft warm lighting of the room. Despite her vision still being blurry, she recognized it immediately.

She heard a click. And a weight was lifted off from her neck and wrists. Rose, her girlfriend helped her out of the wooden pillory and stocks which held her legs hands and neck in place.

“Are you okay? You safeworded out of a sudden. We’ve barely started.” Ross had a very worried look on her face.

“Sorry. Had a panic attack of sorts – ” Ellen’s memory was fuzzy. Didn’t she have a boyfriend? She knew that this had happened in her past, sorta – but the context of what is past and present no longer made sense to her – which eventually led to the argument and then to them breaking up a few days later. Then the wave hit. She remembered everything from every participation in the Plott Device ever. Things had changed. Ross as an agent in Ellen’s life had been replaced with Rose. Dizzy, she stood up, and put some clothings on.

“Wait, Ellen, where are you going?” Rose asked, tailing Ellen.

Ellen’s head began to clear up as she walked towards the exit of Rose (or was it Ross?)’s house. Along the way she picked up her satchel, and felt a spherical device in it. Peeking inside, she saw the Plott Device. She closed the satchel and opened the door.

Sunlight hit her face as a gentle breeze blew inwards. It gave her a sudden boost of confidence. Ellen reached for Rose’s hand and pulled Rose towards her.

“I’m going to the future, Rose. And you’re coming with me this time”.

END//

]]>http://blog.chewxy.com/2014/05/15/2407/feed/0China Retrospective 2014http://blog.chewxy.com/2014/05/06/china-retrospective-2014/
http://blog.chewxy.com/2014/05/06/china-retrospective-2014/#commentsTue, 06 May 2014 03:26:22 +0000http://blog.chewxy.com/?p=2358Continue reading →]]>TL;DR and Meta – I visited China for the first time. I enjoyed it very much. These are elaborated from notes I took while in China. This is part 3 of a 3 part series on China, concerning impressions about China as a whole. Part 1 concerns my week in Beijing. Part 2 concerns smaller visits to various parts of China.

So, I visited China for the very first time – in essence, looking at my cultural roots. Along the way I have gained some impressions about China, as well as new views on old topics. This blog post summarizes my impressions of my first trip to China.

People. People Everywhere

That was pretty much my first impression of China. And never did it leave my thoughts once. China is really filled with people. It’s people people people everywhere. In the past I had wondered about China’s lack of expansionism. China’s history has always seen China nucleate instead of expand outwards. It was the in the atmosphere of having people everywhere I began to realize one of the reasons for the lack of expansionism. If we take wealth to be the primary reason for expansionism, then capturing the internal market of China alone would be a monumental task. Any expansion outwards would probably not gain the government as much utility as nucleating.

Having a lot of people within an area leads to some implications. Infrastructure in China is huge. Kinda like American-sized everything. You can see and infer that most of the designs were meant for transporting a huge amount of people from point A to point B in the most efficient manner. Everything, from the bank of 8 escalators going up in Nanjing Station to the wide walkways in shopping malls, the design informs the reason for it: keep things moving.

Having a large population also means that keeping public toilets clean is also somewhat of a nightmare – I’ve never actually managed to poop in a Chinese public toilet – it kinda was a bit too disgusting for me. Despite this, the public locations are generally very clean. I took the high speed train a few times in China, and I counted 4 rounds of sweeping and rubbish collection per hour in the train itself. Also, I observed that the public toilets around the West Lake was cleaned about once every hour. The routine makes sense – sweeping and rubbish collection can be concurrently done while the area is being used. Washing toilets is linear process – the toilet has to be shut down for a bit while it’s being cleaned. This causes relatively clean streets and ammenities, but unclean toilets.

Powel, Sheenan and Thomas (2009), Becker, Baudry et al, as well as the likes of Jared Diamond and Matt Ridley have long argued that population density is a major factor in the occurances of innovation. And yet, the Industrial Revolution started in England, not China, despite the fact that the Chinese had been inventing stuff since the earliest of times.

In 1972, economist Mark Elvin came up with a plausible answer. He called it the high level equilibrium trap. In essence, China has so many people, that it was easier to throw people at the problem (you know the old phrase, to throw money at a problem). This caused industries to be efficient enough so that there would be no profit incentives to innovate. I didn’t really buy the premise. After visiting China however, Elvin’s words keep coming back to haunt me. It’s not difficult to see that it’s far cheaper to throw people at the problem than to innovate solutions in China.

Technology

Computers and advanced machinery, however, have made humans quite replaceable. Programmer hours do not scale linearly with the quantity of work produced, nor does it scale linearly with the efficiencies gained. In the age of the knowledge worker, the old way of putting more people on the job to solve a problem is slowly evaporating away, and the Chinese seem to know that.

Here’s a funny annecdote. I was on the subway in Nanjing. At around a station called ruanjian dadao (lit: Software Avenue), a couple of Chinese geeks walked in. You could tell they were probably computer programmers as they fit the stereotype very well. One of them was holding a can of energy drink (of sorts, it’s a Chinese energy drink). Both were bespectacled and for a lack of better words, clumsily dressed. I was standing just in front of the door, and it just happened during that day I was wearing a black Golang t-shirt, complete with the Golang gopher. They saw my shirt, our eyes met, and we nodded at each other silently, acknowledging each other’s presence. This incident stuck in my mind because of the sheer amounts of coincidences (also, why does Nanjing have a station called Software Avenue??)

It wasn’t until I came back to Sydney that I realized that Go is big in China (as is… Erlang). In fact, tech itself is big in China. Everyone everywhere in China uses a smartphone. When I called to make a cancellation, I was instructed to use the website instead, because they no longer used the phone to handle reservations. Heck, even relatively western geeky stuff made its way to the general populace in China. In Shanghai, the lady who sat next to me spent the entire subway journey playing the original 2048 (i.e. the .github.io website) on her phone.

In the west, we see the Chinese as copycats. The truth might be a bit stranger than that. Here’s what I think: the Chinese copy, and mutate a product to fit its population. The mutation to the product is not small mutations (ala Rocket Internet), but big mutations which make the products unrecognizable.

Take WeChat (or Weixin) for example. It’s essentially a WhatsApp clone. Except it does a lot more. It has a follow function to follow friends (remember FriendFeed?), and I have used WeChat to find food (the suggestions were unfortunately all overpriced and really not that great). You could use WeChat to pay for a taxi. I had wanted to try but doing that would require all sorts of verification and government ID and all that, so no thanks.

I cannot see how a product like WeChat can work in Australia or US. We’re used to having different apps do different things. WeChat is kinda like a Frankenstein monster of apps – from what I could recall, it even has a QR code scanner (what for I have no clue). Does this imply that app designers in China are kinda shite? Not really. It just means that the people of China have different preferences than us.

The People

Speaking of the people of China, during my trip to China, I was continually impressed by the people there. Yes, it’s true that the older generation still spits everywhere, but it was the younger generation that impressed me quite a bit. Specifically, the amount of knowledge the people have. A hotel receptionist impressed me when she mentioned the story of the marriage a Chinese princess called Hang Lipo to the Malaccan Sultan. While in Malay myths the marriage of Hang Lipo to the sultan is a Big Deal (because in part it confers legitimacy to the Malay “empire”), there was no actual historical record of said “princess”. And the Chinese did keep very meticulous records in extreme detail (for example, what colour the Emperor’s poop was).

What was interesting however, was that the Malaccan myth was a very small part of all the myths of the world, and yet she knew the story (we were both derisive over that story). Later over tea, we compared notes on various other myths. It was a bit interesting that her knowledge spanned from the smallest Albanian myths to the stories of the Dreamtime of local aborginal people. She even accurately mentioned that the indegenous people in Australia are not one tribe, but thousands of tribes.

Lest you think it was an isolated incident, I have been repeatedly impressed by the locals and their knowledge of the greater world. For example, I had a taxi driver discuss the design of nuclear power plants in broad strokes. In my notes I had written “[taxi driver] talking about why heavy water is used”. Of course it later transpired that he had actually graduated with a degree in Physics, but chose taxi driving as a career because he will, in his own words, “make more money to survive the city”. I too recall the waitress who spent her time explaining the chemical reactions that causes food to go brown.

Or the couple in Luoyang selling me “fried yoghurt” who took the time to explain how they built their own anti-griddle. They even tried to explain bits of it in English (although I am quite sure they mixed up the words for Oxygen and Nitrogen, unless liquid oxygen was really used, which uh, I don’t think is plausible). Which leads to another thing I noted – at least in Beijing and Shanghai, the younger generation understood English quite well, but don’t speak it well. Kinda like me with Mandarin.

Virtually every younger person I talked to (I didn’t get much of an opportunity to talk to the older people) had a lot of knowledge, and some in widely diverging fields ranging from history to probability to world politics. The words “worldly guy” and “worldly girl” repeatedly appears in my notes – my only regret was that I didn’t bother with their names or a real rapport.

Political Attitude

Given that people in China whom I have met are quite worldly, you’d think they would take some interest in their local politics. I couldn’t be more wrong. By and large, the Chinese people whom I have interacted with are generally politically aware – I’d say much more than the average American[1]. They know that their web is censored. They know that their government isn’t “open” (by western definition and standards). The thing is, they don’t really care.

There is an old, rather racist phrase that reads like a variation this: “Chinese people are Jews of the Orient”, in the sense that Chinese people are motivated mainly by profits and money. Which is sadly kinda true about the political attitude amongst the people whom I had conversations with. The people I talked with generally have that attitude. They don’t really care who’s running the country, they care that their rice bowls are filled.

Combining that attitude with the Chinese culture and you get a weird mix of things. For example, there is a high amount of political slactivism in China. I use the words “slacktivism” because it’s really just that. The Internet culture of the Chinese has led to messageboards filled with political rants and commentary, even on topics the West assumes that is being censored in China (for example, I randomly found a thread dissing Mao Zedong with over a thousand comments). But that’s really the extent of it.

Not that it isn’t causing effects. In fact corruption is heavily tackled by commoners (i.e. non party affiliated people) on the Internet, and it’s known to have brought down many a corrupt official. Heck, in China they even know about their Internet access being censored and monitored. There is even a derogatory term online for anyone perceived to be astroturfing on behalf of the Chinese government – they’re called the “Five Cent Party” (五毛党).

But as mentioned, it’s slacktivism. At dinner I asked a lady and her boyfriend what if people were more interested in being politically active. The answer was not so surprising – they join the Party. This allows them to vote, giving them a political voice.

By way of studying game theory and voting systems, I had sorta already knew this was the case – that democracy actually kinda does exist in modern day China, just not for the masses, but it’s available to those who express an interest in making informed votes. It is in fact the complete opposite of Australia’s electoral system, where voting is compulsory for the population. The way I think of it in China is as such: voting is compulsory for those interested in having a political say. There is a barrier to entry (i.e. joining the Party), so only people who is really truly interested in having a political say can vote.

I don’t think of one system as better than the other – all systems have their flaws and their advantages. I can see why the system works for China – the population is huge, for one. Bringing on full American-style democracy would not be a good idea, in my opinion. But hey, what do I know right?

I should probably stop writing about the political situation in China. I really look forward to visiting China again, and I don’t want my water tables checked, nor do I want to be invited to drink tea[2].

Surveillance and Security

In Nanjing, I witnessed an event of public disorderliness (probably alcohol induced). I was in the middle of a tall escalator on the way up and out of Nanjing station. I heard a commotion at the bottom of the escalator, so I turned my head to have a look at what’s going on. It was a man who was making a scene, loudly scolding everyone. Then I exited the escalator. I went about doing my thing, and when the (presumably) drunkard reached the top of the escalator, he made another scene – this time with police officers. There were four policemen, who after they had enough of the drunkard’s verbal abuse, simply lifted the man – each officer carrying a limb, and put the drunk guy in a police golfcart, and sat on him to shut him up.

What’s the amazing thing? When I exited the escalator, there were no police officers at the exit. Not five minutes later, the (presumably) drunk man was in a golf cart, carted by the local police. The police had responded within an escalator’s ride (it was a fairly long escalator to be fair). It was either a very fast response time, or constant surveillance was in place.

The answer is the latter. Now, I must mention that the police officers I have encountered in China are extremely friendly, even if they have rather weird habits (like smoking while on duty – that one kinda blew my mind a bit) and are kinda gruff and offputting (spitting everywhere). I had a police officer in Luoyang who explained to me when was the best time to capture a picture of the Longmen Grottoes, and how he had come in the wee hours of the morning to enjoy the first light over the river.

Another point of interest in my trip to China is security. If you think the TSA in America is nuts, try having to have your backpack scanned at every subway station. I wear a Pebble watch, which I had set to Sydney time instead of Beijing time. At almost every checkpoint, I’d be pat down, and a security personnel will ask if the thing I have on the wrist is a watch, and why is it not in Beijing time. Towards the end of the trip, I had wisened up, and didn’t carry a backpack nor did I wear my watch.

I asked a friend the reason for the ridiculous amounts of checkpoints, and the answer, rather unsurprisingly was… TERRORISM. A few years back, there were not many security check points. A few well-publicized events of Xinjiang terrorists attacking later, security checkpoints were deployed everywhere – at every subway station, and every place of notable interest.

Stereotype

It would be remiss if I didn’t mention that I had some difficulties with some cognitive biases. Especially with stereotyping a particular ethnicity – the Xinjiang/Hui people in particular. I am not a fan of their religion (or any religion for that matter). And they appear to have caused a lot of hassle in subway stations and places of historical interest that inconvenienced me quite a bit.

In Shanghai, just outside Yuyuan Garden, I caught a Xinjiang man (the hat is a giveaway) with his hand in my pocket. I grabbed his hand and loudly tutted at him and walked away quickly. The ironic thing was the night before, I was advised to stay away from groups on Xinjiang people because it would be more than likely I’d get pickpocketed. Confirmation bias about Xinjiang people as a group of troublemakers set in.

Events like this inform my stereotype of a particular group of people, and I try to actively account for that. In fact, my entire trip to China has been one big wrestle with some cognitive biases I have.

For example, I used to think that China was a relatively backward country. They’re not, but the Gini coefficient is quite high though, which would account for the perception that China is backwards. I am also aware because my perception is thus framed, the expectations were low, and hence many things exceed expectations.

But perhaps the biggest mental hurdle for me was the fact that I constantly had to judge by double standards. I learned pretty quick that in China, if I were to judge the actions of people based on the standards I am used to (standards of not spitting on the ground for example), I was going to have a miserable time. The solution was simple – judge the actions based on their standards instead. Which is easier said than done, to be honest. A lot of mental gymnastics needed to be done to achieve that.

Being conscious about cognitive biases did lead to some interesting and albeit dangerous thoughts though. For example, what if there is a statistical justification for stereotyping? I did some back of the envelop calculations for statistical justification, taking into account fictionalized base rates (because data is hard to come by). It does lead to some serious thinking about ethics and the like.

Culture

I think having a concept of a shared historical past culture with the Chinese people as a whole did help a lot. It’s often said that East-Asiatic cultures are more collectivistic than individualistic. And I think this is the first time I’ve experienced it in a long time (the other time I experienced it was my first time in Japan).

When I visited the Forbidden City, there were security guards outside the gates, standing in a line. Some were uniformed, and some weren’t. Out of curiosity, I asked one of the young men standing guard about the uniforms. It transpired that those uniformed guards are on duty, while those ununiformed guards were youth volunteers.

In Luoyang I witnessed another more interesting form of volunteering. Driving past an intersection, I saw a lady wearing a vest that says “volunteer traffic controller” waving a flag and directing traffic. I asked the taxi driver if this was a common thing, and it turns out yes, it was.

A more cynical version of me would say this was the result of Communist thinking/propaganda. However, thinking about it, this community spirit is really more Confucian in nature than it is Communist in nature. I mean, the South Koreans volunteered their own personal treasury of gold to bail out the government in 1998. Even the “propaganda” posters[3] in China by the government appeals to traditional Chinese values, which are mostly centered around the family unit and society instead of country or religion (which is far more common in the West).

In fact, I would say the movie Hero accurately describes how I feel about Chinese culture. Caution: A generalization is being made. In general, Chinese culture is all about the Long View. It’s a culture which sees itself existing 10000 years from now. After I came back from China, I had a rewatch of Hero. I disagree quite vehemently with the translation of 天下 to “Our Land”. Visiting China, you get the idea that 天下 is all encompassing, not just a country. If you have a long view of things, even countries become meaningless things. The long term goal makes all short term losses acceptable. It can be pretty unnerving to be exposed to such a culture.

Things I Wasn’t Prepared For In This Trip

I did a lot of homework prior to this trip – even more so than what I usually do. I had an interest in Chinese history (why shouldn’t I, I’m ethnically Chinese, and also, Chinese history is one of the few civilizations if not the only to have a continuous recorded history that goes back more than 5000 years[4]). In fact, I did so much homework on Chinese history, that I forgot to do homework on travel. I was thoroughly misinformed, that you can survive on 500 RMB in Beijing for a week. I was wrong and led to some quite awkward moments with my travel companions regarding money.

Another thing I didn’t do my homework on was the amount of walking required. I am used to walking around the CBD of various cities in the world. China just takes that walking and scales it out. There was so much walking I feel that I should have prepared more – exercised a bit more and stretched my muscles a lot more. Walking from one end of the train station to the other can be rather tiring when you’re carrying a backpack with a laptop in it, especially when the train station is airport sized. Thankfully I brought a pair of great running shoes, but even then I still ended up with blisters on my feet. Bicycles didn’t help much either because it’s still leg work.

Preparation For The Trip

Before I left to China, I did quite a bit of research into the areas I was interested in – mainly the Tang and Song dynasties, and maybe a bit of the Qing dynasty. I was aware of the lore and wanted to supplement my knowledge of the local lores and legends with something more substantial. Here’s a list of things I recommend reading/watching before going to China. Some of these books or media are big and hard to chew through, so take your time with it:

China History Podcast – one of the best podcasts out there for Chinese history. And it’s in English. It is simply phenomenal. Despite me hating podcasts, I’ve been hooked on this. I just wish there were text transcriptions instead of godawfully clunky audio podcasts.

The Pattern of the Chinese Past – Perhaps one of the most important books I’ve read on the topic of the historical macroeconomics of China. Reading this gave me an anthropological understanding of the myths and lore I already knew.

Sex, Law, and Society in Late Imperial China – I bought this book by error. I thought it pertained to the Tang dynasty, which was the most open period of all times in China’s history – which was the bits of Chinese history I was interested in. This book is about the latter three dynasties: Yuan, Ming and Qing. Nonetheless, I did find this book interesting as well. It’s very very well researched, but the way it’s written doesn’t rub me the right way. It made me feel a bit uneasy at times. I’m curious about the author’s book on prostitution markets in ancient Japan, but my brain feels like it needs a cleansing first.

Hero – Yes, that movie starring Jet Li. I think it’s an important movie because it gives insight to what Chinese culture is really in regards to.

上下五千年 – My dad has this book (or books?). I think I am ready to read it now. It’s in Chinese, so it’s kinda hard to read. I might get the comic version instead.

[1] I know it’s non-sequitor but hey every political op-ed I’ve read is full of non-sequitors ↩

[2] If this confused you, it confused me too, until a friend explained that to get one’s “water tables checked” (查水表) or to be “invited to drink tea” is China’s Internet slang for being arrested/investigated for posting “unharmonious” content on the Internet ↩

[3] I am not sure what to call this, it’s not really propaganda in the sense that it doesn’t promote the Communist Party, but rather promotes 文明, or a sense of cultured habits ↩

[4] Well, 5000 years of record keeping is a subject of academic debate, but let’s leave it at that ↩