Saturday, April 19, 2014

What and How

The real work in programming comes from building up massive sets of instruction for the computer to follow blindly. In order to accomplish this, modern programmers rely on a huge number of ready made instruction sets, including the operating system, frameworks, libraries and other large scale infrastructure like databases and web servers. Each one of these technologies comes with an endless number of APIs that provide all of the functional primitives required for interaction.

A modern programmer thus has to learn all sorts of different calling paradigms, protocols, DSLs, formats and other mechanisms in order to get their machines to respond the way that is desired. Fortunately the world wide web provides a seemingly endless collection of examples, reference documents and discussions on utilizing all of this underlying functionality. All a programmer need do is read up on each different collection of functionality and then call it properly. But is that really enough?

Underneath all of the peices are literally billions of lines of code, written over a 30-40 year period. We've pile it so high that it is easy to lose touch with the basic concepts. Programmers can follow examples and call the appropriate functions, but what happens when they don't work as expected? What happens during the corner cases or disruptions? And what happens when the base level of performance given isn't even close to enough?

In order to really get a system to be stable and perform optimally it is not enough to just know 'what' to do with all of these calls and interfaces. You have to really understand what is going on beneath the covers. You can't write code that handles large amounts of memory, if you don't understand virtual memory and paging in the operating system. You can't write caching if you don't understand the frequency of the cached data and how to victimize old entries. You can't push the limits of an RDBMS, if you don't get relations or query optimization. Nor can you do error handling properly if you don't undstand transaction semantics. 

Examples on the Web aren't going to help because they are generally lightweight. Nothing but a full sense of 'how' these things actually work will allow a programmer to correctly utilize these technologies. They can sling them around for small, simple programs, but the big serious jobs require considerable knowledge. 

It's much harder for younger programmers to get a real sense of 'how' things work these days. The technologies have become so complex and so obfuscated that unless you grew up watching them evolve, you can't grok their inner madness. The myths we have about younger programmers being better value for the cost are really predicated on an era of simpler technology. We have surpassed that point now in most of our domains. Slinging together code by essentially concatenating online examples may appear quick, but software is only really 'engineered' when it behaves precisely as the builder expects, and it does this not just for the good days, but also for the very bad ones. Understanding 'how' all this functionality works underneath is unavoidable if you need to build something that is resilant in the real world. 

This complexity shift is quietly underlying the problems that we are having in trying to effective leverage our technologies. Newbie programmers might be able to build quickly, but if the secondary costs of maintaining the system are stratopheric, the value of the system could be turned negative. In our rush to computerize, few paid attention to this, we were too busy heralding the possible benefits of building the next wave of systems, but it seems as if our tunnel vision is quickly catching up with us. 

If computers are really doing what they can, life should be both easier and more precise. That is, our tools should take care of the simple and stupid problems allowing us to focus on higher level concerns. But as anybody out there who has lots of experience with utilizing modern software knows, instead we spend our days bogged down in an endless battle against trivial problems, leaping from silo to silo. Some simple problems have vanished, like copying bits from one machine to the next, but they've been replaced by far more silliness and a plague of partially usable tools.

If we are going to make good on the potential of computers, more people need to really understand 'how' they work under the covers. And as they understand this, they'll be able to craft better pieces that really will simplify our lives, rather than complicate them. Just being able to sling together a larger collection of instructions for a machine does not mean that thoses instructions are good, or even usable. The great mastery in programming is not in being able to code, but rather in knowing what code is helpful and what code causes harm.

Saturday, April 12, 2014

Collective Protection

Over the last few decades of my career, at least half of my working experiences has been really good. They've been great opportunities to solve complex problems, learn new domains and to build things which make people happy. I've been proud of the things I've built even though none of them are famous or made me any significant money. My favorite jobs have all been wrapped in a strong engineering culture; one that strives to always do the right thing, pay attention to the details, avoid politics and focus on getting the best quality possible. 

The other half of my jobs, however, have not been great experiences. Most of them were dominated by horrible people or bad cultures. In those circumstances, you try to do what you can to improve things, but generally the deck has been stacked against you. The only real option is to vote with your feet. To walk away. And I've had to do that many times, although sometimes I wasn't able to escape as early as I wished.

