Around the World with the C++ Migration

Dr. Dobb's Journal October 1998

By Al Stevens

Al is a DDJ contributing editor. He can be contacted at astevens@ddj.com.

It is said that the two most traumatic and stressful experiences a person can have are a death in the family and buying a house. I think I've found number three.

Several months ago a pamphlet came in the mail calling for speakers at Software Development Asia in July of this year. Software Development is a conference our publisher, Miller Freeman, hosts in several parts of the world each year. I have spoken at many of them mostly at the urging of Judy who likes to cruise the exhibitors' booths, be recognized as the wife of a famous international journalist, and collect the free promotional T-shirts, ballpoint pens, and yo-yos. Not having anything new to talk about this year, I ignored the call for papers until Judy, who found it as she emptied the trash, charged into my office and thrust it under my nose.

"We're going," she said. "It's in Kuala Lumpur. Send them a proposal."

"I don't have anything prepared," I said.

"Get creative. Kuala Lumpur is famous for the shopping."

"I'm really busy with this Windows 98 book," I whined.

"Work nights. We're going." End of discussion.

So, on July 1, I found myself checking into a Delta flight from Orlando to Los Angeles with connections to Kuala Lumpur. We'd arrive in Kuala Lumpur on the morning of the 3rd and have four days to rest up, be tourists, and shop. The first of my two talks was to be on the 7th. The Delta agent looked at our passports (because we were checking luggage through) and gave us our boarding passes.

After landing at LAX, we walked to the international terminal and went to the Malaysian Air counter to check in. That's when it happened. The agent leafed through my passport, then asked politely, "Do you have a renewed passport with you, Mr. Stevens? This one has expired."

Stunned, I looked at the passport and explained. "It expires on July 13th. We're returning on the 11th."

He smiled patiently and said. "It expired on July 13, 1997. That was last year. We cannot allow you to board this flight."

[Even if the date had been July 13, 1998, I could not have gone. Malaysia does not permit anyone to enter the country if their passport has less than six months before expiration.]

I can't explain what goes through your mind when faced with something like this. (I can explain the look on Judy's face, but I won't.) I asked the agent what could I do, and he said I should check at the U.S. Consulate when it opened the next day to see if it could handle my request for an extension. He suggested that Judy, whose passport was fine, continue her trip and not miss out on any of the shopping, but my silent, icy stare put a quick quietus on that notion. The agent retrieved our luggage and gave us a coupon for a discount room at the Holiday Inn. He wished us luck and hoped we would be back for the flight the next afternoon.

I got up early the next morning and asked the desk clerk where the Consulate was. The what? The place where you get your passport fixed. She looked it up and wrote down the address -- 1100 Wilshire Blvd.

I gave the cab driver the address. She wanted to talk, so I told her what happened. Sometimes telling people how stupid you are makes it easier to accept. "You don't want 1100 Wilshire," she said, "that's downtown. The federal building is at 11000 Wilshire in Santa Monica." It didn't seem likely that the Consul General would have his office in Santa Monica, but she was right, and I got out of the cab in front of a huge building with signs prominently directing me to the passport office.

The word "consulate" invokes visions of an appointment with the Consul General or perhaps one of his aides, someone who looks like Claude Raines in a cutaway jacket and listens patiently from behind his large walnut desk in a richly paneled office as I explain my plight, whereupon he grandly stamps my transit documents with the required authority. I've seen a lot of movies where that happens. Yeah, right.

The passport office was on the first floor with an outside entrance. I was early and the office was not open. I could see metal detectors just inside the glass door. A sign said ominously that no passports would be issued to anyone who did not have an appointment, which you could make by telephone. I went to a pay phone and dialed the number. An automated service led me through the touchtone entry of my date of travel and social security number, and told me what I had to do. It assigned me an appointment number and an appointment time of 11:30 am that day. It said that no one who did not remember their appointment number would get a passport.

The office would open at 8:00 am. A passport photo shop nearby opened at 7:30. I got pictures and returned to my curb outside the passport office. Thus began the longest day of my life. This was Thursday, July 2nd. If I could get the passport early enough, I could make the 2:00 pm flight. Too late, and I'd have to wait until Friday's flight. If I couldn't get the passport today, I might as well not go. Friday was a holiday; the passport office would not be open again until Monday. If I had to wait until Monday for the passport, I would not arrive in Kuala Lumpur until Wednesday, the day after my first presentation was to be made.

Promptly at 8:00, an armed, uniformed guard opened the door and two of the longest lines of people I have ever seen anywhere began to form -- lines of people who were there to get passports. The Pope has addressed fewer people in the Vatican courtyards. The guard said that, given my circumstances, he might be able to get me in early.

