Are we not men?
I enjoy working with the .Net threading model: it is clean and elegant, and it requires an exacting combination of imagination (to conceive of possible problems) and good taste (to design elegant solutions).
I think it was Dijkstra who first deconstructed the nonsense and mystification surrounding threads, by replacing various arcana with a simple metaphor...which resulted from his dedication to correctness and good taste.
It is in working with threads you realize the truth of his saw or maxim: "in computing science, elegance is not a dispensable luxury [as it so often is to managers]: it is a manner of life and death".
Dijkstra puzzled and enraged many American computer scientists, notably John McCarthy of Stanford, the inventor of Lisp, who a while back had a sort of neoconservative overwhelm on the Net. I think this was because on the European continent, where Dijkstra was educated, people take Kant seriously in general higher education.
Kant thought that what makes us human is a necessary excess of knowledge (constituted in the necessary truth of statements about the whole, such as "experience takes place in time") and of moral choice over and above mere sensory input and our biological needs. Whereas American education and society are reductionistic, reducing knowledge to experience or pragmatic utility, and moral choice to a series of rule-followings intended to ensure comfort in time, or for the religious, an afterlife...which in Fundamentalism becomes nothing more than a sort of holiday camp for the blest while us scamps go to the Bad Fire.
Dijsktra, without being ever to my knowledge explicit on the matter, seems to have the view, of "elegance", that satisfaction, both epistemological (in the programming sense, an assurance of correctness *a priori*) and moral (in knowledge, in excess of empirical testing, of correctness). This may have derived from his Continental background.
Back to .Net: thread debugging brings this to the fore.
For as we know, mere hacking combined with "seems to work" testing, and "the user is happy TODAY" pragmatism, often leaves multithreading programs quite buggy and leaky, and as we know the bugs are notoriously not reproducible.
I had an opportunity today to experience this, fortunately in the context of bug prevention. I'd used event handlers in a main module to handle events in an object running in a different thread.
It was then I realized that the event handlers, running in a new thread, were referring to globals in the main module and I was like, oops...even though in the running code, everything was working.
Don't fix it if it ain't broke? Nope. The unconstrained references to objects in the main module was trouble looking to happen.
I realized that psychologically, just as I'd "assumed" that just because the event handlers were in the main module, then of course they'd be running in the main thread, I needed to do more. Recalling another aphorism of hero computer scientist Dijkstra, that we should endeavor to produce not single solutions but classes of solutions in the form of an easily modifiable UR-text, I reflected that I needed to leave an explicit textual record of the fact that the handler code was, as Church Lady would say, "special".
It needed to be OUTSIDE the implicit namespace of the main module lest some bozo (like me) add a reference to a global object without a lock. I therefore moved the guts of all handlers to their own Shared class and added the needed reference as ByVal parameters.
Another tool in dealing with the messiness of threads is formality, or taxonomy.
Early on, I realized I could classify (taxonomize) objects into a coherent and recordable range from "very stateful" to "completely stateless".
"Very stateful" objects have global variables occupying storage at run time and do not lock these objects, at all.
"Completely stateless" objects have no such variables occupying storage.
Intermediate would be an object which references Shared variables such as a sequence number, by which it would keep track of the number of instances, of the object, running, as long as these variables are locked.
As Daniel points out, coding has a moral component which simply cannot be confused with some sort of happy user or performance review.
As programmers, we need (at long last) (for let us not speak falsely now the hour is much too late) an acknowledgement of a Kantian excess of concern OVER AND ABOVE a paycheck and/or an acceptance test in which we take "a priori" satisfaction in code...where in other words we can examine our mental contents, both internally and in the form of written code, and take some satisfaction, again in excess of the observed facts (but not in contradiction, of course).
However, we work in a society committed to empiricism ("just the facts, Ma'am") and to the reductionism of reducing human satisfaction, whether in China here or elsewhere, to economic growth of which our code forms a part but which fails, even according to its biggest fans (such as Francis Fukuyama, author of The End of History and the Last Man), to address human needs for what Fukuyama labels "recognition" but what Kant would call full humanity.
What's very disturbing about Fukuyama is that he reserves "real" recognition for a sort of caste of mega-players, that elite which feeds upon the labor of "the rest of this" and this may mean "real" humanity...in which the desire, let us say, of the midlevel CIA intelligence analyst to report the truth, or the desire, let us say, of the programmer to write bulletproof code, is the ONE demand society cannot meet.
This results in the real nastiness of The Apprentice, for Trump in the show is clearly the only free man. The Apprentices are applying for permission to grow up, to become free men and women because they assume that real freedom is a wad of cash. And, how convenient it is for real managers, who take the Trumpster as a role model, that in fighting for simple justice (such as the racial justice that was withheld from Omarosa last season) that people will act against each other rather than question the ground rules.
On the job, whenever I experience downtime, I work feverishly on reusable tools in excess of management goals, and this has at times got me in hot water...and, it's never gotten me made Employee of Da Month.
This is because later on, during crunch time, I almost always see the need for my own tools.
In fact, this is where the utilities.DLL in the code for my book got started although I rewrote most lines on my own time, before and during the writing of the compiler, in order to have secure title to all the code. In the case of some older modules, I obtained agreement from the employer for who I had written the code.
I was committed to so factoring all functions, right down to "verifying" (in utilities.verify) that a string contains characters from a set of characters, that I simply refused to consider the REAL "reinvention of the wheel", which is failing to factor common functionality.
These concerns are regularly to managers anything on a bad continuum from soldiering, to goofing off, to an almost feminine concern with beauty, to being some sort of nut or something about items not on the agenda.
But like Devo, I say "are we not men?" As such, if we spot a concern, we should be after apprenticeship able to address the concern.
Time and again, I have been personally thanked for creation more or less under the rose. For one client, I developed a parser for stored procedures (using my "lazy parsing" approach of defining the parser to get only the info you need) and Sunil was overjoyed. The manager never heard about my effort, for the very good reason that he would have nixed it, and made Sunil spend hours doing the work by hand.
Recently at my current job, I extended a tool to convert any collection to a string showing its contents in common ASCII characters, reusing a string2Display and object2String toolset I'd published two years ago in Visual Studio...because one of the developers was trying to debug his use of MSO objects, which are in many ways undocumented.
I got a note back saying it was a "dream solution" but managers typically miss these things and demand instead something which can be explained to customers...for a good reason, in most cases.
"So act that your action can be recommended as a universal moral law". If we take the Kantian "categorical imperative" seriously, given the wide and unpredictable use, all over the world, of what we fashion, the conclusion is that no code is acceptable except code written at the height of our capabilities...as Dan says.
If EVERYBODY wrote crap code, data systems would be unusable.
This of course goes against the engineering maxim that we should do "just enough, just enough, for the City", and make "trade offs", not only perfectly acceptable tech tradeoffs but also moral tradeoffs.
It's one thing to trade speed for space. It's another thing to be persuaded to deliver crap code because your boss wants it. And it's quite another to confirm that Saddam Hussein has WMDs because Rumsfeld wants to hear that.
IF the only business relationship was a contract between you and a single boss, then doing what he wants to the letter might still not be moral. But as it is, your responsibility remains larger.
Having said all this, I also realize that so many programmers are just living from contract to contract. As a young man I was astonished to be told by a head-hunter "listen, Ed, if you want to be a consultant, you have to forget all those ideals you spout and you have to be an ANIMAL, like Charley."
Charley was a developer who abused underlings and did exactly "what the user wanted". His code sucked.
I actually had bought the myth that a "consultant" was a valued vizier who would, like a sage of ancient China, add value and wisdom to the team. The head-hunter was giving me the Chicago street reality...which has its own truth and its own falsity. For one thing, it's a complete betrayal of the social and labor ideals for which Chicago people fought at Haymarket and elsewhere, replacing them by a bunch of white collar gangstas who take everything that's not tied down because their grandpappy died of cholera.
"Just enough for the City" produces people who were told to be animals, to be "technical resources", to be objects and who systematically deny that ANY intellectual effort has any worth unless it makes money. My personal experience happens to be that you then medicate the dehumanization on Rush Street, where a bartender quoted Cicero: seeking no more to be men they succeed admirably in being things.
Today I am content to do as much as I can in excess of a paycheck. I may not make a dime on Build Your Own Goddamn .Net Language and Compiler but there is real satisfaction in knowing that Corey and Bill actually read it, and downloaded the code, and understood the code.
Are we not men?
Of course, there are bugs in the 26000 lines of code delivered for Build Your Own Freaking .Net Language and Compiler. Significant features of the Quick Basic language are not implemented because I ran out of time, along with money. When I realized that I could not do the entire language, or write a complete generator of true CLR, I got together with both Dan Appleman and my editor Beth.
I committed to being sure that all the examples in the book ran as advertised, and Dan also tested everything, he being a patient and most kind gentleman.
But Kant didn't say we'd never screw up. We'd only make a "best effort" and this I certainly did. I left a job in late 2003 and lived beyond my means in an executive stay park with full Internet to flat out complete the book.
[I can no longer get a lease in America, it seems: I blew out my credit rating in the 1980s with an undecidable combination of Living Large and supporting children from a former marriage. Dick Cheney says "the American lifestyle is not negotiable", but mine was negotiated away some time ago, it seems. In China I live in a company apartment.]
"Best effort"...hmmm. I read a tirade against "best effort" in Computerworld a few years ago. The author said that managers should only accept "results".
Yeah, whatever: we are now objects, "resources", like microwave ovens and the expectation is that we shall, at the end of history (badly frayed as THAT little deal was in Iraq, where the homes seem to want to make some more history), produce results in a defined context.
All I know is my kids are grown and I can no longer be held hostage, like Kevin Spacey at the start of American Beauty, to any one job.
Are we not men? The starry heavens above and the moral law within tells us we are.
You rock Edward
Killer post Edward - I can't tell you how cool it is to have you blog!
Kantian Excess
A great post, Edward. The idea from Dijkstra that elegance has an inherent value is intriguing. Just last night I watched a Nova special on PBS called "The Elegant Universe". It was about string theory, Einstein's dream of a unified theory, and the history of physics. There were all sorts of mathematicians and physicists interviewed during the two hour special, and the theme of elegance came up again and again. I had just read your post before watching it, so I was acutely aware of it.
There was an underlying assumption that all of the interviewees appeared to share that elegance in and of itself was valuable, was something to be sought after. It came up in several different contexts throughout the program. One of the string theory pioneers, I think it was, said that they knew it was time to abandon one of their lines of research because the formulas they were coming up with were forced--I think he used the words "ugly" and "ponderous." The lack of elegance was a clear indication to them of a corresponding lack of correctness.
From what I know of Dijkstra, his background and general thinking were deeply rooted in mathematics. Perhaps that influenced his recognition of the value of elegance and simplicity. (Is it fair to say that he viewed computer programming as a primarily mathematical activity?) As part of my research for the book version of Principled Programming, I've studied Dijkstra's seminal 1965 paper "Programming Considered as a Human Activity." Dijkstra opens his paper with a quote from George Boole's book An Investigation of the Laws of Thought, which was first published in 1854. The quote comes from a chapter called "On the Conditions of a Perfect Method." Boole writes:
"...a perfect method should not only be an efficient one, as respects the accomplishment of the objects for which it is designed, but should in all its parts and processes manifest a certain unity and harmony."
Thankfully, so that we have things like elegant threading models, Microsoft and Sun have put people in charge of things like .NET, C#, and Java who share this appreciation.
In your post you spin the subject of elegance into the subject of the morality of craftsmanship. There seems to be a great synergy between these two ideas--I'm just not sure what it is yet. Perhaps it is that the striving for elegance (or call it perfection) is what defines the craftsman's imperative. You point out a great irony, though: the marketplace does not necessarily value dedication to craft, or even dedication to durability. A favorite quote from David Pye:
"All the world knows that any good workman feels a responsibility for the durability of what he makes and feels bound at the very least to make the unseen parts of the job as sound as those which are visible; but his concern goes farther than that. Durability is apt to become for him and end in itself quite apart from moral considerations. He is apt to hold that a thing is not made properly unless it is made to last."
But the need to balance the desire for perfection against the moral considerations of doing what one is being paid to do gets in the way. And there's a gray area in the middle there, where you have to ignore to some degree your employer's lack of appreciation for the "unseen parts of the job," if only to protect him from himself (or herself, as the case may be). That said, if we cannot make the necessary compromises, we shouldn't take the money.
Dan
P.S.
Do you think American reductionism could have anything to do with our tendency to take short vacations? ;-)
"Think like a manager, willya!!"
My experience may be noir but it is that "elegance" is ALWAYS rejected in MIS applications.
We have to take a look at the way that in America, "the Market" is a God that stops thinking, because reports coming out of government applications including NASA is that elegance isn't sacrificed in many software teams, while as a whole NASA engineering outside software is abandoning "elegance".
If my software was being depended on by astronauts, I would want it to be elegant UNLESS it were emergency software with time constraints. However,evidence is (cf Diane Vaughan, THE CHALLENGER LAUNCH DECISION) is that the de-emphasis on engineering elegance (expressed in the ugly phrase "think like a manager and not an engineer") was used in prelaunch to make the engineers shut up about their concerns with O-ring problems which caused the Challenger to fail.
Despite the persistence of responsible and humane software teams, a new culture coexists at NASA in which lives are being lost...as they were last year; Diane Vaughan on the board of investigation found that the ugly culture of "think like a manager" persists and caused the 2003 crash.
Nonetheless, managers code the Kantian instinct as skylarking, soldiering and goofing off and silence conversations with reference to a Market.
We have to rush to this Market with our crappy software which itself contradicts the rules of real markets. A fish vendor in Hong Kong will sell only the best fish but we are compelled to bring stinking mackerels.Depression, low self-esteem and substance abuse result.
The problem in programming is the hegemony of laissez faire, about which scientific and technical people don't want to think.
Academics like Dijkstra were silent on this reality because a precondition of their protection from the false god of the Market is this silence, but even Dijkstra, near the end of his life, gave a real barn burner of a talk to incoming freshmen in 1999.
In it, he compared the struggle against globalization (effectively the struggle against laissez faire and Markets as God) to his own country's Eighty Years War against the hegemonic Spanish yoke of the 16th century.
This evening I'll have a bit more to say.


Oops
...some of us are women. And I remark that women become "women", reproductory objects while their men remain boys, playing video games to relax from hacking VB-6 into their forties and beyond. But neither caste in the Apprentice ever gets to become "free men and women" UNLESS they make the cash, or unless they simply say, like me, are we not men. And women. The "male" was long the modal term for "fully human" and it is high time we realized that when we demand freedom, we are not engaged in no zero-sum game.