Thursday, June 25, 2009

Never use DLLs for code

Unfortunately, this advice won't be usable to some developers. For folks who are writing Active X controls, you're inherently forced to do exactly this: create a DLL which contains code.

However, for those of us who are not trying to create reusable binaries for use in an environment that requires Active X - which I suspect is still quite a significant audience, DLLs should simply never be used for anything other than localized resources.

The reason is simple: DLLs create DLL hell.

There are multiple layers to the issue of DLL hell, various different unfortunate outcomes and scenarios, all of which should be enough in and of themselves to dissuade you from using them in the first place. But when taken together, it blows my mind that anyone still thinks its a good idea to build them, and use them, ever (unless they're absolutely required by the technology in question).

The only reason they exist, is to create a common library that can be drawn upon by many clients at runtime, thus reducing the memory footprint of all of the running applications that rely upon that common code, since only one copy need be loaded by the OS, and then simply mapped into the address space of each client that was linked against it.

But, the thing is, that was a reasonable need in 1990, when Windows 3.0 was released. Memory was indeed very limited, and even the delay of having to load from disk a separate copy of the DLL for each process was a significant performance hit for the OS. DOS compilers & linkers had been using similar techniques for a few years, to squeeze extra usage out of the very limited address space afforded to the 16 bit programs of the day - such as Borland's Turbo Pascal which was able to map various units into a single shared memory section, swapping out which unit was loaded into that section dynamically, at the control of the parent software. This was a clever way to make larger programs than previously possible, and Microsoft's creation of a built-in model to support that in Windows 3.0 made perfect sense.

However, Its 2009. Nearly two decades later. Memory is dirt cheap. Machines regularly come with 4GB or more. Every single process in the machine can easily afford to have its own copy of every library that it needs to function, and still afford vast amounts of ram to data and disk cache and every other function the machine needs to operate well.

And over the years it has been proven time and time again that software which relies on external DLLs for code is far more fragile than those which do not. Microsoft has even had to retool the OS to explicitly account for the myriad issues surrounding DLLs (side-by-side assemblies), and the reality that software can't easily share common DLLs in practice because of subtle (and sometimes not-so-subtle) incompatibilities between versions of a common DLL. One DLL uses one STL library, and expects map<int> to have a certain size and structure, while another DLL was built using slightly different libraries or compiler or linker options that resulted in a map<int> that is not binary compatible with the other one. Suddenly, moving data between the main program and one or the other of these DLLs can lead to slicing, or to invalid memory access, or simply data corruption at the lowest possible levels, which inevitably leads to bad data or (if you're lucky) crashed applications.

The motivation to use DLLs makes no sense. It has no place in a modern computer. Its a nice theory, a fine vision, but one which in practice is a pile of paper cuts that adds up to a lacerated face... the lacerated face of your customer, bleeding all over and wondering why in the 9 hells they every bought your software!

Simply create static libraries, and link against those. It still gives you a simple way to create and maintain common code amongst multiple projects. It gives you the advantages of writing common code once, and debugging it to the benefit of all client programs. And when you fix or update some aspect of your library, you're updating or fixing every client program that relies upon it. But you're not creating a scenario where testing your software on one system is totally arbitrary and unrelated to how it might perform on another system due to different versions of a common DLL. How can you feel confident that your software is debugged if you don't even know if its the same software you're running on two different machines because whole chunks of your code may be different between the two depending on what other software was loaded on one vs. the other! And how can you rest easy knowing that depending on what other software your customer installs after yours, your software may stop working at any time - suddenly using a new version of a common DLL that you haven't tested against, and may well exhibit new and difficult to diagnose or even recognize bugs.

Again, the motivation for DLLs is long, long antiquated. Its a hang-over from an age long gone. Only the absolutely most anal-retentive amongst us would think that it has any place in today's world of software design and distribution.

DLLs are still great for dynamically loading different resources - dialogs, fonts, etc., at runtime. But they have absolutely no business loading code at runtime. Computers are already complicated enough, and already rely upon too many variables - such as the patch level of the OS itself, and the state of the registry, and so on, with out needlessly adding additional moving parts in the form of core-code that your app needs to run varying over time or machine that you're installed on.