In a really bad environment you get pummelled by what I call 'unqualified decisions'. That is bad choices made by someone in an authority position that doesn't have the background or knowledge to make a good choice. Back in the dotcom boom, when software development became popular it attracted a great deal of outsiders. It still does. These are people with little or no direct experience in serious software development. They know enough to be dangerous and they are usually over-confident enough to be convincing, at least to upper management. Once someone like that takes root in a high enough position, nothing a software developer is going to say will prevent trouble. Since we've never really gelled into a recognized profession, a software developer has less credibility as seen from above, when compared to a non-technical egotistical jerk. And without credibility, any attempt to escalate problems, concerns or prevent outright disasters will fail miserably. There is just nothing you can do if your stakeholders don't take you seriously or want to listen. 

What has often occured in this type of scene is that an increasing number of bad decisions flow downhill, causing bigger problems, which usually spurs on more bad decisions. The trouble makers get aggressive  if the engineers point to the real underlying causes, so the enginners just end up passive and do whatever they are told to do until they get their opportunity to leave. Often it can be really sad as it amounts to the slow and steady death of some previous work. The antagonists don't even catch the blame for their mistakes because they attribute the faults to departing staff. They quite often get away with it, and sometimes even have long running careers hopping from one organization to the next replaying the same sad scenerio. Life is tough.

Besides walking away, I've often wondered if there was some other solution for this type of problem. Obviously if software developers were respected as a profession, their advice and opinions would carry more weight during personality or directional conflicts. But we're an immature industry and we can't even agree on basic standards or titles, let alone some larger knowledge base that's respected as professional. Our industry track record is quite horrible right now. Security breaches, information theft and the rapid erosion of everyone's privacy are all tragedies that are laid at our feet. At its worst, software has killed people, brought down companies and wreaked havoc in the world markets. Most people's home computers are plagued with an endless series of nasty viruses and the one time that we all pulled together to avert a technological calamity, Y2K, it turned out that the problem was grossly over-rated. No wonder people don't trust us. Don't believe that we are professionals. And even think that the whole mess is just some random performance art where we just hack away madly while hoping that it will some how magically work well-enough in the end.

As a 'profession' we are not taken seriously. There are pockets of goodness, but even in many software companies we are still the downtrodden. Crazy coders that whack out instructions that most of our handlers believe that they could do trivially, if only they wanted to spend a little more time on it. That's why we lose so often in personality clashes with these people and that's why so much of what we build these days is reckless crap thrown together in a fraction of the time that would have been needed to do it properly. We even have popular movements that twist our own values to allow for increased micro-management within ever shortening spasms of coding panic. Ideas that might sound fun, but any other sane profession would immediately see it as demeaning and fight against it. We, on the other hand, just keep getting sucked in again and again.

Maybe some day we'll mature into a real profession, but we've actually moved farther away from that during my career. The rapid growth of the dotcom age diluted our respect and the inevitable implosion at the end sealed the deal. Our latest security and privacy debacles aren't helping either. 

Our last ditch idea, the hail Mary pass of any oppressed workforce, is the one that 25 years ago I could never imagine myself suggesting. I'm still not sure I like it, but I don't see any viable alternatives. At the turn of last century, profits and greed were out of control. Blue collar workers were at the mercy of their employers and the world for many was an unhappy place. Robert Reich, in his film Inequality for All, pointed to the decrease in unions as being one of the causes of a shrinking middle class in North America. Not explicitly mentioned, but I think worth noting has been the shift from blue collar jobs to white collar ones. But in the early days of this shift an office job was still seen as being higher status, it didn't intrinsically need the same level of protections as those poor souls being exploited in the factories. 

Much has changed and computers have help to thin the ranks of office workers, replacing them with vast armies of IT workers, both on the development and operations side. If developers get it bad sometimes from crazy non-techies, operations people have it ten times worse. Together we're constructing vast piles of hopelessly tangled complexity. Most of which could have been avoided, if things weren't so disorganized and rushed. 

