MERCURY (As in the US Manned Space Flight Program)

As a freshman at CMU in 1968, I took my first computer programming course - Algol on the Univac 1108. Near the end of the term I decided it would be fun and interesting to write something that simulated parts of the Mercury, Gemini, and Apollo manned space programs. Mercury got into orbit, coasted for a while, and reentered. Gemini added changes to the orbit and rendevous with another mission or target in orbit. Apollo added travel to lunar orbit and landing on the moon in the Lunar Module. And returning to the Command Module and returning to Earth, of course.

I never got past Mercury, as it didn't take long in the second semester before I was too busy with coursework. Besides, all my orbits were decaying and one improvement made things worse. So my Mercury program ended in February 1969. NASA's program ran from 1961 to 1963, Gemini 1965 to 1966, and Apollo 1968 to 1972.

Still, it was a landmark program for me and I've kept the listings for (Yikes!) over 50 years. It also became a bit of a benchmark.

Before I started at CMU, Edsger W. Dijkstra wrote a now famous letter to the Communications of the ACM, Go To Statement Considered Harmful. I may have heard about it in class, I certainly heard about it later, but partially in the newer context of interfering with pattern recognition in optimizing compilers.

Just before my sophomore year, Dijkstra wrote another seminal document, Notes on Structured Programming. I never saw it until, umm today, but it had an immediate influence on teaching programming at CMU. Based on my quick scan, he basically advocated for a "top-down" design where you start with a few lines describing the steps the program will make. Then each is described again and so on until you wind up with the code. Other phrases that have been attached include "Modular Decomposition" and the "K.I.S.S Principal - Keep It Simple, Stupid!"

I think all that is involved in many other activities, like building a house. Start with the number of floors, bed rooms, bathrooms, and distinctive features; then determine sizes, plumbing and electrical requirements, etc. Structured programming also advocated for limiting the scope of variables to reduce the risk of something way over there breaking something over here. Or, don't let the stove control the refrigerator. Especially don't let the stove, microwave oven, and baby monitor all control the refrigerator at the same time.

Sometime or other, let's say the summer between my sophomore and junior years, I took a look at my Mercury program to have a good laugh at my "spaghetti code" - ill-structured code. I was surprised, pleased and a bit chagrined that the code was quite well structured. Basically the program prints "ASCII Art" images of the Earth, ellipses, and simulated orbits. Each had its own subroutine, and I had others for printing a clearing the string array that I "drew" into.

I had seen some badly structured code written by other students in that first class. I remember one assignment where someone else's program was two or three times the size of mine and very hard to follow. Eventually, I decided that the people who most strongly advocated for structured programming were the people who didn't innately write structured code.

In my senior year I took a simulation course that touched on several languages and simulation problems. One was to look at the classic multiple queues at bank and store checkout lines vs a single queue style that is sometimes used now. Another was to model a chain of tailgating cars driving down the road and have the lead car slow down. The reaction time delay flowing back from driver to driver led to rear-end crashes as each car had to make a stronger response.

At the end of the course I took a look at Mercury again and realized that one thing I had done was to vary the time between computing new points in orbits. I made it inversely proportional to the square of the distance between the satellite and the center of the Earth. It worked very well for orbits of objects like meteors that would follow a path close to the center of the Earth. We didn't even talk about something like that in class or discuss problems of the long-term accuracy of adding small changes in the satellite's location on each step and the problems inherent to the loss of precision that entails.

Looking at it now, I see several things I'd do differently today:

Other notes on the program.


Contact Ric Werme or return to his home page.

Written 2023 April 23, last updated 2023 April 23.