Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

December, 2008

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Why Do So Many Programmers Use One Character Index Variables

    • 14 Comments

    There is a commercial on TV these days where a little girl is helping her mother and grandmother prepare a large turkey for a holiday dinner. The little girl asks the older women why the turkey only has one leg. The other leg has been cut off and the older women explain that this is because the little girl’s great grandmother always did it that way. Then a flashback shows that the reason the leg was originally cut off was because the great grandmother didn’t have a pot that whole hold the turkey unless one leg was cut off first. Her daughter and granddaughter and great granddaughter could probably easy buy a pot large enough. In fact the pots they have now might be large enough. But “because that is the way we have always done it” these women were still cutting off one leg.

    I remember Grace Hopper once saying in a talk that if we every said “because that is the way we have always done it” she would appear behind us and haunt us. I can’t hear the phrase without thinking of here over 30 years later. But in a real way that is why so many programmers using index variables of one letter and that the letter is between “i” and “n.” So what’s the story?

    For many people back in the day the principal programming language was FORTRAN. Early versions of FORTRAN would let you specific the variable type of a name but the default values for integers were variables that started with the letters “i” through “n.” Also with some systems longer variable names took up more room in memory. And memory at that time was expensive. So to make it easy a lot of people used “i”, “j”, and “k” as their first choice for index variable names. That’s how I learned it.

    Those of us who learned FORTRAN as a first language brought that habit with us to other languages. To BASIC, and C, and Java, and even PASCAL. And many many more. Why? “Because that is the way we have always done it” Shame on us. And the people we taught taught the same thing to others. That’s not really good. “index” is such a better variable name. In specific cases there are even more helpful, more descriptive and more useful variable names. For counting loops, for variables to pass to methods and many other places. Generally most of use have gone beyond the one character variable name. The last big sticking point seems to be index/loop variables. It’s probably time we all got past that. At least we should teach better practices to our students.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    We Need Wireless Power

    • 6 Comments

    New Hampshire was hit by a major ice storm last Thursday night. The power at my house went out initially around 7:30PM but my UPS system kept the Internet modem and Wi-Fi access point up for a while. The power came back briefly around 10PM but went out for good at midnight. This time the storm took out the cable so there was no Internet. After almost 36 total hours without power or heat (it dropped to 20F or –6C outside) the power finally came back Saturday morning. Now on Monday there is still no cable or high speed Internet at home. I was able to get to the Internet on my cell phone using EDVO and also make phone calls. The wireless networks were a lot more resistant to the effect of the storm than the other utilities. If only Tesla had been more successful with his research on the wireless transmission of power.

    Schools are pretty much closed state-wide in New Hampshire as much of the state is still without power. The north side of my town is still without as are several near by towns. You really don’t realize how dependent we are on electric power until you have to go without it. The same is true for the Internet. I found myself stopping several times a day thinking “Oh I’ll look that up on the Internet.” only to catch myself with the memory that the Internet was not available. No looking up bank balances. No looking up that company someone told me about. No ordering that Christmas gift. It felt weird.

    How did we get along before? Well my neighbor who has a very old house had a gas stove that didn’t need electric power and a fireplace. We were able to cook and stay warm there. But somehow I don’t see us going back to encyclopedia in place of the Internet. Not for full time at least. And have you seen a typewriter lately? I saw some in a store recently and they were clearly labeled for collectors rather than for people who wanted to use them. Long term there is no going back.

    Well that is my observation for today. More useful posts once I have had time to tap the network for a while.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Cheating, Ethics, Computer Science

    • 4 Comments

    It all started when I saw a link to this article about students creating videos to show others how to cheat. These young people don’t see anything wrong with cheating or helping others to cheat. Oh they understand that their teachers don’t like it but they don’t seem to really understand why. This led to a little chat on Twitter. The problem is everywhere. The way I see it students have decided that the goal of school is to get good grades. So if cheating helps them get to that goal they are by some definition a success. Now personally I always saw the goal of school to learn things but apparently that is not the case any more.

    So where does this attitude come from and where is it taking us? Well according to David Callahan's book "The Cheating Culture: Why More Americans Are Doing Wrong To Get Ahead” (book review here) cheating is pretty much everywhere in our culture today. Is winning everything? Is “how one gets there” no longer important? Important and scary questions.

    But you’re no doubt waiting for the promised tie in with computer science. Well let me start with that great line “with great power comes great responsibility.” It seems to be that the rapid rate of growth of computer controlled systems is providing computer scientists and information technology professional with great power. This is not power we want controlled by unethical people. This is already worrying people.

    Visit this article about computer-controlled battle robots. (NY Times free subscription may be required) The article talks about robots that will battle people not other robots. The “research hypothesis is that intelligent robots can behave more ethically in the battlefield than humans currently can,” according to Ronald Arkin, a computer scientist at Georgia Tech. Does that say something scary about humans to you? It does me. These robots will be programmed by humans though. A mixed item that. One hopes that ethical rules can be agreed on and programmed and that robots will avoid making unethical choices because of fear or bigotry or other emotional issues. But those programmers has better be highly ethical or we’re all in trouble.

    There are of course a lot of artificial intelligence issues to worked out for these robots as well. But ethics is always going to be important. I believe we need to start talking about that early. Not just for computer science of course but those of us involved in CS education have to make sure that our students don’t miss out on it. We should not just assume that they will learn it in some other class. And we should be particularly distrustful of the idea that they will learn ethical behavior when they leave school. There are just too many examples of the opposite happening.

Page 1 of 7 (21 items) 12345»