Learning from the past, pretty much the easiest thing we can do to change our destinies is to unionize. Not for pay or senoirity, but rather to protect ourselves from all of the bad people out there that want to compromise the work down to an unusable quality. If we did go this route, we could create a new IT union that espoused our values and that helped us enforce a code of good conduct for the things that we are creating. If we're being pushed to do bad things, we could appeal to the union to intervene on our behalf. A neutral third-party to arbitrate disputes. We'd have some way of preventing technical debt from swamping the projects. At minimum we'd have access to a broader perspective on what is really current practice, so we could tell right from wrong. Good practice from foolishness. We'd have some way of really standardizing things that wasn't controlled by specific vendors. 

The dark side would be insuring that control doesn't fall into the hands of the wrong people, either vendors or others with self-oriented agendas. We could mitigate against that, by voting for leadership and setting term limits to prevent people from settling in. Big companies would hate the ideal and activity work against it, but if we unite ourself in order to stabilize the profession and build better stuff, even the public would find it hard to be against the idea right now. No doubt the fiercest opposition would be within the ranks of programmers themselves. We're an uncontrollable herd of cats, setting off in every direction possible, so any attempt that is perceived to change that status quo is usually fought heavily. But the idea here is not to reign in coding practices, rather it is to clearly establish reasonable practices and then give the programmers some leverage with their stakeholders to follow those directions if desired. And to lend some type of real authority to inter-programmer disagreements. If one coder has gone way off the map, it would be useful for a project to be able to establish this with some certaincy before it is too late.

Overall I'm still not certain that we don't have other alternatives, but I'm not really aware of any at the moment (comments are welcome). As our societies rely more heavily on computers, the pressure to write crappier stuff has increased. This is a dangerous trend that I know we have to reverse if we really want to leverage our technologies. If I felt our industry was maturing, this type of remedy wouldn't be necessary, but there is little trustworthy evidence that we've improved and considerably more evidence that we've actually degenerated in the face of our mounting complexity. Right now I don't trust most software, and I generally find my self dancing around an endless series of annoying bugs just to get simple things done. I've lost my belief that computers are actually helping us. We need to fix this before it becomes catastrophic.

Sunday, March 2, 2014

Unwinding Complexity

I keep coming back to complexity. It underlies so much of what software developers do for a living. Building a big, sophisticated software system is all about juggling millions of little moving parts. When it goes well the results are organized, stable and hopefully incredibly useful. We strive to build software that people can rely on to make their lives easier.

Building software is like building anything else, except that few people can see the final results. They can see the interface, feel the performance and sense the stability, but rarely can they stand back and appreciate all of the peices. This allows programmers to hide a tremendous amout of dirt in the system from their stakeholders. Given the high expectations and short timeframes, programing has become increasingly about sweeping dirt under the 'rug'. People chase every possible shortcut, even when they know the long-term consequses are dire. Added to those problems, deep analyse of any business reveals lots of skeletons in their closets plus a raft of inefficiencies that have built up over history. Rarely does a development project clean up the mess it finds, rather it just lifts the rug a little higher and sweeps more dirt under it.

Thus the millions of little parts in a project aren't just code and configuration. They are the huge collection of what is essentially artifical complexity, both internally and externally, that has built up over time. There is never enough time to get it cleaned up and reorganized, so the results just contribute to the ever growing organizational backgroud noise that increasingly hampers progress. Of course it is far worse for larger and older organizations, but even little companies have their messes. 

You'd think that a big new development would be the perfect time to clean house but no one ever leaves the time to get it done. No one ever has the energy. The inevitable consequence is that the dirt builds up layer upon layer. Decades go by while the artificial complexity grows into an ever larger Gordian knot. In many ways our rush to automate with software has just made these problems worse. Computers can simplify, but they can more easily obfuscate, and the way we build software these days, the latter is the most frequent occurrence. 

At some point this complexity exceeds the ability of people to deal with it. These days most large non-technical organizations just flitter around that threshold, spending most time barely in control. The natural response we have to this is to try to tighten down the processes, usually with new rules, but these rules just add more rope to the growing knot. The core, all of those skeletons and dirt, almost never gets touched. The ball of complexity just grows larger. This vicious cycle is what facinates me. Surely there is some way to reverse the cycle; to unwind the problems?

