Today, I was trying to explain to someone the difference between entering a Web site’s address in the address field of a Web browser, vs. entering a search term in Google. I was not very successful. In the end, it doesn’t really matter… Google happily accepts a Web site address in its search field, and all modern browsers accept search terms in the address field, passing it on to the preconfigured search provider.

But this experience reminded me of a clip from Star Trek IV: The Voyage Home. It’s when Scotty and McCoy talk to a factory manager and Scotty tries to show the chemical formula for “transparent aluminum”. When McCoy suggests the use of a computer, on old Mac sitting on a desk nearby, Scotty first tries to talk to it; and when McCoy helpfully points at the mouse, Scotty picks it up as though it was a microphone tries talking into it.

What I realized is that thirty years later, we basically gave up on the idea of trying to educate users. If that computer was built today, with users like Scotty in mind, we’d just put a damn microphone into the bleeping mouse. It’s just easier that way.

I just came across this gem of an example of bad coding in the C language.

Most C implementations allow arrays as function arguments. What is less evident (unless you actually bothered to read the standard, or at least, your copy of Kernighan and Ritchie from cover to cover) is that array arguments are silently converted to pointers. This can lead to subtle, difficult-to-spot, but deadly programming errors.

Take this simple function, for instance:

void fun(int arr[100])
{
printf("REPORTED SIZE: %d\n", sizeof(arr));
}

Can you guess what its output will be? Why, arr is declared as an array argument of 100 ints, so the output should be, on most systems, 400 (ints being 4 bytes in length), right?

Not exactly. Let me show you:

int main(int argc, char *argv[])
{
int theArr[100];

printf("THE REAL SIZE: %d\n", sizeof(theArr));
fun(theArr);
return 0;
}

On a 64-bit Linux box, this program compiles cleanly, and produces the following output:

THE REAL SIZE: 400
REPORTED SIZE: 8

Similarly, on Windows, using a 32-bit version of Microsoft’s C compiler, I once again get a clean compile and the program outputs this:

THE REAL SIZE: 400
REPORTED SIZE: 4

The morale of this story: Array arguments are pure, unadulterated evil. Avoid them when possible. They offer no advantage over pointer arguments, but they can badly mislead even the most experienced programmer. Compilers still allow array arguments, mainly for historical/compatibility reasons I guess, but it is unconscionable that they don’t even provide a warning when this abuse of syntax happens.

Fourteen years ago, I embarked on a small hobby project: A compiler for an ultra-simple programming language I called W, a language specifically designed to produce short 16-bit DOS programs. It has the distinguishing characteristic of having neither keywords nor types. The only data type on which it operates is a 16-bit machine word (hence the name, W).

I then wrote a few pages about this language that are still featured on my Web site.

Today (not for the first time) my project was rediscovered. Apparently not everyone realized that this was an old project (I now changed the configuration of the project page to make sure its creation date is visible.) The link went a little viral, as it was featured on both Reddit and Y Combinator. Which explains why, when I woke up this morning, I saw my server under a far heavier load than usual.

It was interesting to look at the comments on these two sites. Some liked what I have done. Others were critical, not sure why; it was a hobby project, after all, I wasn’t trying to win any accolades. But there was one particular comment on Reddit, by user MarshallBanana, that I really liked:

“What a bastard, making something for himself for fun. He sure deserves some shit for that.”

Back in my misguided youth, I spent a couple of years developing game programs for the Commodore 64.

It all started in 1982, when a friend of mine and I dropped by at the office of a newly formed company, Novotrade. We heard somewhere that these folks have a new personal computer in their possession, one with a whopping 64 kilobytes of random access memory (an almost unheard-of amount at the time), and they are looking for programmers.

It was all true. The Commodore 64 was there and they were indeed looking for talented programmers. Thus we got to meet Ferenc Szatmári (a physicist-inventor who later on had a profound influence on my life) and others, who explained the deal: Novotrade was about to enter into a business relationship with a British company, the idea being that Hungarian programmers will be writing game software for Commmodore’s brand new personal computer. As part of this arrangement, a prototype Commodore 64 (of West German manufacture, with serial number 000002) was already there, available for us to study.

