Saturday, January 27, 2007

Programming errors

In my last entry, I said, "I don't know. The trouble with software is - you know there's going to be a problem with it eventually. You just haven't found it yet."

This reminded me of something I read in the second C language book I read (the one right after reading Kernighan and Richie). I don't have the book anymore and don't even remember the name. So, this isn't an exact quote but it went something like, "You'll find that as you gain experience with the C programming language, the mistakes you make will become more subtle and more difficult to find." I've found this to be fairly accurate.

While I still make stupid mistakes like the famous:

if ( condition ) ;

where function() is always called regardless of the state of condition (because I mistakenly put a semi-colon after the if ( condition ) statement). I find more of my errors involve the architecture of the program rather than syntax errors. Of course, when moving to C++, whole new realms of errors are opened to you. The Java language removes some of these errors from your repertoire but adds others.

So, I seem to paint a rather pessimistic picture. You never gain on the errors. The more you write, the more experience you gain and the more difficult it gets to find the errors. But in reality, I find that as I gain experience, I have learned to avoid many errors. I find it pays to write your program as if someone else will be needing to read it, understand it and use it. This keeps me from using tricks while coding. It helps me to keep my code transparent. The days of needing to use obtuse coding styles so that code will run faster or take less room are gone. Compilers have improved over the years.

It pays great dividends to write code that makes sense, uses meaningful symbol names and is well commented. While comments can sometimes get out-of-sync with the code when you go back to make changes in the code, I find comments to be very important. You can only explain the reasoning behind an algorithm by using comments. What I'd like to see, someday, is a compiler that lets you embed links, pictures and diagrams in the comments so you can point to a paper or website that explains the reasoning behind that section of code.

Comments are not the only way to make code better, though, and I try to not depend on comments completely.

Friday, January 26, 2007

"That's not going anywhere"

In my last entry, I was lamenting the fact that I couldn't get any ideas for a blog entry when I could actually use them. Just now, I heard someone use one of my favorite sayings, "That's not going anywhere."

I remember my father using that phrase when we would be loading something in the car or a truck. I'd be worried that when we got moving, the load would shift or fall out. So, he'd give this incantation, "Don't worry. That's not going anywhere." And it never did. I know it wasn't the words that kept the thing from moving - t was his being careful and knowing from experience how to place things. But there was something about the phrase that seemed to not only put me at ease but it appeared to be like closing the door as you left or putting the period at the end of a sentence. You just did it. It was the final step of the process.

My father certainly couldn't have invented the phrase. He must have heard it somewhere else. I often joke with my friends when we are loading something into a truck: We're not done until someone says, "That's not going anywhere." The other silly part of this is that of course, it IS going somewhere! We're loading it into a truck (or onto a ship) for goodness sake. What we mean is, "That's not going to shift," or "That's not going where we don't want it to go," but those don't have the same ring.

Maybe we need something like this in engineering. Or maybe engineers have been using this all along. I'll bet the builders of the pyramids said, "That's not going anywhere." Maybe the engineers of the first Tacoma Narrows Bridge (the one that collapsed) forgot to say, "That's not going anywhere" before they opened it for traffic. This is fine for Civil Engineering but what about for Electrical, Electronics or Software Engineering? We need a finalizing incantation, too.

How about, "That's not drifting anywhere," for an electrical analog circuit? Maybe, "That's not burning out anytime," for a high power electrical system. But I can't think of anything appropriate for software. "That's not being misused anytime," for a program function just doesn't cut it. It lays all the blame on the people using the function in the future. Maybe something like, "That's solid code," after SteveMaguire's book, " Writing Solid Code." Or maybe, "That's not breaking anytime," or "No bugs there."

I don't know. The trouble with software is - you know there's going to be a problem with it eventually. You just haven't found it yet.

Tuesday, January 23, 2007

I'm a terrible blogger

How can I have so many ideas for this blog while I'm driving to work, while I'm in the middle of a meeting, during a church service and while I'm in bed at night yet not have a single idea when I have a few minutes to spend writing?

Some ideas that may be explored soon:

* How an engineering group is similar to a musical group
* I'll show some pictures of our new house (before and after) and describe how it went together
* I'll describe the night rain flooded into our new house the week after we moved in
* I'll list some books I've really enjoyed recently - both technical and non-technical
* The idea of creating a small language for use in a larger program
* How I get a project organized and how I don't get a project organized
* Some funny stories that have happened to me and my friends over the years
* Some day, hopefully after the ground thaws, my 10-year old son and I are going to build a shed in our backyard - that should be worth a few stories!

These aren't great ideas but I'm sure I'll have some good ideas on the way home tonight.

Tuesday, January 16, 2007

Learning too late?

Well, I've already broken my New Year's Resolution of writing at least once a week. I'll try to do better.

It may look, from the subject line, like I'm going to write about the situation where someone makes a mistake in their life in the vein of "not looking before they leap", but instead I'm thinking about the situation in electronics and computers. Things are changing so quickly that people coming into these fields now don't have the advantage that some of us older folks have had. There is an analogy in music that I'll start with.

It used to be that there were a lot of places where a musician could go to learn how to perform. For classical musicians, people used to have small groups in their home for small audiences. For jazz, there were a large number of clubs that would take people with little experience. For popular music, there were lots of small stages around, like vaudeville or community halls or even town bands. In the present day, getting music lessons is very expensive. The schools and churches are about the only place left that allow you to perform without and lot of experience. By the way, have you ever noticed how many singers got their start in a church choir? You not only get free instruction but you also get a lot of encouragement. The last thing a new musician needs is a bunch of negative criticism. A learning musician needs encouragement and a chance to perform. I think we are making it harder for new musicians to get the experience they need. That is why it is so hard to hear good music these days. Our society is limiting the opportunities new musicians have to learn in the real world. Even though churches remain one of the last places for a new musician to get experience, they are going more and more to using canned music or hiring professionals to do the music. I believe we are missing the point. The music doesn't need to be perfect to please God (after all, it will never be exactly perfect anyway). The importance is the feeling behind the music, the sincerity of the offering of the music and the opportunity for people to be able to join in with the music.