Do yourself and your customers a favor: insulate yourself from DLL Hell - simply do not ever use DLLs for code that you write, and always supply compatible versions of 3rd party DLLs in your application's executable folder with your installs, so that your software will choose those over any other installation's copy of the DLL, and your software therefore will continue to run as correctly a year from now as it did when it was first installed.

Thursday, June 11, 2009

Question: "Do you approve or disapprove of the job President Obama is doing in office?"

Anyone would have been so much better than Bush that its hard to speak out against Obama. In many ways, he's got my approval.

But fundamentally he's more "more of the same" than he is of "change."

The stimulus is going to be an anchor on our economy for at least 20 years, and will become a battle cry of Bush-like people, the neocons and other even more wrong-headed folks, to allow them to tear down the valuable social services and protections for our natural resources, and to further prop up the old-money in this nation.

His continuation of our Imperialistic policies in Iraq and Afghanistan only continues to inculcate the young into Al'Qaeda and similar fundamentalist, reactionary radical organizations, which further erodes our economy and our political clout on the world stage.

He's continuing bush Jr's legacy of covering up our extremely questionable and anti-democratic actions at home and abroad, suppressing the release of evidence of governmental wrongdoing and protecting complicit companies from prosecution.

He's got a tough job, there's no doubt. But principles of freedom, democracy, and accountability should not be negotiable!

Studies have repeatedly shown that throwing money at problems doesn't work. Some ungodly statistics of failure come from throwing cash willy-nilly at things, especially governmental monies where they have only the most tenuous connection to performance and market viability.

Companies founded with Governmental grant money almost always fail, from what I understand. The role of government money should be in pure research and in social services, NOT in financially stable for-profit companies. The two do not mix in anything you might name as 'successful'.

The banks and fat-cats involved in the mortgage debacle and the ensuing stock market crash needed to fail. The market *needed* to correct itself. Those folks should have lost their shirts, pants, fancy boats, planes, and 3rd and 4th homes. The government should be helping out those who are screwed through no fault of their own: folks who have a solid history of being productive people living at the edge of being able to afford
their homes. Loan guarantees, collecting the bad debts even. But the process of throwing money at the problem which more than less has saved those very folks who most deserve to lose everything due to their greed saves them from learning any lessons from their wanton greed and gluttony. They've Learned Nothing.

And because they've learned nothing, and because we, the schmuck tax-payers have paid the bill (and all of us Americans and most of the globe) will continue to pay this debt down for the next 50 years, we've doomed not only ourselves to a horrendous burden for the sake of the wealthiest top 1/2% of the world, but we've further ensured that the lesson that they've learned is: "Be too big to fail, and everyone will bail you out ensuring your reckless gluttony."

American Politics are strife with unbridled greed and self-interest at the expense of the greater whole. Despite current appearances, there have been times in our history and in the history of the world where
politicians are at least embarrassed by their obviously unethical and selfish actions. Times when the masses have recently had an uprising against those in power and humbled them, reminding them that their position of power is predicated upon the people's willingness to go along with the social contract.

That hasn't happened in entirely too long in this nation, and in most of the so called 1st world countries. Politicians have become openly self-serving, openly flaunting their wealth and power and daring anyone to do anything about it. And the sad thing is, we generally don't. We just shrug our shoulders and figure its business as usual and the world is corrupt and always will be.

But change... real change... will come to America, and to Europe. China is rising fast. India is becoming more and more a player. And the damage we are doing to the planet, to our very ability to survive on this rock in space, is rapidly moving towards mass-self-extinction.

The question to my mind is whether we will do as we've always done: shirk our collective responsibilities and ignore the problem for as long as possible (which is often too long), and end up a lot of rotting corpses on an overripe planet? Or will we take the lessons of community and greater good to heart and start acting like we give a damn?

Obama is a good man... in much the same way Bush was a good man... they both honestly believe that they are helping the world. They both have strong ideas as to what the best way to do that is. But Bush Jr. was laughably naive, probably the dumbest individual to hold the office of President of the United States in our entire History; and in the name of loyalty he handed most of the reigns over to Dick Cheney, who was a cynical, power-mongering neocon, who worked unabashedly for his own personal and ideological self-interests and fuck everyone else, in this nation or abroad.

I prefer Obama's form of goodness. I think its closer to honesty, and further from the rampant self-delusion of Bush Jr.