As it is well known, the Commodore 64 went on to become one of the most successful personal computers of all time. Our games did not fare that well; truth to tell, they weren’t that great. The games we ended up developing were “chosen by committee,” so to speak, from game ideas sent in by the public in response to a Novotrade-managed contest. Still… we were proud of introducing some rather novel programming techniques. Specifically, highly efficient graphic algorithms were developed by two of our teammates, Imre Kováts and Márton Sághegyi, which allowed us to create 3D-ish full screen animations like a moving horizon or a floating iceberg.

Floating iceberg? Yes… one of our games was called Arctic Shipwreck, and it required the player to balance an iceberg by moving a friendly mammoth around while trying to avoid stepping on some poor survivors of a shipwreck… until rescue arrived. Oh, and there was a rather nasty bird of prey, too, that occasionally came and plucked a survivor for lunch.

Not very entertaining, to be honest. Yet for some reason, this game remains much liked by the dwindling community of Commodore 64 enthusiasts. Most recently, it was featured in a nice German-language article on TrueGamer.de; the author of that article, Boris Kretzinger, also interviewed me via e-mail for C64 Scene, an electronic magazine published in the form of Commodore 64 disk images (!).

Microsoft is not the only company that can produce pointless operating system messages. My Samsung phone greeted me with a fine example this morning, as I tried to use its S Voice app to create a new alarm using a voice command:

I feel so much better, now that I know.

For years, I’ve been using the online TV guide provided by ZAP2IT to check what’s on TV. Generally speaking, I’ve been satisfied with their service.

Until last year, when they introduced a whole new layout. Which, in my considered opinion, was a significant downgrade (makes me wonder if they were perhaps inspired by Windows 8).

Today I noticed, to my considerable pleasure, that the old layout is back. I now have the option to “Switch to Classic View”. Which I promptly did, without hesitation and with no plans to change my mind.

Now I am no usability or ergonomics expert, but I do have 30-odd years of experience in IT, and I know a thing or two about user interface design. Here are two illustrations that show why, in my considered opinion, the old format is far superior to the new one. First, the new version, with some of its shortcomings highlighted:

And now here are the same shows, in the old format:

So much easier to view! So much easier to find things of interest!

When they switched to the new format, I wrote an e-mail to complain. I did not expect a meaningful response. Noticing the link today, inviting me to switch back to the old format, was a most pleasant New Year’s surprise. I wrote to them again, thanking them for making the old format available. I hope it stays that way.

I know, I know, let this be the biggest problem in my life, when people are suffering and dying in various corners of the world. For what it’s worth, I never for one moment forget how lucky I am to be able to enjoy the luxury of life in a country like Canada. But this stupid TV guide still bugged me :-)

Today’s Dilbert captured with remarkable acuity a situation that I (and probably, most other software developers) am all too familiar with:

I am reading articles about the slow sales of Windows 8 and complaints about its user interface. All valid, I think. Indeed, there is an easy way to explain in two points why I would not recommend anyone to upgrade to Windows 8 on the desktop:

1. Value added by Windows 8 over Windows 7 for the typical desktop user: None. (To be sure, there are some minor improvements, including speedups. But they are more than offset by the incomprehensible removal of the Start button and the equally incomprehensible move away from the Aero interface, which is actually quite nice.)
2. Difficulties created by the schizophrenic nature of Windows 8 (“Modern” vs. “desktop”) and the cumbersome nature of a touch-oriented interface on a desktop computer: Lots.

In other words, you are paying a huge price (not the dollar cost of a Windows 8 license but price in the form of re-training yourself or your employees, and the inevitable productivity loss due to a very confusing schizophrenic interface) and you essentially get nothing in return.

Maybe Microsoft will fix all this with Windows 9. Maybe Ballmer has to go first.

Earlier this morning, I came across the following headline on Google News: “Fewer crashes when docs report bad drivers, study finds“.

