Monday, February 6, 2017

Contrast without comfort

I just finished reading the book Rainbows End, by Vernor Vinge.

The quote that stuck with me, from page 355 is, "Back when I was young, you could have got a patent off of it... Nowadays, it should be worth a decent grade in a high-school class."

Yes, technology changes, and skills that would have been impressive twenty years ago are of little worth today.

Friday, December 9, 2016

Consequence without compassion

There are some things in this world that are unforgiving. This post is about a couple of things that you can type into a computer's command line with devastating results.

Just today, I needed to use a file named SROSTERS.TXT, which had been written by a DOS program on a Windows machine. But, I needed to use it on my MacBook Pro. It was important to today's work, but I noticed that each of its 33,000+ lines ended with a carriage return, line feed. Those two characters are invisible, so I only noticed it because one line of interest was exactly one character longer in the file than the equivalent line produced on the Mac, although they appeared to be identical.

There is a handy Bash command that will remove all the carriage return characters, leaving only a line feed at the end of each line, which is what the Mac expects. So, I set out to use that command:
cat SROSTERS.TXT  |  tr  -d  '\r'  >srosters.txt
 The cat command outputs the file contents to standard output, which is then piped (notice the vertical bar aka "pipe") into the standard input of the tr (translate) command, with the option to delete all  carriage return characters (-d '\r'). It was my intention that the output of the translation would go into a new file named srosters.txt which could then be used on the Mac.

Now the greater-than sign (>) in Bash has two different roles. It is followed by a file name, and if the file doesn't already exist, it is created (empty) before the command runs, which was my intention. But, if it does exist, it is truncated to an empty file, again before the command runs.

In my mind, based on years of experience using UNIX® and various linux systems, the two file names SROSTERS.TXT and srosters.txt would be for different files. Not so on the Mac's OS X version of linux. These two* names are both names for the same file!

So, when I pressed the enter key, my computer first truncated the file to an empty file, then sent its contents (also empty) through the pipe into the translate command whose output went into the file (still empty!).

And that is how I experienced a severe consequence, with my computer expressing no compassion.

You know, the greater-than sign has bitten me before, so maybe I should have been more careful.

As a graduate student, 30 years ago at the University of Calgary, I had spent most of a day working on a class assignment. When I finished at six o'clock, I did what I ordinarily did at the end of a day, which is to type this command to remove all of my backup files:
rm  *.bak
This would remove all files whose names ended with ".bak" and that is what it had done every day before. But that night, I was in a hurry, and my left pinkie finger didn't leave the shift key quite fast enough as my right ring finger went for the period key. So, that key got shifted and the command that I actually typed was instead:
rm  *>bak
Ouch.  If only I'd had time to look at the command line before pressing the enter key, but my fingers were on automatic. After running the command, I did, as always, check to see that the backup files had indeed been removed. To my astonishment, all of the files were gone, and there was a new one, named bak, which was empty. The rm (remove) command removed all of the files (as specified by the wild-card *) and sent its (empty) output into the newly created file named bak. Just as my command specified. Again, no apologies from the computer!

That night, I learned that sometimes you can do a project better the second time you try it. I had to have the assignment done, so I stayed another hour or so and re-wrote all of the code from memory.

Today, I'm going to resolve my problem by having a friend who works near my desk in the office find a USB key in my drawer and email me the file contents.

A bonus story, where a great deal of much-appreciated compassion was shown, from 20 years ago, when I worked in the Advanced Technology Group of WordPerfect Corporation as a senior scientist. Our administrative assistant (who I will call Virginia) was having some trouble with her computer and emailed the group a screenshot** of a rather ominous warning message. I flippantly fired back an email message saying (as best as I can remember)
It looks like you have the dreaded M$ Windows virus on your machine. It's easy to get rid of. Just type DELTREE C:\WINDOWS and that'll take care of it.
About half an hour later, when I'd forgotten all about my little joke, I was called into my boss's office. He tried to keep a straight face as he reprimanded me. Virginia hadn't seen my message as a joke, and had issued the command, which completely removed the operating system from her computer. A technician came and it took most of the afternoon to get her machine working again.