I believe it is similar in engineering. Many of us learned by building small kits (HeathKit is gone now). We had to know the hardware. If we did any programming, it was in assembly language where you have to know every detail of the machine. Plus, you got the opportunity to do it because no one else knew how to do it. Now, companies have a software group that does all that stuff. If the company needs a program, it writes up a specification and submits it to the software division which writes up a schedule and assigns it to one or more people. While this is necessary for business, it doesn't help new people enter the field. There need to be some projects that amateurs can handle. Another problem is that now, the hardware has advanced so far that new engineers have no way (or at least no time) to dig into the machine to understand how it really works. The one place that still allows some of this is in embedded systems, these are the products where the electronics (and usually a microprocessor) are part of the machine - built into the machine. If you get into an embedded project, everything is simpler and more pragmatic. You're trying to get a job done and everything is exposed to you. Here is a chance for new people to get their feet wet and learn how things really work.

What brought this all up to me today was reading a note about the latest version of the CodeGear (formerly Borland) Delphi compiler and C++ compiler. One fellow asked if there were any good books to learn about the compiler and its integrated development environment (which includes the compiler, a text editor, debugging tools, a help system etc.) and the answer was no. They would have to look for books about earlier versions of the compiler. I am so fortunate that I started with the compiler when it first came out and there were a number of good books that started from the beginning. Also, you could ask a question on one of the many newsgroups and get a helpful reply from someone who had just had the same problem. It seemed that everyone was on the same level - all coming up to speed together. Now, if you ask certain questions, you can get an angry reply that, "this has been covered a million times before." Well, not for this guy. How is a new person supposed to learn but by asking questions and trying to get more experience?

Monday, January 08, 2007

Opposites might attract but...

Today is the anniversary of my wife and I getting married. It was thirteen years ago. These have been wonderful years and I would do it again in a minute. My wife and I knew each other for years before I finally wised up and asked her out. I thought I knew what I wanted in a wife but I was wrong. I'm not sure how you come to this conclusion but I came to it by realizing the limitation of the "Opposites attract" statement. It's fine when you're talking about magnetic material. Yes, the opposite poles attract and get together. Then they are stuck! It's not like they chose to be together. They just blindly joined and now only an external force can separate them. And yes, lots of times people who are opposites are attracted to each other. But being attracted to each other and being right for each other are very different things.

What I found that finally got me to realize how "right" my wife was for me was that for a relationship to really work and to blossom, there must be a lot of common ground. Shared interests are very important. Shared values are even more important. And shared respect is extremely important. I first noticed this when we were both part of a group in our church that was asked to form a "contemporary music worship team". The church was going to start a separate service with more contemporary music that might appeal to younger people. There were about seven or eight people at the first meeting and the pastor asked for some suggestions for songs. The other people in the group started shouting out suggestions and singing parts of them. My future wife and I both had suggestions but they were overlooked because we weren't shouting them out and "selling" them to the group. So, we sat back and watched and later performed the songs the others had suggested. But my wife and I were actually the two most accomplished musicians in this group. She had been part of a group like this in another church (and played both the piano and guitar) and I was the member of a couple of musical groups outside the church (as well as a pianist for the regular church service and member of the choir). I looked at her during the meeting and saw the look on her face and recognized it as the feeling of disappointment inside me.

Another time I remember was when the church was having a get-together for the young people of the church and my future wife called me to tell me about it. I remember getting all excited that she was asking me to go to this event and made sure that was there early so I could talk with her and sit next to her. We talked a lot during the evening and I was getting happier and happier until I heard the guy on her other side say he was sure enjoying himself and was glad she had asked him to this party! I was crushed. She had just been in charge of calling all the people in the church who might be interested in this party. She wasn't asking me (or the other guy) to the party to be her date. But it made me realize how much I liked her. It made me realize what a mistake I was making in not pursuing her.

When I finally asked her out on a date (although I made it sound like it wasn't a date in case she rejected me or didn't have a good time), we drove into the city to go to some music stores and to have lunch. In contrast to every other date I had ever been on, I was not nervous at all! And we had no trouble talking about things. When we talked later about this "date", we were both amazed how much fun it was and how relaxing it was to not have to put on airs for the other person. We had so many shared interests and shared values that we just always wanted to be together to talk about (and learn more about) the things we both loved.

Being married is the best thing that ever happened to me. I love my wife more than ever. Our only regret is that we didn't get married sooner.

Tuesday, January 02, 2007

Resolution for the new year

It's been too long since my last post. So, I'm resolving to post at least once a week but with the hope that I'll post more than that. I'd like to post once a day but I've shown myself that I'm not good at that. It's not that I want to post just any old junk just to make a daily post. The problem is: Why is there not at least one interesting thing to say once a day? It doesn't have to be earth shattering or interesting to anyone else but me. But it should be something I would want to read myself after some time has passed.

So, we did move into our new house the week-end after I made my previous post. Things were very busy but there was no excuse to not post to this blog because the computer and DSL connection remained in my mother-in-law's house during that time (I did move it over to the new house but the move went smoothly and it was up and running the same day). There was also a very interesting problem to write about the night of November 11 and the morning of November 12. I'll write a full entry about that. But the important thing is that we are fully moved into our new house. We had both Thanksgiving and Christmas in our new house and they were wonderful.

More later.