The headline almost made sense. Yes, bad drivers cause crashes, indeed the main reason why modern operating systems crash these days is bad third-party drivers. So being able to identify and report a bad driver kind of makes sense, but how would you do that? And what does it have to do with your docs? Did the author mean perhaps that a document, say, an HTML page, could display a warning about a bad driver instead of invoking the driver (e.g., to display video) and risk crashing the browser or the computer?

It was over thirty years ago, back in 1979-1980, that I first earned money from a software development contract. My first assignment? Aircraft simulation, specifically tabulating the minimum safe take-off distance of TU-154 aircraft at Budapest airport under various loads and weather conditions.

Alas, the Hungarian national airline, MALÉV, is no more. But as of today, I became the proud owner of a MALÉV TU-154 B-2, with the original MALÉV markings.

No, not the real thing, I’m not that rich (and even if I were that rich, I’d not be spending my money on obsolete Russian aircraft), just a beautiful diecast model. Still, it’s a nice reminder.

I am reading with astonishment an article in IEEE Spectrum on the origins of DOS. The author, a self-proclaimed expert on software intellectual property analysis, describes his attempt at a forensic comparison of early versions of MS-DOS and CP/M, to prove or disprove once and for all the allegation that MS-DOS was a result of theft.

But I find the article poorly researched, and also a thinly veiled attempt to plug the author’s company and analysis tools. Childish comparisons of identifier names and code fragments… really? The issue was never verbatim copying but the extent to which QDOS (which is the operating system Microsoft purchased and renamed) was derived from CP/M. It is clear that it was heavily influenced by CP/M, just as CP/M was heavily influenced by its predecessors, including operating systems written for the PDP-11. Does this constitute infringement? I certainly do not believe so. Indeed, something very similar (albeit more formal) occurred a little later, when the first IBM-compatible “clones” hit the market, and companies like American Megatrends, Award and Phoenix created binary-compatible versions of the IBM PC BIOS using “clean room” reverse engineering.

Some online commenters went so far as to ascribe ulterior motives to the author and question his sincerity. I think that is uncalled for. However, I do believe that this article should not have been published in its present form. At the very least, the author should have been advised by competent editors to tone down the plugs; to do a little bit more research on the topic; and to shift the emphasis from meaningless code comparisons to an analysis of the functional similarities between the two operating systems, the possible origin of these similarities, and the question of whether or not they might constitute infringement (and the extent to which the law may have changed, if at all, in this regard between 1982 and 2012).

Today, I spent an inordinate amount of time messing with IMAP.

IMAP is a protocol that allows e-mail clients to access e-mail stored on a server. Unlike the more popular POP3 (Post Office Protocol version 3), IMAP (Internet Message Access Protocol) allows the messages to stay on the server, and allows clients to establish a folder structure on the server.

This makes it possible, in principle, to access the same mailboxes from multiple client devices like a desktop computer, a smartphone, or a tablet.

Don’t we already have this with any Webmail provider, such as Gmail, Yahoo! Mail, or the new Outlook.com? Well, yes, but… with all these services, your mail actually physically resides on computers that do not belong to you. I’d be less concerned about this were it not for a case that happened just the other day, a hacker using social engineering to gain access to a journalist’s iCloud account and through that account, everything else (including the journalist’s phone, laptop, and other accounts.)

If Apple can fall victim to social engineering, so can Google or Microsoft. So for this reason alone, I prefer to keep my e-mail on servers that I physically own. But I still like the convenience of accessing my e-mail from anywhere without having to copy bulky mail files or worry about synchronizing them.

This is where IMAP comes in. Except that it turned out to be a much more difficult task than I anticipated.

The basic setup is easy… enable IMAP and go. But then… the University of Washington IMAP server that is included with Slackware Linux has some quirky settings (such as showing all my folders on the server, not just my mail folders) that can only be corrected by recompiling. It took a while before I realized this, and therefore I wasted a lot of time with bugs in the various Android IMAP clients I tried, bugs that just went away once I recompiled the IMAP server. Outlook (which I plan on continuing to use on my main desktop computer) has its own quirks, not the least of which is the insanely difficult nature of seemingly trivial tasks, such as relocating built-in folders like the junk e-mail folder.