The compassion came as my boss chose to forgive me, and we still laugh about it when our paths cross.

* And not just these two names, but all of the 2,048 possible variations, mixes of upper and lower-case letters, of this file name. Whichever of the variants you use, you will be referring to the same file.
** Unfortunately, I no longer have access to that email system, or I could have displayed the warning message in this blog post.

Monday, May 23, 2016

Computation without compilation

The notion of programming is customarily associated with the practice of coding. Developing a program by coding requires the use of a compiler to translate the code you write into a form usable by the computational device.

I own a fairly simple machine, a DeLonghi TRN0812T space heater (the link is to a review by Consumer Reports, from which I also borrow the picture below). The primary purpose of the device is to heat a small room, but it can be programmed, which is my interest in this post. It can be programmed without requiring any written code to be compiled. Thus it does a (very simple) computation without compilation.

Two asides are needed: 1) the distinction between operating a machine versus programming a machine, and 2) bootstrap loading via toggle switches. In the interest of tl;dr I am going to defer these to later in this blog post.

Here is a picture of part of the control panel of the space heater. It shows two large switches which have four possible configurations: 0 (off), MIN (minimum), MED (medium), MAX (maximum). Above them, and not shown in the image, is a thermostat. Below the two large switches are 96 tiny switches arranged in a circle. These are used to program the heater.

The heater photographed above is set to maximum and programmed to run continuously, except from 5:30 a.m. when it will be switched off until 6:00 a.m. when it will switch back on. The time at which the picture was taken* is 10:30 p.m. and the heater is on.

Operating the machine is straight-forward. Turn it on to maximum (with all the tiny switches left in the factory setting: towards the center of the circle). Set the thermostat to its maximum position (again, the factory setting).When the room reaches the desired temperature, turn the thermostat down slowly until you hear a click, then stop at that point. The thermostat will then act to maintain that temperature. To save energy, you can switch off one of the large switches, thus setting the heater to either medium or minimum.

Aside: operating the machine requires you to be present and attentive. In contrast, programming the machine involves you doing something now which will have an affect later even in your absence.

Programming the machine is also quite simple. First, turn the knob clockwise (in the direction of the long arrow) until the pointer is aligned with a number representing the current time of day (in a 24 hour clock). Then push the tiny switches outward for all of the times (15 minute intervals) when you want the heater off.

Having programmed the machine, you can now leave it unattended and it will cycle on and off under control of your program. (The owners manual soberly points out that "you can ... program up to 48 cycles ... over a period of 24 hours")

I would like to point out that since there are 96 of the tiny switches, and since each one can occupy, independently, one of two positions, that there are 296 (=79,228,162,514,264,337,593,543,950,336**) possible programs. (The reader may find it interesting to compare this calculation to the approximation suggested by my Powers of 2 post which would have 296 to be approximately 64 x 1027, which is close... but quite a bit on the low side)

Of all the possible programs, I'll mention four or five. With all the switches out, the heater will never turn on -- not a very useful program, except, perhaps, as a practical joke. With all the switches in (the factory setting), the heater is always on. With every other switch out, you have one of the two possible programs which cycle the heater on and off 48 times over a 24 hour period (the possibility promised in the manual). Finally, the program currently on my heater, with half the switches in and the other half out, turns the heater off at 5:30 p.m. and back on again at 5:30 a.m.

A note about large numbers. If there were a billion owners and each owner tried a different program every day (with some mechanism to avoid duplication), it would take nearly 217,000 trillion years for all possible programs to be tried.

Finally, the aside about bootstrap loading. This heater intrigued me because it reminded me of old days in computing. Early machines would load their programs from punched paper tape. But the program which loaded the programs from paper tapes had to itself be loaded into the machine. And this was done by setting small switches to place an initial program into the machine. Wikipedia has a nice article about booting computers which you can find by clicking here.

