There is nothing quite like clicking “run”, for a program and… it doesn’t. All programmers know the feeling, especially those beginning in the field and it’s not a good one. When it happens, you know you’re in for an uncertain amount of time, searching for the culprit, the bug in the code which is blocking the program to perform. Only then can you adjust accordingly and bring it to life. Here are some of the most common programming errors.

No Error Will Stop a Good Programmer

We have all lived these moments, programmers or not, when we are convinced that we have built something great, and when we launch it… it simply doesn’t work. Although it can be quite frustrating, it is important to keep going until we find the solution. That is the difference between normal people and great ones.

That’s why, being aware of the most common errors is important. It will save you a lot of time by searching specifically for them, in order to solve the problem. Here is a non-exhaustive, explanatory list, for some of them.

Logical Errors

As in life, an error of logic will do much more damage than just stop the program from running or make it crash: it will cause it to misbehave. That complicates everything because what was supposed to come out in a certain way still comes out but with a completely different result.

The most common logic error is “null reference.” These errors are responsible for many bugs that can occur inside a program. They imply that there was some kind of computer logic which was not respected in the coding. Sometimes, it is a property or a field that is null or a condition has kept an object from being created. Other times, it is a local variable field which exists but is not initialized.

To understand a logical error in a program, think of a situation in your life which is plausible, but not the reality. For example, the NASA once lost one of its space crafts because there were some calculations done in American units while others where in UK units. The computer understood both, but did not connect them together.

Syntax Errors

Unlike logical errors, the program will tell you where the syntax errors are located (and yes, it is a relief!). But there are various syntax errors that can occur. They are caused by the fact that they are not following a normal sequence, according to the computer’s language.

There are two languages that can be involved in the error. The first one is compiled language. In this case, you will come into contact with the error at compile time. You’ll just need to correct it for the program to work as it should. The other language is interpreted. They are going to come up when you run the program. There is also the possibility that the program will not inform you that it is a syntax error, which would render your search a little bit more complicated. Although, in both cases, the compiler (interpreter) will let you know where to look for it.

The fact is: computers, like humans, have grammar rules and if you don’t follow them, they cannot understand what you need them to do. We are able to comprehend the meaning of a sentence if someone forgets to place a parenthesis somewhere in a sentence, but it is not so for a machine. The smallest syntax error will stop the program from running.

Semantic Errors

If you are wrong about semantic in a computer language, you’ll simply end up getting nothing at all. Contrary to the logical error, which can lead you in various directions, a semantic error will simply make the program non-functioning. If you try to run it and nothing happens, then you have a semantic error somewhere inside. You’ll need to find it and recreate that section entirely.

What Are the Differences between the Various Errors?

If we want to sum up the different error possibilities, we could say that a semantic error is an improper use of a program statement. That means, there is simply no understanding at all of what you were trying to tell the program to do. It’s the opposite of the logical error where it understands something, but it’s just not what you were trying to tell it to do.

If you have a semantic error, you are simply not telling the program what to do using the right words. As for the syntax errors, it clearly states what it is: a typo or a command written in a bad grammar. Finally, the logical error is simply that the program understood something which is completely different than what you were trying to tell it.

Errors cannot be avoided. They will always happen, no matter how hard you try not to make them. It’s the art of solving them which will make you a great programmer.

Categories: Computering

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *