The Bureaucracy of Automatons

An introduction to the notes on Confucian Software.

Software and the Sage

Among the many dissimilarities between software and gentlemen of the classical Chinese Spring and Autumn Period, two in particular stand out. One existed in a pre-scientific feudal society on an agricultural technological and economic base, and the other presupposes the scientific method and a modern (or post-modern) industrial base. Secondly, the concept of virtue or potency (德) is central to The Analects, but software artifacts are, in our day and age, non-sentient. Morality requires some degree of self-awareness – of consciousness – and so software does not itself practice virtue any more than a spoon or a lawnmower.

The immediate relevance, for a developer, of the Analects, are the two other grand concerns of Confucius, which are existential fundaments of software. These are names (名), and the rites (礼).

Continue reading

Advertisements

VII.1 Reuse

子日,述而不作,信而好古,窃比于我老彭. – 论语 七:一

The Master said, ‘I transmit but do not innovate; I am truthful in what I say and devoted to antiquity. I venture to compare myself to your Old P’eng.’ – Analects VII.1 (Lau)

Before contemplating the process implications of this radically static statement, let’s note that from the perspective of designed code itself, it is always true. Code transforms and transmits information. This is the garbage-in garbage-out principle. Designed code (not genetic or evolved code) does not innovate.

Backups of the user directory for the Analects’ source control repository are, alas, lost to antiquity, and though many sophisticated data recovery techniques have been tried, with some success, none have yielded the identity of Old P’eng. Our ignorance of him highlights our relationship with Confucius and with any classical tradition. To us, Confucius founded a philosophical school, but in his own words he merely continued a tradition that we can see indirectly, if at all.

Scholarly consensus is that Confucius is deliberately overstating his lack of innovation for reasons of rhetoric or modesty (see eg DC Lau, AC Graham, or just wikipedia on this verse). Nevertheless the verse is considered pivotal in understanding Confucius’ traditionalism and conservatism in a time of extraordinary violence and social change.

Existing solutions are useful in at least two ways. 

Firstly they may capture unintuitive theoretical results in accessible ways. Many algorithm design and data structure results are now in this category, such as sorting algorithms and efficient concurrent maps (eg the Java 6 lock free implementation of java.util.ConcurrentHashMap). The formal scientific characterization of such solutions in terms of, say, algorithmic complexity and performance benchmarks  make computer theoretic literacy crucial. Programmers will be unlikely to understand the derivation by reading the code, so they must be able to read the documentation. 

Secondly they may capture highly specific details of the environment and robust solutions to managing it. This will include successful workarounds for under-specified elements of protocols, or flat-out incorrect but popular implementations. Any user of say Ruby on Rails or Tomcat takes advantage of this kind of reuse. Consider too the domain specific details and tolerances of a fly-by-wire control system for a particular make and model of plane.

These two kinds of reuse may be contrived to lie on a spectrum, but I’ve chosen to distinguish them here for their correspondence to two different categories of knowledge – logos and metis. In classical Greek epistemology logos is theoretic universal knowledge and metis is hard won cunning, “feel”, or craft knowledge (as an aspect of techne, craft knowledge and theory). James C. Scott describes the Greek hero Odysseus, surgeons and maritime pilots as all relying on metis (Seeing Like A State). Scott also makes the connection between traditional knowledge – which is particular and tied to a society and geography – and common law conservatism in the tradition of Edmund Burke and Michael Oakeshott.

Confucius is claimed as a kind of Burkean conservative, for instance, by James Kalb. Both Confucius and Burke grew up in societies with small literate elites and large impoverished peasantries. They both share senses of the worth of settled convention, the importance of teaching and the literary canon, a paternalistic affection for heredity power, and a sympathy for the welfare of everyday people.  Neither are they reactionaries, but welcome improvement at a humane pace (IX.3).

Seeing Burke and Confucius as similar is not mainstream and deserves a dedicated analysis of its own. (My searches revealed more extant work linking both of them individually to Wittgenstein than to each other, but pointers are always welcome.) In a comprehensive entry for Burke in the Stanford Encyclopedia of Philosophy, Ian Harris argues that despite being more often claimed by the right wing, he does not have a clear modern partisan successor. Nevertheless, distinguished scholars like DC Lau or AC Graham stay well clear of Western political comparisons, while happily comparing classical Chinese figures with Western philosophers. 

Unusually, a software library, and all the hard won craft knowledge that comes with it, can be imported into another with extraordinary ease when compared to other forms of craft knowledge. A pilot is of little advantage outside his home port, and Ruby on Rails is of little use for 3D rendering, but in software we can copy the pilot and use him on innumerable ships entering that port. We can also ultimately read the source code to Ruby on Rails and determine how it tolerates the idiosyncrasies of particular browsers and servers. This is because all code is built on a formal information substrate – the computational medium. (This is Harrison Ainsworth’s term and his note on reuse provided a number of the connections in this post.)