But in the end I strongly fear that the road to hell is being paved with a 1 Trillion dollar money-printing binge which will falsely inflate the economy and allow us all to continue to ignore the looming threats to our very existence.

Global warming - or more accurately: the exponentially accelerating consumption and exploitation of the worlds finite resources polluting the atmosphere to the point that we cannot sustain our very existence, leading to massive, global, cataclysmic extinctions of the Human race, and most higher life-forms from this planet, effectively resetting the clock to the last time of the Dinosaurs demise. We are the comet, the super-volcano, the gamma-ray burst to end life as we know it on this planet. And it is our very predisposition to selfishness and greed that is rapidly becoming our self-undoing.

Economic ruin - which is really just another way of expressing the above: rampant self-interest, consumption of everything that the planet has to offer
, is real and is here. We are trying to live in way that is predicated on the assumption that there is always more basic materials to acquire, in order to make more for less. This is untrue. Its been untrue for ever, but we're rapidly approaching a sort of cliff or wall: where there simply is no more oil, not enough arable soil to produce the food, where we cannot distribute the food we can grow because we no longer have the gasoline to run our engines with, where we simply cannot feed ourselves. And yet we persist in talking about the economy, as though its disconnected from the things we do, from the health of this world. We've long been guilty of pretending that our economy and its exploitative health doesn't directly harm those in so-called 3rd world countries (economic slaves, by any other name). But it doesn't just harm many of our fellow human beings... its harming the very land we stand upon, the air we breath, the water we drink. Its killing us.

I am very glad to be alive. Its an amazing thing to be conscious, to be aware, and to think about how to solve these problems. I am deeply grateful to live this life.

I only wish more of us were willing to put our own narrow, selfish, small-minded, pathetic self-interests aside and think beyond ourselves - to include the entire planet in our sense of "self".

There is so much publicity these days about "think global, act local". But really, just think global. Act global. Without many, many voices... and voices with teeth... we're just going to do more of the same.

Democrats and Republicans are far more alike than different. They use a lot of rhetoric to try to spin the tale that they're opposites, but the truth is they're fraternal twins. Both work for their own self-interests first, then that which keeps them in power, then that which looks like its helpful to the world but which is in fact a thin veneer which serves to help themselves to remain in power, and so on ad nauseum.

American hegemony is the real name of the game to the Democrats and the Republicans. Both remain entrenched
in a view of the world that hasn't been relevant since before WWI. We're not a nation competing with other nations. That's just another illusion that galvanizes the plebes to get behind those in power and assure them of their ability to continue to live in luxury, unquestioned and obedient.

We are one people. One world. One collection of interrelated species of plants, animals, everything that lives and contributes to our existence on this blue-green marble. And without some balance, some dance of interdependent sustainable coexistence we're on a one-way ride to mass extermination, ourselves at the front of the roller-coaster to hell.

When I see on-the-ground true actions which are in alignment with the higher principles of "we're all in it together," and not just give lip-service to these ideals, or even consider them ideals all, but rather necessary survival mechanism, then Obama - or whomever is willing to go the distance - will get my full approval.

We're smart enough to recognize the elephant in the room... but so far we seem to be too lethargic and small minded to fix it.

I hope that our demise is slower than I think it will be, but fast enough that it will genuinely scare every man, woman, and child upon this planet into thinking of something beyond their next meal, next pleasure, next "me me me" moment, so that we can truly move on from being a world dominated by the emotional equivalent of two year-olds, into something more humane.

Will you work with me? Where do you see things going?

Monday, June 1, 2009

Whatever happened to simple?

Have you noticed a trend in the world of Programming, Computer Software, etc., towards making things more complicated than they really are?

I can understand this trend in terms of my experience as a programmer. When I was young, I thought I could pretty much make anything work, and that the time it would take to make it was always fairly short. "I can make that!" Accompanied with "That's not too hard, maybe a few hours of programming!" And time and again, my estimates were way off, and things took much longer than I had anticipated, and often bloomed in ways I had not foreseen, into complexities and code-necessities that required time and thought to handle.

Add to that the typical response of non-programmers to every feature: "Build that! And have it done yesterday!", and one quickly comes to the conclusion that things are harder than they seem, more complex than they ever appear at first blush, and a self-preservation mechanism of "default to more complex / difficult assumptions" so that you have the space and set expectations that might actually match the end-result, keeping yourself out of the cross-hairs of "you're late with X feature" criticism from management.