I waited outside the lines, because one line was for people with appointments earlier than mine, and the other the "will call" line; I didn't know what that line was for but it wasn't for me, the guard said. Two other people were waiting with me. One fellow was going with his family on vacation the next day. His passport application had been in the system over a month. A woman was there to get pages added to her passport for a trip the next day. (You need new pages stapled into your passport when your pages are filled with entry and exit stamps and visas.) Her request for pages -- and her passport -- had been somewhere in that building for over a month. While we waited, we watched the procedure. Everyone who spoke to the guard used the words "emergency" and "expedite" just like we had. Things were looking bleak.

My companions were noticeably irritated and angry. They made constant references to the incompetence of a system that brought them to this point. They spoke of telephone conversations with uncaring bureaucrats who blithely lied to them and seemed not to know anything. I told them that my plight was due to my own stupidity and that if I got a passport that day, I would declare to anyone who cared to listen that the system works.

Eventually we got in. We went to different windows where clerks stood ready to get us into the system. My clerk found no record of my appointment but took my application and old passport anyway and gave me a control number, but only, she said, because I had my airline ticket with me to prove that I needed special service. So much for needing an appointment and an appointment number. She directed me to the next room where a long wall of clerks served people by control number. Four of the windows were marked "will call" and were closed. An automated voice, sounding like something from Logan's Run, called out the control numbers and told people which window to go to. It took a long time for our numbers to come up. When mine did, a clerk took my credit card and gave me a green "will call" sheet with instructions. Mystery solved. I was to return at 1:00 pm -- no sooner, no later -- get in the outside "will call" line, and, if my passport was ready that day, I would get it sometime after 1:00 pm at a "will call" window. What if it is not ready, I asked. Then I could return on Monday, she said. I considered a long weekend in the Holiday Inn near LAX with Judy glaring at me. ("The cable at this hotel doesn't get QVC!") The system has to work, it just has to.

At 1:00 pm my two companions and I were in the outside "will call" line, where people were allowed to enter the building in batches designed to keep the room manageable. The guards did it with walkie-talkies. Eventually we passed into the window room where they told us to get into one of the four inside "will call" lines according to the first letter of our last name. I stood in line and watched as some people got passports and other people were told to go sit down and wait for their names to be called. My two companions were among the former group. It was gratifying to see the stress and anxiety vanish from their expressions when they finally had the precious documents in their grips. They waved and called "good luck" across the room and left, their voyages and their happiness ensured. My day was far from being over.

My turn at the "will call" window came at last. The clerk took my name and rummaged around in what looked like a random pile of thick envelopes. Every now and then, another clerk would come in and throw some more envelopes onto the pile. Mine was not there, the clerk said, although it was unclear how she could have known. Go sit down and wait for your name to be called. What if it's not called? If you are still here when we close, your passport was not finished. When do you close? When everyone has been served. I figured that the folks who assemble the passports leave at quitting time, and the folks who work the windows distribute the last batch, and anyone who didn't get a passport comes back another day.

So I sat down and listened for my name. The room was packed with people of all ages, shapes, sizes, and ethnic origins. Two armed guards walked around the room and cordially kept order. As fast as people would leave or sit to wait with me, the guards would mumble into their walkie-talkies and usher in another batch. Some people waited patiently. Others kept fidgeting and running to the windows to ask if anyone had seen their passports anywhere. No one had. Not before your name gets called, anyway. I moved to stand near the speaker so I wouldn't miss hearing my name being called. The clock ticked the day away.

I spoke with one man who had applied for a renewal several days before and had paid the extra money to expedite his application. He had been through this drill three days running, and each day they sent him away to return the next day. Finally they called his name. He came back to tell me he still did not have a passport. Some problem with an approval from the Washington office, which was now closed (the three-hour time zone difference). My hopes were sinking fast. I continued to wait and listen as name after name was called and never mine.

Late in the day, when there were only a few people remaining and closing time loomed near, they called my name. "Al Stevens, go to window 19." I almost missed it. I went to window 19 expecting the worst. There it was, an envelope containing my new passport. Spirits lifted, I thanked everybody I could find and said loudly for everyone in the room to hear, "Ladies and gentlemen, the system works!"

And it does work. The only flaw in the system is that the process -- the way you are moved in and out of the building, from line to line, window to window, with no understanding of the meaning of it all -- engenders apprehension and uncertainty. Throughout the day, I did not know what my fate would be or even what it might be. There was no way to understand how the information flows or where I would go next or what stages of passport approval, construction, packaging, and delivery were involved. What I could see, the pile of envelopes, for example, resembled chaos. Anxiety and impatience are the inescapable consequences.