In the early days of the Industrial Revolution people were automating manual tasks in a rather ad hoc fashion. New inventions were siloed, and then thrown into use to deal with isolated aspects of the existing labor. In time, people like Henry Ford approached the problem from a broader perspective. They set the stage for modern factory production. Well-organized 'lines' of production that smoothly turn out works of high precision. An individual craftsman may put more skill and care into handcrafting their work, but their individuality shows in the output. Each peice is slightly different. Factories took some 'soul' out of the work, but they brought down the price while increasing the quality. This type of tradeoff is now well-established for a lot of manual work. We know how to mass product things like cell phones and build incredibly sophisticated projects like skyscrappers. In a sense we can use scale to minimize the overall complexity to a point where we can control quality. But all this knowledge onlyapplies to physical things.

Organizational processes and software both share the same property that the are crafted mostly with intellectual effort, not physical effort. The people doing this work these days operate as individual craftsmen, each infusing the output with our own personal stamp. Added to that, we have no way to measure the quality of our intellectual effort on either the small scale or the large one. We don't know if the results have been well-thought out or are half-baked. Anyone can propose an idea to fix a process problem, but there is no way to measure the quality or depth of that idea. It may fix the issues or it may be misguided and make them worse. There is no way to tell.

What I keep wondering about complexity is whether or not it really is possible to unwind it correctly, in a manner that is controlled? Could I, for instance, actually fix some of the deep company problems that I've run across? Not just in the software, but also in the organization?

My best guess is that complexity can be unrolled, and that it can be unrolled in a controlled process that is predictable. I keep thinking about what the equivalent of a factory line might be in this case. The problems roll in on one side and the appropriate thinking rolls out the other. In between, any and all of the necessary intellectual work that needs to be completed is done in an albeit uncreative, but very reliable way. That is, there is some definiable process that one should be apply to intellectual pursuits that eliminates artificial complexity by essentially normalizing the work in thinking to a finite number of defined steps. To clean up the mess, you just need to correctly follow the process. It might be time-consuming, but it is also deterministic. Once the work gets stripped down that way, it should gain intellectual precision but of course it loses that individual touch. It clearly wouldn't be as fun or creative as intellectual work is today, but the results would hopefully make up for that.

Industrialized thinking would be a much larger leap forward than was factory automation. We could, for instance, tidy up our governmental organizations so that for once they operate efficiently and with the least cost. That probably wouldn't decrease our taxes, rather our countries could provide more services at a much higher quality. The costs incrued by a bedraggled bureaucracy would finally be minimized instead of gradually eating more money for less output. Companies would be freed from their internal fog to really be able to compete well in their markets. Costs would be controllable.

I can definitely see how these ideas could change our world, but are they really possible? It could just be that the invisible nature of thinking negates this possibility in the same way that software isn't visible to most people. We can't yet measure what we can't see. It is this indirect link that binds building software to any possible industrial thinking concept. How do you guarantee the quality of intellectual output? You can't just hire anybody for quality control, and you can't even be assured that the people you hire are really seeing things as they truely are. These types of problems already dominate software development.

So far I don't have any decent answers for this problem. Some people might suggest documentation, but I've seen that fail too often as an approach. People don't proof read very well, and when they do it is usually for syntax not concepts like semantics or higher. To industrialize, the output has to be checkable in some way that would occur in an intermediate stage, long before it is too late. It would have to be reliable.

One approach that might have merit is to trace all things backwards. Start at the end and traverse back to the start. That is, if you wanted to simplify something like the laws of a country, you start tracking those that are actually being applied. Where they depend on other laws for properties like consistency or integration those get added into the mix as well. At some point you'll end up with a denormalized tree (dag actuallly) with what's currently in practice. Normalized these relative to a consistent underlying set of principles and the results should hopefully be a considerably smaller sets of 'clean' laws that could effectively replace the older ones. Even from the description you can tell that this whole process sounds rather tedious and boring, but if it really has those qualities and it is complete when done than it is likely the sort of industrialized approach that we are looking for. It might not be as fun as crafting endless new laws on top of each other, but compressing the overall complexity of the legal system would make it far easier for people to get fairer resolutions to their problems. Some lawyers might not be happy about that, but it would benefit society.

Roughly, it took about a hundred years for manual automation to get industrialized and it probably took another one hundred to get to today's level of precision. Cleaning up our disorganizations and ad hoc thinking processes will most likely follow suit at some point in the future. It may take generations, but it is likely inevitable. Until then, the only ways to clean up artificial complexity are time and luck, and pehaps the occasional brilliant insight.