But on the other hand, I am more and more seeing examples of folks who are either over-compensating for these factors, or who are simply coming at everything from a hyper-conservative position, making it very hard to see the simple in things.

When I began my career, Text-based GUIs were just becoming available. Programs such as Borland's fantastic Turbo series, and PC Tools suite, and Copy II PC. Much of the standard fair of GUIs of today found their genesis (at least from my experience) in these software suites. The edit box, the drop-down menu, the combo-box, the radio button, check box, push button, list box, etc., all began their life to my eyes here. And they were generally very well done. They were consistent, and relatively intuitive. These software suites were by and large simple to use. And it was fairly common to see some new innovation, some slight twist on a theme, that made using them even easier and more powerful, such as begin-typing-jump-to-first-match in a list.

But it seems to me that much of this "try it and find out" mentality has been replaced with a "form a committee to study this issue and do focus groups to determine an interface's value" type approach. And this sort of hype-conservative approach stifles innovation, and to my eyes at least, leads to a sort of dumbed down, least common denominator approach to user interfaces.

I don't know about you, but my experience of "design by committee" is that of a sub-par experience, a sort of group-stupid applied to what should be fairly trivial and obvious decisions. It seems to me that it often invokes the "what color should we paint the shed" sort of arguments, where there shouldn't be this level of discussion and focus on something so trivial.

Essentially, the preconceived notion that every decision is not a trivial one, that there's no such a thing as a simple feature is a dangerous slippery-slope in and of itself. And here's sort of the seminal argument for why a simple feature isn't: How many Microsoft employees does it take to change a lightbulb?

And although I respect that, in fact, most things are more complex than they appear at first blush... I hurts my brain to see such overwhelming odds set up against any sort of trivial and useful innovation as a type-ahead search, or perhaps more compellingly, creating a security model at Microsoft that isn't ... well ... retarded.

Some things are simple. And they need to be left to a single developer's common sense to implement them. Its great to at least review such things on a local level - maybe the group to which that programmer is assigned. But having to have every single minute bit of trivia examined as though type-ahead and security UI are of the same depth of focus and importance is.. crazy. And that way lies stagnation and poor designs.

Two examples come to my mind when I read such blogs. First: Microsoft Vista's "shut down" button, and second: Vista & W7's "Security UI". Someplace I read a Microsoft blogger's scathing post on the process behind the Start-menu's shut-down button. How that it went to multiple committees, was changed over and over during the various stages of Vista's design, and ultimately was left with an unfocused, incoherent design. Clearly a victim of Parkinson's Law of Triviality.

But it pains me to think that the many intelligent and sometimes brilliant people at Microsoft have such a poor grasp of what is meant by "Ordinary Users". Ordinary users do not feel threatened by whether something is grouped or ungrouped on the task bar! Lol - they don't even, for the most part, have any idea how to use the task bar. Raymond's example is laughable. It sounds absolutely nothing like any ordinary user I've ever heard. And yet these are the self-same folks who believe that they understand what ordinary people perceive and how they think about computers.

But when you actually sit down and use a computer, be it a Vista machine or a Windows 7 machine, and are constantly bombarded with "This action requires Administrator permissions" dialog, where you have to type the password for the admin account over and over to accomplish even day to day tasks, with no option to perma-authorize anything, you come to the inescapable conclusion that the folks at Microsoft behind this UX as they like to call it (User Experience), must all be on some serious drugs, or more likely, utterly self-delusional. Its so far from a functional, usable interface as to make me want to shame them in front of the entire class. I'd give them an "F". Hell, I'd post it in the school cafeteria's wall for all to see. I'd hold a mandatory "school-rally" to highlight the vast failure that is their security, and I'd want to interview the many folks involved in the course of creating this albatross to try to come to grips with how such an Elephant comes to reside in plain view without anyone commenting on how incredibly retarded it is, so that we can learn from their mistakes and never, ever, ever make this colossal of a stupidity again.

Or do you find that you side with the "there is no such thing as a simple feature" folks? Do you find Microsoft's UI changes in Vista and Windows 7 to be genuinely better and more usable than their overall UI in XP? Would you prefer to see every decision go through committee? Or do you see a better way?