In the end, I won. There are still some quirks to be worked out, but I can now access my e-mail from Outlook, the Web (with Squirrelmail) and from my Android phone and tablet just fine. Still, it was a much harder battle than it should have been. I honestly expected this technology to be more mature in the year 2012.

It looks like Microsoft is absolutely, positively determined to make it hard for long-time users of Windows to continue using their computers productively.

For instance, they actually went the extra mile to disable hacks that allowed Windows 8 to boot directly to the classic desktop and reinstated the Start menu.

What on Earth is going on in Redmond? What are you guys smoking?

I just finished reading a very interesting Vanity Fair article about the decline of Microsoft. It paints a devastating picture leaving one to wonder why Microsoft’s shareholders continue to tolerate Ballmer’s (mis)management.

I have been wondering the same thing for many years, for pretty much the same reasons mentioned in this article: the Vista fiasco, the squandering away of the IE lead, Windows CE and Windows Phone, the Zune misstep, and last but not least, the disaster that is yet to happen, which is called Windows 8.

And how many times did you type “microsoft.com”?

And I actually happen to like Microsoft.

The Comments section is also interesting, but mainly because of the bias and misinformation. My all time favorite: the story about how Word became the dominant office product because of “secret APIs”. Perhaps there were secret APIs, perhaps there weren’t. But none of that had anything to do with the then market leader, WordPerfect, jumping on the Windows bandwagon several years late, and with a crappy product that crashed even more often than Microsoft Word for Windows 1.0. And by that time, Microsoft was up to version 4.x and frequent crashes were no longer considered acceptable.

Remember Microsoft Bob? The revolutionary new interface for Windows that was supposed to make everyday computing easier for the unwashed masses?

It was one of Microsoft’s most spectacular product failures, surpassing even the dreadful Clippy (which, after all, was just an unwelcome feature in an otherwise successful product, Office 97).

But now, it seems that Microsoft is determined to do it again. At a time when the operating system is becoming increasingly less relevant to most users (who cares what operating system runs underneath your browser when you access Gmail or Office 365?) they seem to be dead set on alienating that one class of users for whom the operating system still matters: content creators, which includes artists, designers, software developers and the like.

To their credit, Microsoft is doing this in the open, documenting in a very lengthy blog post the basic ideas behind their most controversial design choices.

But the comments are revealing. Here is a random selection (certainly not unbiased) that I found that I could most closely relate to. After all, just like one of the commenters, I, too, “tried Windows 8 for 2 weeks and then uninstalled“… or rather, not so much uninstalled as never looked at the VM again in which it was installed because I just couldn’t care.

Can someone help me out? Should I install Ubuntu, get a Mac, or keep using Windows 7?

Your product is named after a feature of your product. And now the new version of your product tries to abandon said feature in its newly introduced usage mode.

Google just added windows to Chrome OS. You are removing windows from Windows. This won’t end well.

Except for immersive games, I DON’T WANT to run a single full-screen app. Not ever. If I want something to fill the screen, I will maximize the windows.

There is a significant disjunction in the UI. when you hit the start button and are whisked into metro land just to search for something, only to come back to the desktop

Thank you Microsoft for this complete failure. I for one welcome our new KDE overlords!

None of this TABLET CRAP belongs on desktops!

The cold, hard truth of the matter is that Microsoft have created an operating system that I feel is OPENLY ANTAGONISTIC to power users, business users, creative professionals and anyone seeking to use their PC as a productivity tool.

In WW2 the English started a program to analyze aircraft to figure out where they needed to add armor. They looked at all of the planes coming back and did frequency analysis of where the bullet holes were. Some areas were so riddled that easily 60% of bullet holes hit these key areas. The first reaction is to armor these heavily hit areas of the plane. This is wrong. These planes survived. The armor should go everywhere else.

You are killing Aero? You have to be kidding!

Windows 8 prognosis for sales: not that good. That is the latest finding from research entity Gartner.