Not all craft knowledge of a codebase is encapsulated in the codebase. There are particularities of the install, workaround scripts, configuration, scheduled jobs and so on, but these are ultimately digital artifacts easily included within a slightly broader view of what a codebase is (this latter is a premise of DevOps and for anyone serious about a controlled environment). More problematically, there are conventions of use, design choices, oral traditions of “check here when you change there”, and so on. At the limit, all codebases are incomplete. They depend on co-texts, results and knowledge of the domain that need not be encoded. An air traffic control system does not need a textbook description of Bernoulli’s Principle.

Burke and Scott argue that in an established society important, non-obvious, traditional knowledge is captured in social conventions and established practice, and the practice cannot be simplified without a loss of valuable situational knowledge. Scott additionally points out that such an environment is very difficult for an outsider to navigate and there are strong motivations for central political power to apply simplifications to it.

Yet highly particular, ‘local’ code that requires hands on experience and knowledge of accompanying conventions most frequently has another name in software development: bad. Or: spaghetti. Or: legacy. The sentiment is well captured in Qi’s koan on fear, even if it does riff off an opposing classical Chinese tradition. (In Confucian terms we might note the building is not harmonious.)

In No Silver Bullet, Brooks distinguishes accidental and inherent complexity, with the latter being an attribute of the underlying problem rather than any specific software or hardware implementation. Complexity due to poor or improvable design is always accidental; that due to the problem domain is by definition inherent.

An aesthetic sense of good or poor design becomes crucial when pursuing aggressive reuse (VII.14). Without it you will simply perpetuate junk.

Having argued the link between conservatism and software reuse, it is worth being a little more precise about flavours of conservatism. William F. Buckley famously described it as that which “stands athwart history, yelling Stop, at a time when no one is inclined to do so, or to have much patience with those who so urge it.” Despite its partisan origins, this is a good start, as it illustrates certain threads of environmentalism and the idea of heritage listing fall easily under the same banner. ((It is also useful to think of contemporary US Democrats defending Franklin D. Roosevelt’s New Deal, or opposition to changes to Britain’s NHS in this frame.))

In its purest form, this can be “return to a golden age” conservatism. There’s certainly an argument that Confucius would have been happy with a reversion to the society of the Eastern Zhou. We should again temper our interpretation by wondering how much is rhetoric covering adaptation of tradition to new times. In software, certainly, simply reactionary approaches are of little use. Brooks and the founders of eXtreme Programming have both noted that a more effective strategy is to embrace change. Oakeshott argues in On Being Conservative that settings of widespread and enthusiastic change are in particular need of an awareness of the value of what exists now. A traditionalist most often defends the present versus the future, not the past versus the present. This conservative disposition’s usefulness to software is more apparent if taken as an analytic tool rather than an inherent aspect of personality. After all, the greenfield doesn’t exist (see X.18), and any project that pretends to be a greenfield is an interesting lie.

Conservative thought in this vein usually emphasizes working within a tradition and a community – in software we would say platform. This also suggests interesting contours for the breadth of possible reuse; and there are other verses, such as XVI.11, where that might be explored. What is immediately apparent is the narrowness and fragility of an entirely in-house platform due to the smallness of its developer community; and the need for a shared jargon (XIII.3) and perhaps a canon (XVI.13).

Given the corpus of extant code in the form of libraries, to adore antiquity is to know your platform, including its innards, not just thoughtless rote quoting via copy and paste. At this moment in software, to reuse and extend is a greater service than extraneous self-involvement masquerading as innovation.

If you can easily find some code and copy it, you get the result at zero cost. That is an efficiency that cannot be beaten: no amount of programming tool and technique improvements can ever do that. So we want to maximise reuse. – Fred Brooks, No Silver Bullet

VII.14 The joys of music

子在齐闻韶,三月不知肉味,日,不图为乐之至于斯也。– 论语,七:十四

The Master heard the shao in Ch’i and for three months did not notice the taste of the meat he ate. He said, ‘I never dreamt that the joys of music could reach such heights.’ — Analects VII.14 (Lau)

When Ataturk said “There is no revolution without music,” he had a very specific type of music in mind. The founder of modern Turkey had already brought and led the country through extraordinary change, from wars through ways to dress through the structure of government. At least in Andrew Mango’s interpretation, adoption of the European classical music tradition could then stand as a culmination of that national modernization, a sign that Turkey had arrived.