This is a nice demonstration of a fact that I point out in my dissertation, which is that one can look at programming as choosing a number. Here instead of the more customary "think of a number between one and a hundred" we have, with this heater, "think of a number between one and 79,228,162,514,264,337,593,543,950,336." Once having the number, we can convert it to binary and set the 96 switches according to the ones and zeroes, programming it without needing to compile code.

* the arrow is pointing at the mark between 22 and 23, meaning that the current time when the picture was taken is 22:30 (24 hour time) which corresponds to 10:30 p.m.
** the number was computed using TOOL which can do large integer arithmetic on numbers of up to 147,456 digits. This number doesn't stress the system much because it is only 29 digits long.

Tuesday, August 25, 2015

Continuation without compulsion

In other words, persisting in something because of its benefits, and not because one must. Such is my relationship with DataPerfect, with which I became acquainted in 1988, as I began* that portion of my career spent with WordPerfect Corporation. I continue to use DP regularly, having, in the last four months alone, created nine database applications to assist me in my current job as a web developer.

DataPerfect is a software jewel, very compact yet complete and powerful. It's most remarkable characteristic is that it has enabled people who would never have considered themselves programmers to create wonderfully useful data-based applications. People are considered computer-literate** if they can use programs to do work. They are programmers when they can create applicatons that other people can use to do work.

There are descriptions of DataPerfect in words, but of course the best way to understand it would be to learn to use it. The setting for the jewel is DOS, which modern computers no longer run directly***. Here are some dimensions that could be included in such a description.
  1. Modes: define mode vs. run mode
  2. Organization: panels, fields, indexes, and links
  3. Usage: single user vs. multiple concurrent users
  4. Operations: lookup, browse, create (i.e. data entry), edit, and delete
  5. Relationships: one to one, many to one, one to many, and many to many
  6. Communication: clipboard, importing, exporting, phoning, reporting, and printing
  7. Security: none, definer password, user credentials
  8. Usability: panel and report lists vs. menus
  9. Help: general, context-sensitive for each field
  10. Add-ons: print spooling, mouse usage
  11. Documentation: manual, books, web sites
  12. Support: active community
An article with a good description of DP was written many years ago by Ralph Alvy****. It touches on items 2, 3, 4, 5, 9, 11 and 12 from the outline above. Unfortunately, the links in this article are no longer working (suffering from "link rot") but you can find information about his book at

I expect to continue using DP any time that I need to process textual data with any amount of structure, not from compulsion, but because it is so very useful.

* At first, I was kept busy with a new language that our team was creating, TOOL, later described in my dissertation. The purpose of TOOL was to become the next implementation language for a new and different version of DataPerfect. Once the new language was up and running, I felt that it was important to learn what DataPerfect was, and so I gradually became an expert user, despite the fact that others on my team assured me that that wasn't necessary. I'm glad I did.

** Several years before this story, I taught computer literacy courses as an itinerant instructor for Lethbridge Community College. Generally, these were three week courses, and I would take my Apple ][ computer and drive to a small town one evening a week to join a small group of adults in a local school computer lab. First a three hour session on word processing. The second week another three hour session on spreadsheets. Finally a three hour session on databases. Both interest and mastery trailed off during each such course. Most people grasped word processing, which was after all, a lot like using a typewriter. They had more trouble with spreadsheets, and didn't get databases at all. I think it was too abstract. And probably too much based on a textual description of what would later happen. Making that connection, between a textual description, and something that happens later because of it, is what separates programmers from non-programmers.

*** Instead, one must first install a DOS virtual machine, as outlined in this story about one DP application.

**** The article is not dated, but is probably from around the turn of the century (which makes it "dated" in that sense of the word, but still applicable). Incidentally, Ralph is a good example of someone who is not self-described as a programmer, yet who has created DP applications, and even wrote a book about it!

Thursday, August 13, 2015

Communicate without conversing

In other words, read and write: be literate. (One could easily imagine other ways of communicating that don't involve the voice, such as miming, dancing, etc., but, this post is mostly about reading.)

While living in Mauritius for a couple of years, we came to know about the languages used there. Most Mauritians speak a creole language, Morisien, which is the native language for most of them. Traditionally it had been only an oral language. However, in 2011, an official spelling system* was approved by the government. So, it has now become interesting to ask how many people can read this language, which can now be written in a standard way.

Dev Virahsawmy, a noted Mauritian linguist, told me in personal conversation that he estimates about 20% literacy. That is, only a small portion of the population can read and write Morisien. Yet according to Google (as of this writing) the literacy rate in Mauritius is 88.8% and wikipedia reports a rate of 89.8%.

Education is compulsory through age 16, and is free, even beyond high school. And the transportation to/from school is free. Everyone must learn both English and French in school. So, the high literacy rate is for these languages. Since 2012, Mauritian Creole is being offered as an optional subject, starting in the first year of school, and available to second year students in 2013, to third year students in 2014, and so on.

So, the situation is that while almost everyone can read and write a language, and almost everyone speaks Morisien, most cannot read or write it. This will improve gradually, and in ten years or so many young adults--who will have studied the language for 12 years--will be literate in their native language.

The official spelling is interesting, as it is a highly phonemic orthography. That is, the spelling is regular, with few exceptions, so that if you read it out loud, following a few simple rules, you will hear the oral language and thus immediately understand it. This means that it should be very easy to learn to read Morisien.

Hence, a project idea: produce a series of YouTube videos to encourage learning the few simple rules. Now all I need are: an expert in producing video, a native Mauritian for voice-overs, and a script**. Almost everyone in Mauritius has a smart phone, so, if this could go viral, literacy could soar.

Encouraging Mauritians to read: to communicate without conversing.

*Lortograf Kreol Morisien
** I have written elsewhere about a list of common words that could star in such a script.

Monday, June 1, 2015

Contrivance without content

This post is simply a link to a web page which describes more programming work which I accomplished using the Bash scripting language. So, about another contrivance, but no content here. Please enjoy the page at

Why a separate page? Because I needed to use features of HTML and CSS which are difficult to embed in this blog.

Wednesday, August 6, 2014

Confusion without compromise

Another off-topic post*, this one about communication with a corporation. This corporation currently has a campaign entitled, "We're listening." It is intended, I suppose to convince the customers that they are listening.

As it happened, I had a little problem with one of their accounting procedures, and so I was taken in by the slogan, and tried to tell them about the problem. Here is the conversation, stripped down to its essence.

[3chase-customer [2author I am having difficulty because of one of your accounting procedures. (Description of procedure.)]]

[3chase [2charlotte We understand your frustration. Here is how it works. (How the procedure is supposed to work.)]]

[3chase-customer [2author I don't feel listened to. I would be very happy if your procedure worked the way you describe it. But it actually works like this. (Description of procedure.)]]

[3chase [2josue We understand your frustration. Here is how it works. (How the procedure is supposed to work.)]]

[3chase-customer [2author You aren't listening. I would be very happy if your procedure worked the way [2charlotte] and [2josue] describe it. But it actually works like this. (Description of procedure.) I will have to minimize my use of your service.]]

[3chase [2mark We appreciate your business. We would have loved nothing better than to satisfy you with our replies. We are sorry you are going to minimize your use of our service, and hope you will reconsider. If you have any further questions, please contact us.]]

The ball is in my court again, but I think that I will just retire from the field. I have lost this volley. The corporation has lost some business. How could it have the slogan, "we're listening," while not listening? Of course, I wasn't listening either, in the sense of believing what they said. I prefer to believe what I see them actually doing.

For the record, the accounting procedure actually works the way I described it (to a customer's disadvantage) and not the way the corporation describes it (which would be to the customer's advantage).

Neither side has truly communicated to the other. Nothing will change, and the customer confusion will continue. Neither side changed its position. This is confusion without compromise.

* Inspired by Myrna's post-the-first and post-the-second about another corporation which didn't communicate well.