I have to give you credit Microsoft, you really do know how to alienate people.

The flat UI in no way looks premium. It is harsh, spartan, and an eyesore.

The Metro environment severely compromises functionality by:

• not allowing real multitasking (only applications in the foreground are allowed to use CPU);
• not allowing more than two applications to run in the foreground (all other applications are suspended).
• not allowing the two apps in foreground to use half the screen each (most of the time one of the two apps will be unusable because it has too little space to display information).
• not allowing the use of more than one display for Metro apps.
• not allowing more than one running instance for an Metro app.

And the most scary thing is that we already have an example of crippling the Desktop: Windows on ARM/Windows RT. By not allowing third party Desktop applications, the Desktop is only there to allow you to use MS Office.

Do you have a logical explanation why you are screaming permanently that these 9.1 percent iPad/iPhone/Android users are more important than 90% desktop users?

Pls provide a METRO ON/OFF option in Windows 8 (only desktop). With Mouse&Keyboard, METRO is bizarre to use.

How does Windows 8 “metro” and other this teletubby nonsense work on multimonitor setup?

It’s a degradation of Windows. New UI is terrible

The metro interface is horrible and whoever designed it should go back to work for whatever cell phone company they crawled out of.  Lets stop dumbing down the computer for the appliance user.

From my perspective, Aero glass is still fresh and new.  The loss is ultimately cosmetic and therefore minor, but it adds to one of the bigger issues with Windows 8’s UI

Using Windows 8 with a mouse is about as much fun as running Windows Phone 7 in an emulator all day.

And finally, the last comment that sums up my own feelings neatly:

If W8 really works on a desktop used by adults I’ll consider it

But not until then.

While the world mourns Steve Jobs, another computing pioneer, Dennis Ritchie, died. Our world wouldn’t be the same without UNIX or the C programming language. My own life would have been very different without him. Jobs will long be forgotten when Ritchie’s legacy will still live on, decades from now.

#include <stdio.h>

main()
{
printf("goodbye, dennis\n");
}

It has been a while since I did anything in machine language. Until this past weekend, that is, when I spent a fair bit of time starting at disassembled code with a debugger.

Last week, I upgraded my Sony Ericsson smartphone to the latest version of its operating system. The upgrade process failed on my main computer when, after updated USB drivers for the phone were downloaded, they failed to install. The problem was not specific to the phone: all driver installations failed, with a not very informative code (0xC0000142, which just means that the application failed to initialize.)

Using the very helpful ProcMon utility from sysinternals (now owned by Microsoft) I managed to identify that it was a process named drvinst.exe that failed. This process is invoked automatically by the system every time a USB device is inserted, and also during device driver installations. So why did it fail?

I downloaded the latest Windows debugger (windbg.exe) from Microsoft; this debugger allows me to do things like debug child processes spawned by a parent process. (I later learned that drvinst.exe actually has a feature whereas it waits for a debugger after startup, to help with driver installation debugging; but chances are that I would not have been able to make much use of this feature, as the failure occurred before drvinst.exe actually started to execute its own code.) I attached the debugger to the DCOM service process (which is the one that spawns copies of drvinst.exe.) I was able to determine that it was during the initial process setup stage that this process failed, when it was attempting to attach to the gdi32.dll system library.

I still have no idea why this happens. But with the help of the debugger, I was able to tinker with this process, changing a processor register’s value at just the right spot, allowing it to continue. This inconvenient but workable process allowed me to install drivers for my phone and also updated drivers for my wireless mouse from Microsoft Update.

Perhaps the most incomprehensible bit is that the same thing works fine on an essentially identical computer. The actual failure occurs inside a kernel subroutine (undocumented system call 123Ah, called from GdiDllInitialize in gdi32.dll) that I cannot debug without a kernel debugger (and since I am trying not to mess my machine up too much, I opted not to do kernel debugging). That subroutine does not appear to be doing anything particularly magical. I checked and all relevant files and Registry settings are identical on the two machines. So it remains a mystery for now… nonetheless, it was educational. I learned a lot about driver installation in Windows 7, about process startup, and incidentally, about the ReactOS project whose open source equivalents to the relevant system components helped me a great deal to understand what was going on.