For Confucius, too, music had moral and political weight as well as aesthetic. Harmony was of great importance to him as a political theorist and as a system designer. Different components work together in harmonious co-operation in a well-built system. Confucius saw a well-functioning state working the same way: for example in XII.11, when everyone from the ruler on knows their place in the system, they can work together.

Carol Michaelson and Neil Macgregor link Confucius’ sense of harmony with the grand bronze ceremonial bells of the Spring and Autumn Period 春秋时代. These were large, expensive, technically sophisticated objects, only within the reach of a lord of a state. We can even imagine this institutional sound being the rather austere music Confucius so enjoyed, though it could have equally been zithers and pan pipes on a more intimate scale.

It’s a very personal, visceral, human reaction captured here, with senses overwhelmed by an aesthetic experience. It shows this reaction to the harmony of a system – a system of instruments in this case – as an intuitive one. It’s also a refined sense. Confucius is, amongst other things, a music critic and a censor, as in XV.11, where he says “Banish the tunes of Cheng” 放郑声远.

This intuitive, trained, sense of how a system is assembled is of great value to a software developer. Kent Beck used the term Code Smell to refer to the sense something could be improved in a piece of software, based on a relatively short aquaintance with the code. Confucians have an auditory metaphor, rather than an olfactory one, but the idea of aesthetic cues for system building coming from non-conscious sources is the same. Code smells focus on the dischordant elements. Conversely, code can sing. The fix is in, everything compiles without warnings, the unit tests and acceptance tests are green, you deploy and run cleanly in production; the joys of software can reach such heights.

[B]elatedly we need to tell you that the musical ensemble would have been a happier mataphor[.] — DeMarco and Lister, Peopleware

VIII.9 Made to follow a path

子日,民可使由之,不可使知之。– 论语 八:九

The Master said, ‘The common people can be made to follow a path but not to understand it.’ — Analects VIII.9 (Lau)

The Analects is addressed to students of government from an aristocratic class (君子, gentlemen). Confucian Software is addressed to software developers, and the fundamental analogy is that the audience is the same: Confucius instructing software developers on becoming gentlemen and sages.

So the differences between gentlemen and the common people are important. We should distinguish the gentleman (who is educated) from the people (who are not) and the small man (小人) who has no understanding or respect. (See Analects XVI:1.)

At first glance this passage is Confucius at his most snobbish and feudal. The people, or the common people (民), can only be driven down a path and are devoid of thought and understanding. This is the same word now used in the People’s Republic of China (中华人民共和国), the word democracy (民主) or all of Sun Yat-sen’s (孙中山) three principles of the people (三民主义). So it can be rather off putting for we moderns.

Indeed, it sounds more like the brutally effective carrot and stick of Lord Shang (商鞅) and the Legalists (法家) than gentle old teacher Kongzi. Passages like this show how the Han dynasty could create the political philosophy of Imperial Confucianism (as John King Fairbank terms it) – the fusion of a Confucian public morality with the real-politikal techniques of Legalism to run the sausage factory of government. The Legalists found just how far you could push realpolitik without public morality when the common people revolted and overthrew the short-lived Qin dynasty (秦朝), which established the Chinese empire, but could not make it endure.

The relationship of the developer to her users via code is that of the scholar official to the people via the bureaucracy. It is also isomorphic to the GUI model view controller pattern.

People Scholar Bureaucracy – Model View Controller

Users walk a path laid out by the code, and beyond a certain point, can take no other.

The code too can be made to follow a path, when we constrain and verify that a path is followed. This is the purpose of testing, to ensure deterministic repeatability. Without testing, there is no engineered path. There is just walking.

When we anthropomorphize software by describing it as thinking, it means we do not have sufficient control on its internals and environment. (By calling the people code we are automatomorphising people as much as we are anthropomorphizing code.) Code cannot think. Once thinking creatures are built on code we should no longer deal with them as code.

Can users be made to think (know, understand)? Ah, you laugh! Feudalism is not so dead after all.

Code certainly cannot be made to think. Nothing can be made to think. And this is also the more generous interpretation of Confucius’ intent. You cannot make the common people  understand a path, you can only lead them to understanding. The meaning of a software system is generated by this interaction.

Confucius Gordon In The Twenty First Century!

Jiang Qing (蒋庆) is a mainland Chinese scholar who proposes reviving Confucius as part of the Chinese political settlement. There is a good overview of his work from Daniel Bell in NPQ. He notes the revival of Confucius’s fortunes amongst Communist Party cadres, as well as critiques Jiang Qing makes of the current Chinese and Western systems.