But the system worked, at least for me. Out of pure stupidity I found myself in need of a miracle to be delivered by a group of dedicated civil servants who go through this same mess every day, and they came through. It works. If I were to redesign this system, the only thing I would change is the quality of information available to the people. I would add some kind of electronic status board so that everyone could see where they were, where they were going, and the status of their passport. Oh, well, it's only once every 10 years.

The next evening we were back at the airline ticket counter at LAX. The ticket agent's face lit up when he saw us. He was glad to have us on our way at last and was sorry that Judy missed two days of shopping. We thanked him for his help in directing us to a happy solution of a crazy problem.

Several things could have intervened to derail this trip. If we had decided to leave even one day later, I never would have gotten to the conference on time. If the agent in Orlando had spotted the expired passport, we would not have gone; the nearest passport office is in Miami. If we had chosen a different connecting city, if the cab driver had taken me downtown instead of to Santa Monica, if I had not decided on a whim to take my airline ticket with me to the passport office, and so on. Judy says she has a guardian angel named Rebecca who sees her through situations like this one. Judy never doubted that everything would work out. It seems that Rebecca likes to shop, too.

SD Asia

Software Development Asia is a downsized version of the stateside editions. This was only its second year, and this year's attendance was off from last year, probably because of the declining economic situation in Southeast Asia.

I gave two talks. One was on the changes that Standard C++ introduces to the C++ language as the ARM describes it, a subject that I have been addressing in this column. I had good attendance, but not many of them were programmers. Since the presentation was mostly code and since I got virtually no response from the audience, I assumed the presentation was a bust. Later, after attending several other talks, I asked why attendees do not ask questions during the sessions. The response was that their culture is too polite. They do not want to embarrass a speaker by asking a question that the speaker cannot answer. They certainly do not want to challenge the veracity of a speaker. That would be unthinkable. We could use a few of those folks at the stateside conferences.

My second speech was about debugging and testing. I talked about the history of debugging and showed a picture of Grace Hopper and her famous bug. I told how debugging was in the days when we used front panel switches and then later, when they wouldn't let programmers get near the mainframe computer and we had to debug through the window, the hole-in-the-wall style. I talked about debugging tools and techniques for writing programs that were designed to be hospitable in a debugging environment. I talked about where bugs come from and how a clear understanding of a program's requirements are essential to finding and fixing bugs. I described debugging techniques, how to narrow in on a bug by closing in on its symptom and how intuition is as valuable a tool as any automated debugging aid. And I addressed the larger subject of system validation, explaining the differences between debugging a program and testing a system and the requirements for conducting an effective beta test program. That talk got a good response -- not in questions, of course, but smiles, nods, and laughter. I think the better response was because you can make light of a subject that is mainly about human error and frailty and everyone relates to it. On the other hand, it's not easy to get them rolling in the aisles when you explain placement delete or mutable data members.

There was the usual "Java for C++ Programmers" presentation, and this one was better than most such sessions that I've attended. Paul Tyma, the presenter, knew Java very well, judging from his answers to my questions. (Yeah, I defied national tradition and asked a few questions.) What I really liked was that he didn't use the typical indefensible argument that we need Java to eliminate the flaws in C++. The main problem with the presentation, however, was his that knowledge of C++ is a bit dated. According to Tyma, one of Java's superior points is that it has a standard string class and another is that Java has automatic memory management and bounded arrays, all of which evinces ignorance of std::string, std::auto_ptr, and STL container classes. He also failed on the object-oriented design front by carefully explaining the IS-A relationship with an example of a base class named Parent and a derived class named Child and by explaining abstraction with a ridiculous example, wherein a designer and builder of pistons for engines does not need to know what a piston is for.

C++ Namespaces

I'll continue now my discussion of the migration from C++ to Standard C++. Although I had intended to simply address how things work and not get into how one thing or another ought to have been done, one issue keeps nagging at me -- the issue of C++ namespaces.