One of the things I like the least about New Scientist (which, in many respects, is probably the best popular science magazine out there) is the “Enigma” brainteaser. I am sure it appeals to the “oh I am ever so smart!” Mensa member crowd out there but…

Well, the thing is, I never liked brainteasers. Are you really smarter than someone else because you happen to remember a random historical factoid? Does it really make sense to ask you to complete a series like, say, 1, 4, 9, 16, ? when the answer can be anything, as there is no compelling reason other than psychology (!) for it to be a homogeneous quadratic series?

But then… sometimes brainteasers reveal more about the person solving them than about the solution itself. I remember when I was in the second or third grade, our teacher gave us a simple exercise: add all the numbers from 1 to 100. (Yes, this is the same exercise given to a young Gauss.) Like Gauss, one of my classmates discovered (or perhaps knew already) that you can add 1+100 = 101; 2+99 = 101, 3+98 = 101, and so on, all the way up to 50 + 51 = 101; and 50 times 101 is 5050, which is the correct answer.

Trouble is, my classmate didn’t finish first. I did. I just added the darn numbers.

Between quick and smart, who wins? What if you’re so quick, you don’t need to be smart? Is it still smart to waste brainpower to come up with a “clever” solution?

Last week’s New Scientist Enigma puzzle caught my attention because it reminded me of this childhood memory. It took me roughly a minute to solve it. Perhaps there is a cleverer way to do it, but why waste all that brainpower when I can do this instead:

/* New Scientist Enigma number 1647 */

#include <stdio.h>

int main(int argc, char *argv[])
{
int d1, d2, d3, d4, d5, d6, n;

for (d1 = 1; d1 <= 9; d1++)
for (d2 = 1; d2 <= 9; d2++) if (d2 != d1)
for (d3 = 1; d3 <= 9; d3++) if (d3 != d1 && d3 != d2)
for (d4 = 1; d4 <= 9; d4++)
if (d4 != d1 && d4 != d2 && d4 != d3)
for (d5 = 1; d5 <= 9; d5++)
if (d5 != d1 && d5 != d2 && d5 != d3 && d5 != d4)
for (d6 = 1; d6 <= 9; d6++)
if (d6 != d1 && d6 != d2 && d6 != d3 &&
d6 != d4 && d6 != d5)
{
n = 100000 * d1 + 10000 * d2 + 1000 * d3 + 100 * d4 + 10 * d5 + d6;

if (n % 19 != 17) continue;
if (n % 17 != 13) continue;
if (n % 13 != 11) continue;
if (n % 11 != 7) continue;
if (n % d4 != d3) continue;
printf("ENIGMA = %d\n", n);
}

return 0;
}

Yes, I am quick with C. Does that make me smart?

Well, almost 23,000. Mostly JavaScript and PHP, also HTML and SQL. This is a project I’ve been working on all summer. Lots more to do, but at least one deliverable is complete, and I can finally spend a little bit of time doing something else. Plenty of other things I’ve been putting off while I was on this programming binge.

It’s not for the first time I said this, but you just gotta love this Internet thing. The big news this morning of course is the leak of some 90,000 classified US military documents from Afghanistan. Guardians of state and military secrets are horrified: troops’ lives will be at risk, they say. What they should recognize is that the fact that we live in an open society, far from being a weakness, is really our greatest strength. Open discussion of the pros and cons, the successes and failures, the risks and possible outcomes of a war is part of living in a liberal democracy.

As to the release itself, it’s funny how times are changing. When I learned the database language SQL ages ago, it was because I make my living as a computer professional. I did not necessarily expect to use my SQL skills in scientific endeavors, but that, too, came to pass when I began using the wonderfully crafted SQL-based query interface of the Sloan Digital Sky Survey. What I certainly never expected is that one day, a journalistic leak will arrive in a variety of formats, perhaps the most useful of which is an SQL dump. I wonder: do they teach the building of SELECT queries in journalism school these days?