Rather than subordinating Confucian values and institutions to democracy as an a priori dictum, they contain a division of labor, with democracy having priority in some areas and meritocracy in others. If it’s about land disputes in rural China, farmers should have a greater say. If it’s about pay and safety disputes, workers should have a greater say. In practice, it means more freedom of speech and association and more representation for workers and farmers in some sort of democratic house.

Jiang, who incidentally shares an English transliteration with Mao’s notorious wife 江青, and is therefore hard to Google for without using Chinese characters, has certainly been on a remarkable intellectual and biographical journey. Xujun Eberlein has provided a good biographical sketch, including his search through intellectual and spiritual traditions from Marxism, Christianity and Buddhism, and detail on his magnum opus, Political Confucianism (《政治儒学》). She also has also posted some a more detailed overview by Wang Rui-Chang and notes on philosophical attitudes to women. Bell also has a good interview with Jiang in Dissent.

I haven’t read Political Confucianism, not just out of native laziness and because I only heard about it last week, but also because it’s patchily available even in Chinese: no English language translation exists. You could call Jiang and his followers Neo-Confucians, except that term is already in use for a group of Song and Ming dynasty thinkers. It was the Neo-Confucians that laid out the obedience-centric doctrine – to government, to parents, to husband – that defined Confucianism until today. This also goes for the New Confucians, the term applied to Neo-Confucian twentieth century thinkers outside the mainland in places like Korea and Taiwan. (Such are the pitfalls of prefixed nomenclature. It has a touch of irony given Confucius declared in Analects XIII, 3 his first priority would be the rectification of names. I have visions of the great teacher giving Modernism, Post-modernism, Neo-classical economics, retro-futurism and Neo-Confucianism several weeks of detention.)

As the Wang Rui-Chang paper points out, Jiang attempts to revive an older, humanistic and individually moral strand of Confucian thought alongside the rather more pessimistic tradition of the Neo-Confucians. Arguably the realpolitik school goes back to the arch-pessimist Xun Zi 荀子, who believed people were inherently evil and needed it taught out of them.

to be fully legitimate, a political power or regime must simultaneously meet three conditions: 1), it must be at one with, or sanctioned by, the holy, transcendental Tao as expressed or implied in the Confucian Scriptures, and as interpreted by the prestigious Confucian Scholars; 2), it must not deviate from the mainstream of the national cultural heritage and break the historical continuity of the nationality; 3), it must comply with the will or endorsement of the common people.

He goes on to quote Edmund Burke; a conservative, moralist figure with a lot in common with Confucius considering they lived 1900 years apart and on opposite sides of the globe.

Skimming over Jiang’s proposal to re-establish Confucianism as a state religion, the key constitutional proposal is of a tricameral legislature, only one of which is directly elected:

The House of Profound Confucians (Tong Ru Yuan) represents the legitimacy of the sacred Way, the House of National Continuity (Guo Ti Yuan) represents the legitimacy of cultural heritage and tradition, and the House of Plebeians (Shu Min Yuan) represents the legitimacy of the common people’s will and desire.

Combining an elected house with two Houses of Lords is obviously not going to light a flame in any democrat’s heart. The obvious parallel here is with the American Tripartite Commission. The existing examples of this sort of thing – in Hong Kong and Iran – are not really encouraging. The emphasis on ethnic or cultural representation rather than geographic and democratic representation also seems both very imperial Chinese and inviting the nastiness of partisan splits on ethnic and cultural lines. Absent having seen the specific arguments Jiang has, and as fun as kicking an absent strawman while he’s down is, let’s just note my general support for the miracle of democracy for now.

What is more striking is the parallel to the golden age of the Westminster system. In 1855 the Northcote-Trevelyan report recommended adoption of a civil service entrance examination as one means of professionalising an inefficient and corrupt bureaucracy. This was inspired in turn by the long history of Chinese imperial examinations for the civil service. Combined with the great Reform bills, by the end of the 19th century the United Kingdom had a democratically elected House of Commons (庶民院) and an aristocratic House of Lords including a number of bishops (国体院). And they relied on a career civil service to advise on, draft and execute policy, which exerted its own conservative cultural influence on the government (统儒院). This constitutional settlement started to change at the end of the 1990s with changes to the Lords and the relationship between the cabinet and civil service, (and in Australia due to the breakdown of ministerial responsibility) but it had a good hundred year run and is by no means finished with. Given it has both historical precedent and cultural suitability, I can’t help but wonder why Jiang didn’t think of it. Perhaps with all that visiting of monasteries, studying of Marxist texts and surviving the Cultural Revolution, he didn’t get much time for repeats of Yes, Minister. If someone has his postal address, I’m happy to send him a copy.