I spent a good part of my spare time in Kuala Lumpur reviewing a pile of newsgroup articles from comp.std.c++, a newsgroup that addresses Standard C++. These articles were posted by participants in response to a challenge of the validity of the Standard C++ namespace feature. I got into the fray and a real brouhaha ensued. My attitudes about the namespace feature and the fact that it actually found its way into the standard specification were formed during this exchange, which means that before articulating any particular position I was teetering on the fence. The strength of the other posters and my own articulation cleared my vision, I think. Here are my conclusions, with which you may or may not agree:

  1. Namespace is a major language feature that the committee designed and specified without much experience in using the feature in the real world in C++ environments. I am told that they drew on their experience with namespace features in other languages. I believe that they also used their intuition and understanding of the problem to invent a solution the implications and consequences of which no one really understands very well. This understanding will come in time, and that experience might call for major changes to the feature just as the behavior of classes underwent major changes over the years. The difference is that namespace is now a standard language feature and to mess with its definition some time in the future could cause major industry backlash due to the potential of widespread broken code. A lot of libraries are going to be coded to this standard.
  2. Namespace addresses a problem that not everyone agrees is widespread enough to have warranted the addition of a major language feature. Apparently if you ever had namespace collision problems with a big system, it's the worst thing that ever happened. If, like me, you never had such a problem, it ain't a big deal.
  3. The advantages of namespaces over external name prefixes are ones of aesthetics and notational convenience. The namespace solution is no more complete (or better understood) than the use of prefixes; it's just prettier. I like pretty code. I believe that the notational improvements of the namespace feature make it worth having a feature if the problem is as large as some programmers have said. I would have preferred that we had more experience in the use of the feature before it became a standard, however.
  4. There are no well-established conventions for how to assign a namespace name. There is speculation about what would be appropriate and proper. Each speculation leads to controversy. For example: Use your company's name as part of the namespace or follow the Java example and use Internet domain names. What happens when your company sells the library? The fact that the namespace experts themselves engage in this sort of speculation and debate indicates that the issue is not clearly understood.
  5. There is no international authority for the prevention of namespace name collisions like there is for Internet domain names. Someone suggested using trademark law. I shudder at the thought.
  6. There is no way for a program to put a legacy library into a namespace without recompiling the library, and if you don't have the source code, you cannot recompile the library. After giving it much thought, I have concluded that, the implementation problems notwithstanding, a namespace standard that does not include this requirement, particularly in view of the large number of legacy libraries in use, is deficient. If the problem is as large as some have said, that problem is most likely associated principally with legacy, pre-namespace libraries. It is not sufficient to simply assume that all these libraries will be recompiled within namespaces.
  7. Some people think that the Standard C++ Library should not have been placed into the std or any other namespace. I tend to agree for two reasons. First, inasmuch as int and float are in the global namespace, why are not string and vector? All four are standard types in the standard language. The difference is that two are intrinsic types and two are class implementations. These are details of implementation and should be regarded by the programmer from the same level of abstraction. (I do, however, recognize a requirement to separate necessarily external names that are not part of the public interface.) Second, the fact that the libraries are in the std namespace prohibits any implementation that does not implement namespaces (EC++, for example) from being officially recognized as a proper subset, which, I speculate, will encourage maverick and cavalier attitudes about standards among those pragmatic developers who want or need to work with smaller versions of the libraries and compilers.

I can think of one possible response to number 7, so I'll give it here to cut down on the e-mail. By placing string, vector, and that ilk in the std namespace, you permit programs to use the new stuff and still link with legacy libraries that use custom classes with the same names. I can think of no other good reason to do it.

If you have different opinions on these points please send them to me at astevens@ddj.com. If I get enough, and if you keep the burners set to simmer or below, I'll publish them in a future column.

I recognize that these conclusions involve and perhaps even provoke controversy. I was chastised on the newsgroup and in private e-mail for coming late to the party -- for not being a part of the process when my contributions might have carried some weight and affected some change. I have three responses to that. First, I decided not to participate so that my journalistic objectivity could not be compromised by the dynamics of group involvement. As James Michener said, "The writer must never allow himself to become part of the story." Second, there are legions of programmers out there who, for one good reason or another, are not part of the process. They are the majority, and they are the users of this language. They are you, and my role as I have seen it during my 10 years with this column is to represent you, my readers. Third -- and this is a painful admission -- I have learned after years of working in software teams and jazz bands that I am not always effective in group situations. The weight of my drive and personality has killed too many good ideas that might have survived and flourished if someone with more charisma and team skills had been their advocate. I might have done more harm than good on that committee.

Home Again

The trip home from Kuala Lumpur was without incident, particularly considering what we went through to get there. One pleasant footnote, though. As we "deplaned," as they say, at LAX, who was standing in the jetway to greet arriving passengers but our helpful agent from eight days prior. It was like finding family to see his face light up again when he saw us. I wish I had gotten his name.

DDJ


Copyright © 1998, Dr. Dobb's Journal